Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions src/PaintUtils.java.superzanti
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package openmods.utils.render;

import java.util.Set;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import openmods.Mods;

import com.google.common.collect.Sets;

import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;

public class PaintUtils {

private final Set<Block> allowed = Sets.newHashSet();

public static final PaintUtils instance = new PaintUtils();

protected PaintUtils() {
allowed.add(Blocks.stone);
allowed.add(Blocks.cobblestone);
allowed.add(Blocks.mossy_cobblestone);
allowed.add(Blocks.sandstone);
allowed.add(Blocks.iron_block);
allowed.add(Blocks.stonebrick);
allowed.add(Blocks.glass);
allowed.add(Blocks.planks);
allowed.add(Blocks.dirt);
allowed.add(Blocks.log);
allowed.add(Blocks.log2);
allowed.add(Blocks.gold_block);
allowed.add(Blocks.emerald_block);
allowed.add(Blocks.lapis_block);
allowed.add(Blocks.quartz_block);
allowed.add(Blocks.end_stone);
allowed.add(Blocks.leaves);
allowed.add(Blocks.leaves2);
if (Loader.isModLoaded(Mods.TINKERSCONSTRUCT)) {
addBlocksForMod(Mods.TINKERSCONSTRUCT,
"GlassBlock",
"decoration.multibrick",
"decoration.multibrickfancy",
"leaves");
}
if (Loader.isModLoaded(Mods.EXTRAUTILITIES)) {
addBlocksForMod(Mods.EXTRAUTILITIES,
"greenScreen",
"extrautils:decor");
}
if (Loader.isModLoaded(Mods.BIOMESOPLENTY)) {
addBlocksForMod(Mods.BIOMESOPLENTY,
"bop.planks",
"appleLeaves",
"persimmonLeaves",
"leaves1",
"leaves2",
"leaves3",
"leaves4",
"colorizedLeaves1",
"colorizedLeaves2");
}
if (Loader.isModLoaded("Natura")) {
addBlocksForMod("Natura",
"floraleaves",
"floraleavesnocolor",
"Dark Leaves",
"Rare Leaves");

}
if (Loader.isModLoaded("TwilightForest")) {
addBlocksForMod("TwilightForest",
"TFLeaves",
"TFMagicLeaves",
"TFLeaves3",
"DarkLeaves",
"GiantLeaves");
}
if (Loader.isModLoaded("chisel")) {
addBlocksForMod("chisel",
"leaves");
}
if (Loader.isModLoaded("IC2")) {
addBlocksForMod("IC2",
"blockRubLeaves");
}
}

protected void addBlocksForMod(String modId, String... blocks) {
for (String blockName : blocks) {
Block block = GameRegistry.findBlock(modId, blockName);
if (block != null) allowed.add(block);
}
}

public boolean isAllowedToReplace(Block block) {
if (block == null || block.canProvidePower()) return false;
return block.isNormalCube() || allowed.contains(block) || block.getRenderType() == 0 ;
}

public boolean isAllowedToReplace(World world, int x, int y, int z) {
if (world.isAirBlock(x, y, z)) { return false; }
return isAllowedToReplace(world.getBlock(x, y, z));
}
}
Loading