diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index aabb0c492..fae65f366 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -66,6 +66,7 @@ import mekanism.client.gui.GuiTransporterConfig; import mekanism.client.gui.GuiUpgradeManagement; import mekanism.client.render.MekanismRenderer; import mekanism.client.render.RenderTickHandler; +import mekanism.client.render.ctm.TextureStitcher; import mekanism.client.render.entity.RenderBalloon; import mekanism.client.render.entity.RenderFlame; import mekanism.client.render.entity.RenderObsidianTNTPrimed; @@ -435,7 +436,7 @@ public class ClientProxy extends CommonProxy { MekanismRenderer.registerItemRender("mekanism", item); } - + @Override public GuiScreen getClientGui(int ID, EntityPlayer player, World world, BlockPos pos) { @@ -647,6 +648,8 @@ public class ClientProxy extends CommonProxy { MekanismRenderer.init(); + MinecraftForge.EVENT_BUS.register(new TextureStitcher()); + //Register entity rendering handlers RenderingRegistry.registerEntityRenderingHandler(EntityObsidianTNT.class, new IRenderFactory() { @Override diff --git a/src/main/java/mekanism/client/render/ctm/BlockRenderTypeCTM.java b/src/main/java/mekanism/client/render/ctm/BlockRenderTypeCTM.java deleted file mode 100644 index e07ae883c..000000000 --- a/src/main/java/mekanism/client/render/ctm/BlockRenderTypeCTM.java +++ /dev/null @@ -1,24 +0,0 @@ -package mekanism.client.render.ctm; - -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumWorldBlockLayer; -import net.minecraft.world.IBlockAccess; - -public class BlockRenderTypeCTM { - - public ChiselTextureCTM makeTexture(EnumWorldBlockLayer layer, TextureSpriteCallback... sprites) { - return new ChiselTextureCTM(this, layer, sprites); - } - - public CTMBlockRenderContext getBlockRenderContext(IBlockAccess world, BlockPos pos) { - return new CTMBlockRenderContext(world, pos); - } - - public int getQuadsPerSide() { - return 4; - } - - public int requiredTextures() { - return 2; - } -} diff --git a/src/main/java/mekanism/client/render/ctm/CTM.java b/src/main/java/mekanism/client/render/ctm/CTM.java index 93de634b5..688df9230 100644 --- a/src/main/java/mekanism/client/render/ctm/CTM.java +++ b/src/main/java/mekanism/client/render/ctm/CTM.java @@ -66,6 +66,8 @@ import static mekanism.client.render.ctm.Dir.*; * -CptRageToaster- */ public class CTM { + public static int REQUIRED_TEXTURES = 2; + public static int QUADS_PER_SIDE = 4; /** * The Uvs for the specific "magic number" value diff --git a/src/main/java/mekanism/client/render/ctm/ChiselFace.java b/src/main/java/mekanism/client/render/ctm/ChiselFace.java index e887add0d..c0f88a684 100644 --- a/src/main/java/mekanism/client/render/ctm/ChiselFace.java +++ b/src/main/java/mekanism/client/render/ctm/ChiselFace.java @@ -5,7 +5,6 @@ import java.util.List; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.EnumWorldBlockLayer; -import net.minecraft.util.ResourceLocation; /** * Chisel Face, basically a list of IChiselTexture's @@ -16,23 +15,20 @@ public final class ChiselFace { private List childFaces; - private ResourceLocation location; - private EnumWorldBlockLayer layer; - public ChiselFace(ResourceLocation location) { - this(new ArrayList<>(), new ArrayList<>(), location); + public ChiselFace() { + this(new ArrayList<>(), new ArrayList<>()); } - public ChiselFace(ResourceLocation location, EnumWorldBlockLayer layer) { - this(location); + public ChiselFace(EnumWorldBlockLayer layer) { + this(); setLayer(layer); } - public ChiselFace(List textureList, List childFaces, ResourceLocation location) { + public ChiselFace(List textureList, List childFaces) { this.textureList = textureList; this.childFaces = childFaces; - this.location = location; } public List getTextureList(){ @@ -69,11 +65,6 @@ public final class ChiselFace { } } - public ResourceLocation getLocation(){ - return this.location; - } - - public void setLayer(EnumWorldBlockLayer layer){ this.layer = layer; } diff --git a/src/main/java/mekanism/client/render/ctm/ChiselTextureCTM.java b/src/main/java/mekanism/client/render/ctm/ChiselTextureCTM.java index 2b0893353..6a2bf6c64 100644 --- a/src/main/java/mekanism/client/render/ctm/ChiselTextureCTM.java +++ b/src/main/java/mekanism/client/render/ctm/ChiselTextureCTM.java @@ -16,15 +16,12 @@ import net.minecraft.util.ResourceLocation; public class ChiselTextureCTM { - @Getter - protected BlockRenderTypeCTM type; @Getter protected EnumWorldBlockLayer layer; protected TextureSpriteCallback[] sprites; - public ChiselTextureCTM(BlockRenderTypeCTM type, EnumWorldBlockLayer layer, TextureSpriteCallback[] sprites) { - this.type = type; + public ChiselTextureCTM(EnumWorldBlockLayer layer, TextureSpriteCallback[] sprites) { this.layer = layer; this.sprites = sprites; } diff --git a/src/main/java/mekanism/client/render/ctm/ModelChisel.java b/src/main/java/mekanism/client/render/ctm/ModelChisel.java index 5e45cebbb..8bae0b306 100644 --- a/src/main/java/mekanism/client/render/ctm/ModelChisel.java +++ b/src/main/java/mekanism/client/render/ctm/ModelChisel.java @@ -40,7 +40,6 @@ public class ModelChisel implements IModel { private Variant model; private Map models = Maps.newHashMap();; - private String face; private Map overrides = Maps.newHashMap(); private transient ChiselFace faceObj; @@ -53,6 +52,13 @@ public class ModelChisel implements IModel { private transient List textures = Lists.newArrayList(); + public String modelName; + + public ModelChisel(String name) + { + modelName = name; + } + @Override public Collection getDependencies() { List list = Lists.newArrayList(model.getModelLocation()); @@ -81,6 +87,16 @@ public class ModelChisel implements IModel { public IModelState getDefaultState() { return TRSRTransformation.identity(); } + + void load() { + if (faceObj != null) { + return; + } + System.out.println("LOADING MODEL"); + faceObj = TextureStitcher.createFace(modelName); + faceObj.getTextureList().forEach(t -> textures.addAll(t.getTextures())); + overridesObj.values().forEach(f -> f.getTextureList().forEach(t -> textures.addAll(t.getTextures()))); + } public ChiselFace getDefaultFace() { return faceObj; @@ -99,6 +115,7 @@ public class ModelChisel implements IModel { final String capture = stateStr; if (modelsObj.containsKey(stateStr)) { + System.out.println("LOAD STATE MAP") stateMap.computeIfAbsent(state, s -> modelsObj.get(capture)); } diff --git a/src/main/java/mekanism/client/render/ctm/ModelChiselBlock.java b/src/main/java/mekanism/client/render/ctm/ModelChiselBlock.java index c7efbdfad..2d09eb758 100644 --- a/src/main/java/mekanism/client/render/ctm/ModelChiselBlock.java +++ b/src/main/java/mekanism/client/render/ctm/ModelChiselBlock.java @@ -118,7 +118,7 @@ public class ModelChiselBlock implements ISmartBlockModel, ISmartItemModel, IPer for (EnumFacing facing : EnumFacing.VALUES){ ChiselFace face = model.getFace(facing); - int quadGoal = ctx == null ? 1 : Ordering.natural().max(FluentIterable.from(face.getTextureList()).transform(tex -> tex.getType().getQuadsPerSide())); + int quadGoal = ctx == null ? 1 : Ordering.natural().max(FluentIterable.from(face.getTextureList()).transform(tex -> CTM.QUADS_PER_SIDE)); IBakedModel baked = model.getModel(state); List origFaceQuads = baked.getFaceQuads(facing); List origGeneralQuads = FluentIterable.from(baked.getGeneralQuads()).filter(q -> q.getFace() == facing).toList(); diff --git a/src/main/java/mekanism/client/render/ctm/TextureStitcher.java b/src/main/java/mekanism/client/render/ctm/TextureStitcher.java new file mode 100644 index 000000000..29dfd838c --- /dev/null +++ b/src/main/java/mekanism/client/render/ctm/TextureStitcher.java @@ -0,0 +1,74 @@ +package mekanism.client.render.ctm; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.model.IBakedModel; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.resources.model.ModelRotation; +import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.ModelBakeEvent; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.client.model.Attributes; +import net.minecraftforge.client.model.IModel; +import net.minecraftforge.client.model.TRSRTransformation; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class TextureStitcher { + + private static List textures = new ArrayList(); + + private IBakedModel baseModel; + public static ResourceLocation baseResource = new ResourceLocation("mekanism:block/ctm_block"); + + public String[] ctmTypes = new String[] {"dynamic_tank"}; + + @SubscribeEvent + public void onTextureStitch(TextureStitchEvent.Pre event) { + for (TextureSpriteCallback callback : textures) { + callback.stitch(event.map); + } + } + + @SubscribeEvent + public void onModelBake(ModelBakeEvent event) throws IOException { + IModel model = event.modelLoader.getModel(baseResource); + baseModel = model.bake(new TRSRTransformation(ModelRotation.X0_Y0), Attributes.DEFAULT_BAKED_FORMAT, r -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(r.toString())); + + for (String ctm : ctmTypes) { + ModelChisel chiselModel = new ModelChisel(ctm); + chiselModel.load(); + event.modelRegistry.putObject(new ModelResourceLocation("mekanism:" + ctm), new ModelChiselBlock(chiselModel)); + } + } + + public static void register(TextureSpriteCallback callback) { + textures.add(callback); + } + + public static ChiselTextureCTM createTexture(String name) + { + TextureSpriteCallback[] callbacks = new TextureSpriteCallback[CTM.REQUIRED_TEXTURES]; + + callbacks[0] = new TextureSpriteCallback(new ResourceLocation("mekanism:textures/blocks/ctm/" + name)); + callbacks[1] = new TextureSpriteCallback(new ResourceLocation("mekanism:textures/blocks/ctm/" + name + "-ctm")); + + register(callbacks[0]); + register(callbacks[1]); + + return new ChiselTextureCTM(EnumWorldBlockLayer.SOLID, callbacks); + } + + public static ChiselFace createFace(String name) + { + ChiselFace face = new ChiselFace(); + + face.addTexture(createTexture(name)); + face.setLayer(EnumWorldBlockLayer.SOLID); + + return face; + } +} diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java index 55f8b6d77..bc4a3210b 100644 --- a/src/main/java/mekanism/common/block/BlockBasic.java +++ b/src/main/java/mekanism/common/block/BlockBasic.java @@ -5,6 +5,8 @@ import java.util.Random; import mekanism.api.energy.IEnergizedItem; import mekanism.api.energy.IStrictEnergyStorage; +import mekanism.client.render.ctm.CTMBlockRenderContext; +import mekanism.client.render.ctm.ICTMBlock; import mekanism.client.render.ctm.PropertyCTMRenderContext; import mekanism.common.Mekanism; import mekanism.common.Tier.BaseTier; @@ -14,6 +16,7 @@ import mekanism.common.base.ITierItem; import mekanism.common.block.states.BlockStateBasic; import mekanism.common.block.states.BlockStateBasic.BasicBlock; import mekanism.common.block.states.BlockStateBasic.BasicBlockType; +import mekanism.common.block.states.BlockStateFacing; import mekanism.common.content.boiler.SynchronizedBoilerData; import mekanism.common.content.tank.TankUpdateProtocol; import mekanism.common.inventory.InventoryBin; @@ -53,6 +56,7 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.FMLCommonHandler; @@ -91,7 +95,7 @@ import buildcraft.api.tools.IToolWrench; * @author AidanBrady * */ -public abstract class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockIcon +public abstract class BlockBasic extends Block implements ICTMBlock//TODO? implements ICustomBlockIcon { public static final PropertyCTMRenderContext ctmProperty = new PropertyCTMRenderContext(); @@ -145,16 +149,34 @@ public abstract class BlockBasic extends Block//TODO? implements IBlockCTM, ICus public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { TileEntity tile = worldIn.getTileEntity(pos); + if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).facing != null) { - state = state.withProperty(BlockStateBasic.facingProperty, ((TileEntityBasicBlock)tile).facing); + state = state.withProperty(BlockStateFacing.facingProperty, ((TileEntityBasicBlock)tile).facing); } + if(tile instanceof IActiveState) { state = state.withProperty(BlockStateBasic.activeProperty, ((IActiveState)tile).getActive()); } + return state; } + + @SideOnly(Side.CLIENT) + @Override + public IBlockState getExtendedState(IBlockState stateIn, IBlockAccess w, BlockPos pos) + { + if(stateIn.getBlock() == null || stateIn.getBlock().getMaterial() == Material.air) + { + return stateIn; + } + + IExtendedBlockState state = (IExtendedBlockState) stateIn; + CTMBlockRenderContext ctx = new CTMBlockRenderContext(w, pos); + + return state.withProperty(ctmProperty, ctx); + } /* @Override diff --git a/src/main/java/mekanism/common/block/states/BlockStateBasic.java b/src/main/java/mekanism/common/block/states/BlockStateBasic.java index 63f91f4ea..cecb506fb 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateBasic.java +++ b/src/main/java/mekanism/common/block/states/BlockStateBasic.java @@ -21,6 +21,7 @@ import mekanism.common.tile.TileEntityThermalEvaporationController; import mekanism.common.tile.TileEntityThermalEvaporationValve; import mekanism.common.util.LangUtils; import net.minecraft.block.Block; +import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.IBlockState; @@ -32,17 +33,19 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing.Plane; import net.minecraft.util.IStringSerializable; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.property.ExtendedBlockState; +import net.minecraftforge.common.property.IUnlistedProperty; import com.google.common.base.Predicate; import com.google.common.base.Predicates; -public class BlockStateBasic extends BlockStateFacing +public class BlockStateBasic extends ExtendedBlockState { public static final PropertyBool activeProperty = PropertyBool.create("active"); public BlockStateBasic(BlockBasic block, PropertyEnum typeProperty) { - super(block, typeProperty, activeProperty); + super(block, new IProperty[] {BlockStateFacing.facingProperty, typeProperty, activeProperty}, new IUnlistedProperty[] {BlockBasic.ctmProperty}); } public static enum BasicBlock @@ -58,6 +61,7 @@ public class BlockStateBasic extends BlockStateFacing { predicatedProperty = PropertyEnum.create("type", BasicBlockType.class, new BasicBlockPredicate(this)); } + return predicatedProperty; } @@ -77,33 +81,32 @@ public class BlockStateBasic extends BlockStateFacing public static enum BasicBlockType implements IStringSerializable { - OSMIUM_BLOCK(BasicBlock.BASIC_BLOCK_1, 0, "OsmiumBlock", null, false, Predicates.alwaysFalse(), false), - BRONZE_BLOCK(BasicBlock.BASIC_BLOCK_1, 1, "BronzeBlock", null, false, Predicates.alwaysFalse(), false), - REFINED_OBSIDIAN(BasicBlock.BASIC_BLOCK_1, 2, "RefinedObsidian", null, false, Predicates.alwaysFalse(), false), - COAL_BLOCK(BasicBlock.BASIC_BLOCK_1, 3, "CharcoalBlock", null, false, Predicates.alwaysFalse(), false), - REFINED_GLOWSTONE(BasicBlock.BASIC_BLOCK_1, 4, "RefinedGlowstone", null, false, Predicates.alwaysFalse(), false), - STEEL_BLOCK(BasicBlock.BASIC_BLOCK_1, 5, "SteelBlock", null, false, Predicates.alwaysFalse(), false), - BIN(BasicBlock.BASIC_BLOCK_1, 6, "Bin", TileEntityBin.class, false, Plane.HORIZONTAL, true), - TELEPORTER_FRAME(BasicBlock.BASIC_BLOCK_1, 7, "TeleporterFrame", null, false, Predicates.alwaysFalse(), false), - STEEL_CASING(BasicBlock.BASIC_BLOCK_1, 8, "SteelCasing", null, false, Predicates.alwaysFalse(), false), - DYNAMIC_TANK(BasicBlock.BASIC_BLOCK_1, 9, "DynamicTank", TileEntityDynamicTank.class, false, Predicates.alwaysFalse(), false), - STRUCTURAL_GLASS(BasicBlock.BASIC_BLOCK_1, 10, "StructuralGlass", TileEntityStructuralGlass.class, false, Predicates.alwaysFalse(), false), - DYNAMIC_VALVE(BasicBlock.BASIC_BLOCK_1, 11, "DynamicValve", TileEntityDynamicValve.class, false, Predicates.alwaysFalse(), false), - COPPER_BLOCK(BasicBlock.BASIC_BLOCK_1, 12, "CopperBlock", null, false, Predicates.alwaysFalse(), false), - TIN_BLOCK(BasicBlock.BASIC_BLOCK_1, 13, "TinBlock", null, false, Predicates.alwaysFalse(), false), - THERMAL_EVAPORATION_CONTROLLER(BasicBlock.BASIC_BLOCK_1, 14, "ThermalEvaporationController", TileEntityThermalEvaporationController.class, false, Plane.HORIZONTAL, true), - THERMAL_EVAPORATION_VALVE(BasicBlock.BASIC_BLOCK_1, 15, "ThermalEvaporationValve", TileEntityThermalEvaporationValve.class, false, Predicates.alwaysFalse(), false), - THERMAL_EVAPORATION_BLOCK(BasicBlock.BASIC_BLOCK_2, 0, "ThermalEvaporationBlock", TileEntityThermalEvaporationBlock.class, false, Predicates.alwaysFalse(), false), - INDUCTION_CASING(BasicBlock.BASIC_BLOCK_2, 1, "InductionCasing", TileEntityInductionCasing.class, false, Predicates.alwaysFalse(), false), - INDUCTION_PORT(BasicBlock.BASIC_BLOCK_2, 2, "InductionPort", TileEntityInductionPort.class, false, Predicates.alwaysFalse(), false), - INDUCTION_CELL(BasicBlock.BASIC_BLOCK_2, 3, "InductionCell", TileEntityInductionCell.class, false, Predicates.alwaysFalse(), false), - INDUCTION_PROVIDER(BasicBlock.BASIC_BLOCK_2, 4, "InductionProvider", TileEntityInductionProvider.class, false, Predicates.alwaysFalse(), false), - SUPERHEATING_ELEMENT(BasicBlock.BASIC_BLOCK_2, 5, "SuperheatingElement", TileEntitySuperheatingElement.class, true, Predicates.alwaysFalse(), false), - PRESSURE_DISPERSER(BasicBlock.BASIC_BLOCK_2, 6, "PressureDisperser",TileEntityPressureDisperser.class, true, Predicates.alwaysFalse(), false), - BOILER_CASING(BasicBlock.BASIC_BLOCK_2, 7, "BoilerCasing", TileEntityBoilerCasing.class, true, Predicates.alwaysFalse(), false), - BOILER_VALVE(BasicBlock.BASIC_BLOCK_2, 8, "BoilerValve", TileEntityBoilerValve.class, true, Predicates.alwaysFalse(), false), - SECURITY_DESK(BasicBlock.BASIC_BLOCK_2, 9, "SecurityDesk", TileEntitySecurityDesk.class, true, Plane.HORIZONTAL, false); - + OSMIUM_BLOCK(BasicBlock.BASIC_BLOCK_1, 0, "OsmiumBlock", null, false, Predicates.alwaysFalse(), false, false), + BRONZE_BLOCK(BasicBlock.BASIC_BLOCK_1, 1, "BronzeBlock", null, false, Predicates.alwaysFalse(), false, false), + REFINED_OBSIDIAN(BasicBlock.BASIC_BLOCK_1, 2, "RefinedObsidian", null, false, Predicates.alwaysFalse(), false, false), + COAL_BLOCK(BasicBlock.BASIC_BLOCK_1, 3, "CharcoalBlock", null, false, Predicates.alwaysFalse(), false, false), + REFINED_GLOWSTONE(BasicBlock.BASIC_BLOCK_1, 4, "RefinedGlowstone", null, false, Predicates.alwaysFalse(), false, false), + STEEL_BLOCK(BasicBlock.BASIC_BLOCK_1, 5, "SteelBlock", null, false, Predicates.alwaysFalse(), false, false), + BIN(BasicBlock.BASIC_BLOCK_1, 6, "Bin", TileEntityBin.class, false, Plane.HORIZONTAL, true, false), + TELEPORTER_FRAME(BasicBlock.BASIC_BLOCK_1, 7, "TeleporterFrame", null, false, Predicates.alwaysFalse(), false, true), + STEEL_CASING(BasicBlock.BASIC_BLOCK_1, 8, "SteelCasing", null, false, Predicates.alwaysFalse(), false, false), + DYNAMIC_TANK(BasicBlock.BASIC_BLOCK_1, 9, "DynamicTank", TileEntityDynamicTank.class, false, Predicates.alwaysFalse(), false, true), + STRUCTURAL_GLASS(BasicBlock.BASIC_BLOCK_1, 10, "StructuralGlass", TileEntityStructuralGlass.class, false, Predicates.alwaysFalse(), false, true), + DYNAMIC_VALVE(BasicBlock.BASIC_BLOCK_1, 11, "DynamicValve", TileEntityDynamicValve.class, false, Predicates.alwaysFalse(), false, true), + COPPER_BLOCK(BasicBlock.BASIC_BLOCK_1, 12, "CopperBlock", null, false, Predicates.alwaysFalse(), false, false), + TIN_BLOCK(BasicBlock.BASIC_BLOCK_1, 13, "TinBlock", null, false, Predicates.alwaysFalse(), false, false), + THERMAL_EVAPORATION_CONTROLLER(BasicBlock.BASIC_BLOCK_1, 14, "ThermalEvaporationController", TileEntityThermalEvaporationController.class, false, Plane.HORIZONTAL, true, true), + THERMAL_EVAPORATION_VALVE(BasicBlock.BASIC_BLOCK_1, 15, "ThermalEvaporationValve", TileEntityThermalEvaporationValve.class, false, Predicates.alwaysFalse(), false, true), + THERMAL_EVAPORATION_BLOCK(BasicBlock.BASIC_BLOCK_2, 0, "ThermalEvaporationBlock", TileEntityThermalEvaporationBlock.class, false, Predicates.alwaysFalse(), false, true), + INDUCTION_CASING(BasicBlock.BASIC_BLOCK_2, 1, "InductionCasing", TileEntityInductionCasing.class, false, Predicates.alwaysFalse(), false, true), + INDUCTION_PORT(BasicBlock.BASIC_BLOCK_2, 2, "InductionPort", TileEntityInductionPort.class, false, Predicates.alwaysFalse(), false, true), + INDUCTION_CELL(BasicBlock.BASIC_BLOCK_2, 3, "InductionCell", TileEntityInductionCell.class, false, Predicates.alwaysFalse(), false, true), + INDUCTION_PROVIDER(BasicBlock.BASIC_BLOCK_2, 4, "InductionProvider", TileEntityInductionProvider.class, false, Predicates.alwaysFalse(), false, true), + SUPERHEATING_ELEMENT(BasicBlock.BASIC_BLOCK_2, 5, "SuperheatingElement", TileEntitySuperheatingElement.class, true, Predicates.alwaysFalse(), false, true), + PRESSURE_DISPERSER(BasicBlock.BASIC_BLOCK_2, 6, "PressureDisperser",TileEntityPressureDisperser.class, true, Predicates.alwaysFalse(), false, false), + BOILER_CASING(BasicBlock.BASIC_BLOCK_2, 7, "BoilerCasing", TileEntityBoilerCasing.class, true, Predicates.alwaysFalse(), false, true), + BOILER_VALVE(BasicBlock.BASIC_BLOCK_2, 8, "BoilerValve", TileEntityBoilerValve.class, true, Predicates.alwaysFalse(), false, true), + SECURITY_DESK(BasicBlock.BASIC_BLOCK_2, 9, "SecurityDesk", TileEntitySecurityDesk.class, true, Plane.HORIZONTAL, false, false); public BasicBlock blockType; public int meta; @@ -113,8 +116,9 @@ public class BlockStateBasic extends BlockStateFacing public boolean hasDescription; public Predicate facingPredicate; public boolean activable; + public boolean ctm; - private BasicBlockType(BasicBlock block, int metadata, String s, Class tileClass, boolean hasDesc, Predicate facingAllowed, boolean activeState) + private BasicBlockType(BasicBlock block, int metadata, String s, Class tileClass, boolean hasDesc, Predicate facingAllowed, boolean activeState, boolean ctmTex) { blockType = block; meta = metadata; @@ -123,6 +127,7 @@ public class BlockStateBasic extends BlockStateFacing hasDescription = hasDesc; facingPredicate = facingAllowed; activable = activeState; + ctm = ctmTex; } public static BasicBlockType get(IBlockState state) @@ -229,27 +234,30 @@ public class BlockStateBasic extends BlockStateFacing BlockBasic block = (BlockBasic)state.getBlock(); BasicBlockType type = state.getValue(block.getProperty()); StringBuilder builder = new StringBuilder(); + if(type.hasActiveTexture()) { builder.append(activeProperty.getName()); builder.append("="); builder.append(state.getValue(activeProperty)); } + if(type.hasRotations()) { - EnumFacing facing = state.getValue(facingProperty); + EnumFacing facing = state.getValue(BlockStateFacing.facingProperty); + if(type.canRotateTo(facing)) { if(builder.length() > 0) { builder.append(","); } - builder.append(facingProperty.getName()); + + builder.append(BlockStateFacing.facingProperty.getName()); builder.append("="); builder.append(facing.getName()); } - else - { + else { return new ModelResourceLocation("builtin/missing", "missing"); } } @@ -263,5 +271,4 @@ public class BlockStateBasic extends BlockStateFacing return new ModelResourceLocation(baseLocation, builder.toString()); } } - } diff --git a/src/main/resources/assets/mekanism/models/block/ctm_block.json b/src/main/resources/assets/mekanism/models/block/ctm_block.json new file mode 100644 index 000000000..fb77712c9 --- /dev/null +++ b/src/main/resources/assets/mekanism/models/block/ctm_block.json @@ -0,0 +1,25 @@ +{ + "elements": [ + { "from": [ 0, 0, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "texture": "#down", "cullface": "down" }, + "up": { "texture": "#up", "cullface": "up", "rotation": 180 }, + "north": { "texture": "#north", "cullface": "north" }, + "south": { "texture": "#south", "cullface": "south" }, + "west": { "texture": "#west", "cullface": "west" }, + "east": { "texture": "#east", "cullface": "east" } + } + } + ], + "textures": { + "particle": "#sides", + "down": "#sides", + "up": "#sides", + "north": "#front", + "east": "#sides", + "south": "#sides", + "west": "#sides" + } +} + diff --git a/src/main/resources/assets/mekanism/textures/blocks/ctm/DynamicTank-ctm.png b/src/main/resources/assets/mekanism/textures/blocks/ctm/dynamic_tank-ctm.png similarity index 100% rename from src/main/resources/assets/mekanism/textures/blocks/ctm/DynamicTank-ctm.png rename to src/main/resources/assets/mekanism/textures/blocks/ctm/dynamic_tank-ctm.png diff --git a/src/main/resources/assets/mekanism/textures/blocks/ctm/DynamicTank.png b/src/main/resources/assets/mekanism/textures/blocks/ctm/dynamic_tank.png similarity index 100% rename from src/main/resources/assets/mekanism/textures/blocks/ctm/DynamicTank.png rename to src/main/resources/assets/mekanism/textures/blocks/ctm/dynamic_tank.png