diff --git a/src/main/java/mekanism/client/render/ctm/ModelChiselBlock.java b/src/main/java/mekanism/client/render/ctm/ModelChiselBlock.java index 2217ab61b..8ee65da96 100644 --- a/src/main/java/mekanism/client/render/ctm/ModelChiselBlock.java +++ b/src/main/java/mekanism/client/render/ctm/ModelChiselBlock.java @@ -7,7 +7,7 @@ import javax.annotation.Nullable; import javax.vecmath.Matrix4f; import javax.vecmath.Vector3f; -import mekanism.common.block.BlockBasic; +import mekanism.common.block.states.BlockStateBasic; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; @@ -109,7 +109,7 @@ public class ModelChiselBlock implements ISmartBlockModel, ISmartItemModel, IPer if(stateIn.getBlock() instanceof ICTMBlock && stateIn instanceof IExtendedBlockState) { IExtendedBlockState state = (IExtendedBlockState) stateIn; - CTMBlockRenderContext ctxList = state.getValue(BlockBasic.ctmProperty); + CTMBlockRenderContext ctxList = state.getValue(BlockStateBasic.ctmProperty); return createModel(stateIn, model, ctxList); } else { diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java index 3802fd4ba..bc1838d31 100644 --- a/src/main/java/mekanism/common/block/BlockBasic.java +++ b/src/main/java/mekanism/common/block/BlockBasic.java @@ -9,7 +9,6 @@ import mekanism.api.energy.IStrictEnergyStorage; import mekanism.client.render.ctm.CTMBlockRenderContext; import mekanism.client.render.ctm.CTMData; import mekanism.client.render.ctm.ICTMBlock; -import mekanism.client.render.ctm.PropertyCTMRenderContext; import mekanism.common.Mekanism; import mekanism.common.Tier.BaseTier; import mekanism.common.base.IActiveState; @@ -101,8 +100,6 @@ import buildcraft.api.tools.IToolWrench; */ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? implements ICustomBlockIcon { - public static final PropertyCTMRenderContext ctmProperty = new PropertyCTMRenderContext(); - public CTMData[][] ctmData = new CTMData[16][4]; public BlockBasic() @@ -212,30 +209,9 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple IExtendedBlockState state = (IExtendedBlockState)stateIn; CTMBlockRenderContext ctx = new CTMBlockRenderContext(w, pos); - return state.withProperty(ctmProperty, ctx); + return state.withProperty(BlockStateBasic.ctmProperty, ctx); } -/* - @Override - public IIcon getIcon(ItemStack stack, int side) - { - if(BasicType.get(stack) == BasicType.BIN) - { - return binIcons[((ItemBlockBasic)stack.getItem()).getBaseTier(stack).ordinal()][side]; - } - else if(BasicType.get(stack) == BasicType.INDUCTION_CELL) - { - return icons[3][((ItemBlockBasic)stack.getItem()).getBaseTier(stack).ordinal()]; - } - else if(BasicType.get(stack) == BasicType.INDUCTION_PROVIDER) - { - return icons[4][((ItemBlockBasic)stack.getItem()).getBaseTier(stack).ordinal()]; - } - - return getIcon(side, stack.getItemDamage()); - } -*/ - @Override public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock) { @@ -1023,9 +999,11 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple { if(side == state.getValue(BlockStateFacing.facingProperty)) { - System.out.println("Yeet"); return type.getName() + (state.getValue(BlockStateBasic.activeProperty) ? "_on" : ""); } + else { + return "thermal_evaporation_block"; + } } if(type == BasicBlockType.INDUCTION_PORT) diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 17444a790..de6ccd1c5 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -9,6 +9,7 @@ import mekanism.api.MekanismConfig.client; import mekanism.api.MekanismConfig.general; import mekanism.api.energy.IEnergizedItem; import mekanism.api.energy.IStrictEnergyStorage; +import mekanism.client.render.ctm.CTMBlockRenderContext; import mekanism.client.render.ctm.CTMData; import mekanism.client.render.ctm.ICTMBlock; import mekanism.common.Mekanism; @@ -26,6 +27,7 @@ import mekanism.common.base.ISustainedInventory; import mekanism.common.base.ISustainedTank; import mekanism.common.base.ITierItem; import mekanism.common.base.IUpgradeTile; +import mekanism.common.block.states.BlockStateBasic; import mekanism.common.block.states.BlockStateBasic.BasicBlockType; import mekanism.common.block.states.BlockStateFacing; import mekanism.common.block.states.BlockStateMachine; @@ -74,6 +76,7 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; @@ -154,6 +157,21 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou } public abstract MachineBlock getMachineBlock(); + + @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(BlockStateBasic.ctmProperty, ctx); + } public BlockState createBlockState() { @@ -220,88 +238,6 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou } } -/* - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - BASE_ICON = register.registerIcon("mekanism:SteelCasing"); - DefIcon def = DefIcon.getAll(BASE_ICON).setOverrides(false); - - switch(blockType) - { - case MACHINE_BLOCK_1: - ctms[11][0] = new CTMData("ctm/Teleporter", this, Arrays.asList(11)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock, Arrays.asList(7)).registerIcons(register); - - MekanismRenderer.loadDynamicTextures(register, "enrichment_chamber/" + MachineType.ENRICHMENT_CHAMBER.name, icons[0], def); - MekanismRenderer.loadDynamicTextures(register, "osmium_compressor/" + MachineType.OSMIUM_COMPRESSOR.name, icons[1], def); - MekanismRenderer.loadDynamicTextures(register, "combiner/" + MachineType.COMBINER.name, icons[2], def); - MekanismRenderer.loadDynamicTextures(register, "crusher/" + MachineType.CRUSHER.name, icons[3], def); - - for(RecipeType type : RecipeType.values()) - { - MekanismRenderer.loadDynamicTextures(register, "factory/basic/" + type.getUnlocalizedName().toLowerCase() + "/" + BaseTier.BASIC.getName() + type.getUnlocalizedName() + MachineType.BASIC_FACTORY.name, factoryIcons[0][type.ordinal()], - DefIcon.getActivePair(register.registerIcon("mekanism:factory/basic/BasicFactoryFront"), 2).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/basic/BasicFactoryTop"), 1).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/basic/BasicFactoryBottom"), 0).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/basic/BasicFactorySide"), 3, 4, 5).setOverrides(false)); - MekanismRenderer.loadDynamicTextures(register, "factory/advanced/" + type.getUnlocalizedName().toLowerCase() + "/" + BaseTier.ADVANCED.getName() + type.getUnlocalizedName() + MachineType.ADVANCED_FACTORY.name, factoryIcons[1][type.ordinal()], - DefIcon.getActivePair(register.registerIcon("mekanism:factory/advanced/AdvancedFactoryFront"), 2).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/advanced/AdvancedFactoryTop"), 1).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/advanced/AdvancedFactoryBottom"), 0).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/advanced/AdvancedFactorySide"), 3, 4, 5).setOverrides(false)); - MekanismRenderer.loadDynamicTextures(register, "factory/elite/" + type.getUnlocalizedName().toLowerCase() + "/" + BaseTier.ELITE.getName() + type.getUnlocalizedName() + MachineType.ELITE_FACTORY.name, factoryIcons[2][type.ordinal()], - DefIcon.getActivePair(register.registerIcon("mekanism:factory/elite/EliteFactoryFront"), 2).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/elite/EliteFactoryTop"), 1).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/elite/EliteFactoryBottom"), 0).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/elite/EliteFactorySide"), 3, 4, 5).setOverrides(false)); - } - - MekanismRenderer.loadDynamicTextures(register, "purification_chamber/" + MachineType.PURIFICATION_CHAMBER.name, icons[9], def); - MekanismRenderer.loadDynamicTextures(register, "energized_smelter/" + MachineType.ENERGIZED_SMELTER.name, icons[10], def); - icons[11][0] = ctms[11][0].mainTextureData.icon; - - break; - case MACHINE_BLOCK_2: - MekanismRenderer.loadDynamicTextures(register, "chemical_injection_chamber/" + MachineType.CHEMICAL_INJECTION_CHAMBER.name, icons[3], def); - MekanismRenderer.loadDynamicTextures(register, "precision_sawmill/" + MachineType.PRECISION_SAWMILL.name, icons[5], def); - - break; - case MACHINE_BLOCK_3: - icons[0][0] = BASE_ICON; - icons[2][0] = BASE_ICON; - MekanismRenderer.loadDynamicTextures(register, "oredictionificator/" + MachineType.OREDICTIONIFICATOR.name, icons[3]); - icons[4][0] = BASE_ICON; - MekanismRenderer.loadDynamicTextures(register, "formulaic_assemblicator/" + MachineType.FORMULAIC_ASSEMBLICATOR.name, icons[5]); - MekanismRenderer.loadDynamicTextures(register, "fuelwood_heater/" + MachineType.FUELWOOD_HEATER.name, icons[6]); - - break; - } - } - - @Override - public IIcon getIcon(ItemStack stack, int side) - { - MachineType type = MachineType.get(stack); - ItemBlockMachine item = (ItemBlockMachine)stack.getItem(); - - if(type == MachineType.BASIC_FACTORY) - { - return factoryIcons[0][item.getRecipeType(stack)][side]; - } - else if(type == MachineType.ADVANCED_FACTORY) - { - return factoryIcons[1][item.getRecipeType(stack)][side]; - } - else if(type == MachineType.ELITE_FACTORY) - { - return factoryIcons[2][item.getRecipeType(stack)][side]; - } - - return getIcon(side, stack.getItemDamage()); - } -*/ - @Override public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { @@ -448,107 +384,6 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou return 0; } -/* - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - switch(blockType) - { - case MACHINE_BLOCK_1: - switch(meta) - { - case 0: - case 1: - case 2: - case 3: - case 9: - case 10: - return icons[meta][side]; - default: - return icons[meta][0] != null ? icons[meta][0] : BASE_ICON; - } - case MACHINE_BLOCK_2: - switch(meta) - { - case 3: - case 5: - return icons[meta][side]; - default: - return icons[meta][0] != null ? icons[meta][0] : BASE_ICON; - } - case MACHINE_BLOCK_3: - switch(meta) - { - case 3: - case 5: - case 6: - return icons[meta][side]; - default: - return icons[meta][0] != null ? icons[meta][0] : BASE_ICON; - } - default: - return BASE_ICON; - } - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess world, BlockPos pos, int side) - { - int meta = world.getBlockMetadata(pos); - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); - - switch(blockType) - { - case MACHINE_BLOCK_1: - switch(meta) - { - case 0: - case 1: - case 2: - case 3: - case 9: - case 10: - boolean active = MekanismUtils.isActive(world, pos); - return icons[meta][MekanismUtils.getBaseOrientation(side, tileEntity.facing)+(active ? 6 : 0)]; - case 5: - case 6: - case 7: - TileEntityFactory factory = (TileEntityFactory)tileEntity; - active = MekanismUtils.isActive(world, pos); - - return factoryIcons[factory.tier.ordinal()][factory.recipeType.ordinal()][MekanismUtils.getBaseOrientation(side, tileEntity.facing)+(active ? 6 : 0)]; - default: - return icons[meta][0]; - } - case MACHINE_BLOCK_2: - switch(meta) - { - case 3: - case 5: - boolean active = MekanismUtils.isActive(world, pos); - return icons[meta][MekanismUtils.getBaseOrientation(side, tileEntity.facing)+(active ? 6 : 0)]; - default: - return icons[meta][0]; - } - case MACHINE_BLOCK_3: - switch(meta) - { - case 3: - case 5: - case 6: - boolean active = MekanismUtils.isActive(world, pos); - return icons[meta][MekanismUtils.getBaseOrientation(side, tileEntity.facing)+(active ? 6 : 0)]; - default: - return icons[meta][0]; - } - } - - return null; - } -*/ - @Override public int damageDropped(IBlockState state) { @@ -1274,22 +1109,4 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou return 0; } -/* - @Override - public CTMData getCTMData(IBlockAccess world, BlockPos pos, int meta) - { - if(ctms[meta][1] != null && MekanismUtils.isActive(world, pos)) - { - return ctms[meta][1]; - } - - return ctms[meta][0]; - } - - @Override - public boolean shouldRenderBlock(IBlockAccess world, BlockPos pos, int meta) - { - return !MachineType.get(this, meta).hasModel; - }*/ - } diff --git a/src/main/java/mekanism/common/block/states/BlockStateBasic.java b/src/main/java/mekanism/common/block/states/BlockStateBasic.java index 2a61f562c..c0ad482c2 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateBasic.java +++ b/src/main/java/mekanism/common/block/states/BlockStateBasic.java @@ -1,5 +1,6 @@ package mekanism.common.block.states; +import mekanism.client.render.ctm.PropertyCTMRenderContext; import mekanism.common.Mekanism; import mekanism.common.MekanismBlocks; import mekanism.common.Tier.BaseTier; @@ -44,10 +45,11 @@ public class BlockStateBasic extends ExtendedBlockState { public static final PropertyBool activeProperty = PropertyBool.create("active"); public static final PropertyEnum tierProperty = PropertyEnum.create("tier", BaseTier.class); + public static final PropertyCTMRenderContext ctmProperty = new PropertyCTMRenderContext(); public BlockStateBasic(BlockBasic block, PropertyEnum typeProperty) { - super(block, new IProperty[] {BlockStateFacing.facingProperty, typeProperty, activeProperty, tierProperty}, new IUnlistedProperty[] {BlockBasic.ctmProperty}); + super(block, new IProperty[] {BlockStateFacing.facingProperty, typeProperty, activeProperty, tierProperty}, new IUnlistedProperty[] {BlockStateBasic.ctmProperty}); } public static enum BasicBlock @@ -97,7 +99,7 @@ public class BlockStateBasic extends ExtendedBlockState DYNAMIC_VALVE(BasicBlock.BASIC_BLOCK_1, 11, "DynamicValve", TileEntityDynamicValve.class, false, Predicates.alwaysFalse(), false, false), 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, false), + THERMAL_EVAPORATION_CONTROLLER(BasicBlock.BASIC_BLOCK_1, 14, "ThermalEvaporationController", TileEntityThermalEvaporationController.class, false, Predicates.alwaysFalse(), false, false), THERMAL_EVAPORATION_VALVE(BasicBlock.BASIC_BLOCK_1, 15, "ThermalEvaporationValve", TileEntityThermalEvaporationValve.class, false, Predicates.alwaysFalse(), false, false), THERMAL_EVAPORATION_BLOCK(BasicBlock.BASIC_BLOCK_2, 0, "ThermalEvaporationBlock", TileEntityThermalEvaporationBlock.class, false, Predicates.alwaysFalse(), false, false), INDUCTION_CASING(BasicBlock.BASIC_BLOCK_2, 1, "InductionCasing", TileEntityInductionCasing.class, false, Predicates.alwaysFalse(), false, false), diff --git a/src/main/java/mekanism/common/block/states/BlockStateMachine.java b/src/main/java/mekanism/common/block/states/BlockStateMachine.java index 825caa203..4a4a430ab 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateMachine.java +++ b/src/main/java/mekanism/common/block/states/BlockStateMachine.java @@ -55,6 +55,7 @@ import mekanism.common.tile.TileEntitySolarNeutronActivator; import mekanism.common.tile.TileEntityTeleporter; 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; @@ -66,11 +67,13 @@ 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 BlockStateMachine extends BlockStateFacing +public class BlockStateMachine extends ExtendedBlockState { public static final PropertyBool activeProperty = PropertyBool.create("active"); public static final PropertyEnum tierProperty = PropertyEnum.create("tier", BaseTier.class); @@ -78,7 +81,7 @@ public class BlockStateMachine extends BlockStateFacing public BlockStateMachine(BlockMachine block, PropertyEnum typeProperty) { - super(block, typeProperty, activeProperty, tierProperty, recipeProperty); + super(block, new IProperty[] {BlockStateFacing.facingProperty, typeProperty, activeProperty, tierProperty, recipeProperty}, new IUnlistedProperty[] {BlockStateBasic.ctmProperty}); } public static enum MachineBlock @@ -423,7 +426,7 @@ public class BlockStateMachine extends BlockStateFacing if(type.hasRotations()) { - EnumFacing facing = state.getValue(facingProperty); + EnumFacing facing = state.getValue(BlockStateFacing.facingProperty); if(type.canRotateTo(facing)) { @@ -432,7 +435,7 @@ public class BlockStateMachine extends BlockStateFacing builder.append(","); } - builder.append(facingProperty.getName()); + builder.append(BlockStateFacing.facingProperty.getName()); builder.append("="); builder.append(facing.getName()); } diff --git a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java index cbda51daf..fd4200816 100644 --- a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java +++ b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java @@ -71,6 +71,7 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva public boolean updatedThisTick = false; public int clientSolarAmount; + public boolean clientStructured; public boolean cacheStructure = false; @@ -187,14 +188,13 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva { if(!updatedThisTick) { - boolean prev = structured; - clearStructure(); structured = buildStructure(); - if(structured != prev) + if(structured != clientStructured) { Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); + clientStructured = structured; } if(structured) @@ -583,8 +583,6 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva outputTank.setFluid(null); } - boolean prev = structured; - structured = dataStream.readBoolean(); controllerConflict = dataStream.readBoolean(); clientSolarAmount = dataStream.readInt(); @@ -595,10 +593,10 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva lastGain = dataStream.readFloat(); totalLoss = dataStream.readFloat(); - if(structured != prev) + if(structured != clientStructured) { inputTank.setCapacity(getMaxFluid()); - worldObj.markBlockRangeForRenderUpdate(getPos(), getPos().add(1,1,1)); + MekanismUtils.updateBlock(worldObj, getPos()); if(structured) { @@ -610,9 +608,9 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva } }); } + + clientStructured = structured; } - - MekanismUtils.updateBlock(worldObj, getPos()); } @Override diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java index 08e9ff4d1..8023e1961 100644 --- a/src/main/java/mekanism/common/util/MekanismUtils.java +++ b/src/main/java/mekanism/common/util/MekanismUtils.java @@ -838,7 +838,7 @@ public final class MekanismUtils { if(!(world.getTileEntity(pos) instanceof IActiveState) || ((IActiveState)world.getTileEntity(pos)).renderUpdate()) { - world.markBlockRangeForRenderUpdate(pos, pos); + world.markBlockRangeForRenderUpdate(pos, pos.add(1, 1, 1)); } if(!(world.getTileEntity(pos) instanceof IActiveState) || ((IActiveState)world.getTileEntity(pos)).lightUpdate() && client.machineEffects) diff --git a/src/main/resources/assets/mekanism/blockstates/thermal_evaporation_controller.json b/src/main/resources/assets/mekanism/blockstates/thermal_evaporation_controller.json index dcf74a220..5e49fc919 100644 --- a/src/main/resources/assets/mekanism/blockstates/thermal_evaporation_controller.json +++ b/src/main/resources/assets/mekanism/blockstates/thermal_evaporation_controller.json @@ -8,12 +8,7 @@ } }, "variants": { - "facing": { - "north": {}, - "south": {"y": 180}, - "east": {"y": 90}, - "west": {"y": -90} - }, + "normal": [{}], "inventory": [{}] } }