diff --git a/src/main/java/mekanism/api/EnumColor.java b/src/main/java/mekanism/api/EnumColor.java index df9ba7433..32164cbf1 100644 --- a/src/main/java/mekanism/api/EnumColor.java +++ b/src/main/java/mekanism/api/EnumColor.java @@ -1,5 +1,6 @@ package mekanism.api; +import net.minecraft.util.IStringSerializable; import net.minecraft.util.StatCollector; /** @@ -7,7 +8,7 @@ import net.minecraft.util.StatCollector; * @author AidanBrady * */ -public enum EnumColor +public enum EnumColor implements IStringSerializable { BLACK("\u00a70", "black", "Black", new int[] {0, 0, 0}, 0), DARK_BLUE("\u00a71", "darkBlue", "Blue", new int[] {0, 0, 170}, 4), @@ -75,7 +76,7 @@ public enum EnumColor * Gets the name of this color with it's color prefix code. * @return the color's name and color prefix */ - public String getName() + public String getColoredName() { return code + getLocalizedName(); } @@ -84,6 +85,12 @@ public enum EnumColor { return code + getDyeName(); } + + @Override + public String getName() + { + return unlocalizedName.toLowerCase(); + } /** * Gets the 0-1 of this color's RGB value by dividing by 255 (used for OpenGL coloring). diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index ae61e4ed3..7f8d26598 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -76,6 +76,7 @@ import mekanism.client.render.entity.RenderFlame; import mekanism.client.render.entity.RenderObsidianTNTPrimed; import mekanism.client.render.entity.RenderRobit; import mekanism.client.render.item.CustomItemModelFactory; +import mekanism.client.render.obj.MekanismOBJLoader; import mekanism.client.render.tileentity.RenderBin; import mekanism.client.render.tileentity.RenderChargepad; import mekanism.client.render.tileentity.RenderChemicalCrystallizer; @@ -198,6 +199,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.client.model.obj.OBJLoader; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.FMLClientHandler; @@ -853,6 +855,8 @@ public class ClientProxy extends CommonProxy { MekanismRenderer.init(); + ModelLoaderRegistry.registerLoader(new MekanismOBJLoader()); + MinecraftForge.EVENT_BUS.register(new CTMRegistry()); MinecraftForge.EVENT_BUS.register(this); diff --git a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java index 708ef04cc..97d7f5246 100644 --- a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java +++ b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java @@ -478,7 +478,7 @@ public class GuiLogisticalSorter extends GuiMekanism } fontRendererObj.drawString(LangUtils.localize("gui.itemFilter"), 78, yStart + 2, 0x404040); - fontRendererObj.drawString(filter.color != null ? filter.color.getName() : LangUtils.localize("gui.none"), 78, yStart + 11, 0x404040); + fontRendererObj.drawString(filter.color != null ? filter.color.getColoredName() : LangUtils.localize("gui.none"), 78, yStart + 11, 0x404040); } else if(filter instanceof TOreDictFilter) { @@ -501,7 +501,7 @@ public class GuiLogisticalSorter extends GuiMekanism } fontRendererObj.drawString(LangUtils.localize("gui.oredictFilter"), 78, yStart + 2, 0x404040); - fontRendererObj.drawString(filter.color != null ? filter.color.getName() : LangUtils.localize("gui.none"), 78, yStart + 11, 0x404040); + fontRendererObj.drawString(filter.color != null ? filter.color.getColoredName() : LangUtils.localize("gui.none"), 78, yStart + 11, 0x404040); } else if(filter instanceof TMaterialFilter) { @@ -517,7 +517,7 @@ public class GuiLogisticalSorter extends GuiMekanism } fontRendererObj.drawString(LangUtils.localize("gui.materialFilter"), 78, yStart + 2, 0x404040); - fontRendererObj.drawString(filter.color != null ? filter.color.getName() : LangUtils.localize("gui.none"), 78, yStart + 11, 0x404040); + fontRendererObj.drawString(filter.color != null ? filter.color.getColoredName() : LangUtils.localize("gui.none"), 78, yStart + 11, 0x404040); } else if(filter instanceof TModIDFilter) { @@ -540,7 +540,7 @@ public class GuiLogisticalSorter extends GuiMekanism } fontRendererObj.drawString(LangUtils.localize("gui.modIDFilter"), 78, yStart + 2, 0x404040); - fontRendererObj.drawString(filter.color != null ? filter.color.getName() : LangUtils.localize("gui.none"), 78, yStart + 11, 0x404040); + fontRendererObj.drawString(filter.color != null ? filter.color.getColoredName() : LangUtils.localize("gui.none"), 78, yStart + 11, 0x404040); } // Draw hovertext for sorting buttons @@ -583,7 +583,7 @@ public class GuiLogisticalSorter extends GuiMekanism { if(tileEntity.color != null) { - drawCreativeTabHoveringText(tileEntity.color.getName(), xAxis, yAxis); + drawCreativeTabHoveringText(tileEntity.color.getColoredName(), xAxis, yAxis); } else { drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); diff --git a/src/main/java/mekanism/client/gui/GuiMekanism.java b/src/main/java/mekanism/client/gui/GuiMekanism.java index 70df23899..99141197d 100644 --- a/src/main/java/mekanism/client/gui/GuiMekanism.java +++ b/src/main/java/mekanism/client/gui/GuiMekanism.java @@ -111,7 +111,7 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper if(data != null) { - drawCreativeTabHoveringText(data.color + data.localize() + " (" + data.color.getName() + ")", xAxis, yAxis); + drawCreativeTabHoveringText(data.color + data.localize() + " (" + data.color.getColoredName() + ")", xAxis, yAxis); } } } diff --git a/src/main/java/mekanism/client/gui/GuiSideConfiguration.java b/src/main/java/mekanism/client/gui/GuiSideConfiguration.java index 24b88b280..7e8bbc6b6 100644 --- a/src/main/java/mekanism/client/gui/GuiSideConfiguration.java +++ b/src/main/java/mekanism/client/gui/GuiSideConfiguration.java @@ -189,7 +189,7 @@ public class GuiSideConfiguration extends GuiMekanism { if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) { - drawCreativeTabHoveringText(data.color + data.localize() + " (" + data.color.getName() + ")", xAxis, yAxis); + drawCreativeTabHoveringText(data.color + data.localize() + " (" + data.color.getColoredName() + ")", xAxis, yAxis); } } } diff --git a/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java b/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java index 7dd53e4c6..100513a19 100644 --- a/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java @@ -208,7 +208,7 @@ public class GuiTItemStackFilter extends GuiMekanism { if(filter.color != null) { - drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis); + drawCreativeTabHoveringText(filter.color.getColoredName(), xAxis, yAxis); } else { drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); diff --git a/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java b/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java index 2f6d92375..bf0ae1e41 100644 --- a/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java @@ -156,7 +156,7 @@ public class GuiTMaterialFilter extends GuiMekanism { if(filter.color != null) { - drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis); + drawCreativeTabHoveringText(filter.color.getColoredName(), xAxis, yAxis); } else { drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); diff --git a/src/main/java/mekanism/client/gui/GuiTModIDFilter.java b/src/main/java/mekanism/client/gui/GuiTModIDFilter.java index 436e94462..e3f059b3a 100644 --- a/src/main/java/mekanism/client/gui/GuiTModIDFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTModIDFilter.java @@ -194,7 +194,7 @@ public class GuiTModIDFilter extends GuiMekanism { if(filter.color != null) { - drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis); + drawCreativeTabHoveringText(filter.color.getColoredName(), xAxis, yAxis); } else { drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); diff --git a/src/main/java/mekanism/client/gui/GuiTOreDictFilter.java b/src/main/java/mekanism/client/gui/GuiTOreDictFilter.java index 4901d66f1..de80fbf48 100644 --- a/src/main/java/mekanism/client/gui/GuiTOreDictFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTOreDictFilter.java @@ -194,7 +194,7 @@ public class GuiTOreDictFilter extends GuiMekanism { if(filter.color != null) { - drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis); + drawCreativeTabHoveringText(filter.color.getColoredName(), xAxis, yAxis); } else { drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); diff --git a/src/main/java/mekanism/client/gui/GuiTransporterConfig.java b/src/main/java/mekanism/client/gui/GuiTransporterConfig.java index f4896c16c..16e510f72 100644 --- a/src/main/java/mekanism/client/gui/GuiTransporterConfig.java +++ b/src/main/java/mekanism/client/gui/GuiTransporterConfig.java @@ -158,7 +158,7 @@ public class GuiTransporterConfig extends GuiMekanism { if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) { - drawCreativeTabHoveringText(color != null ? color.getName() : LangUtils.localize("gui.none"), xAxis, yAxis); + drawCreativeTabHoveringText(color != null ? color.getColoredName() : LangUtils.localize("gui.none"), xAxis, yAxis); } } } @@ -167,7 +167,7 @@ public class GuiTransporterConfig extends GuiMekanism { if(configurable.getEjector().getOutputColor() != null) { - drawCreativeTabHoveringText(configurable.getEjector().getOutputColor().getName(), xAxis, yAxis); + drawCreativeTabHoveringText(configurable.getEjector().getOutputColor().getColoredName(), xAxis, yAxis); } else { drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); diff --git a/src/main/java/mekanism/client/gui/element/GuiGauge.java b/src/main/java/mekanism/client/gui/element/GuiGauge.java index 146cf95e1..3f4c75d6a 100644 --- a/src/main/java/mekanism/client/gui/element/GuiGauge.java +++ b/src/main/java/mekanism/client/gui/element/GuiGauge.java @@ -140,7 +140,7 @@ public abstract class GuiGauge extends GuiElement } } - guiObj.displayTooltip(color + data.localize() + " (" + color.getName() + ")", xAxis, yAxis); + guiObj.displayTooltip(color + data.localize() + " (" + color.getColoredName() + ")", xAxis, yAxis); } } } diff --git a/src/main/java/mekanism/client/render/ctm/ModelChiselBlock.java b/src/main/java/mekanism/client/render/ctm/CTMModelFactory.java similarity index 91% rename from src/main/java/mekanism/client/render/ctm/ModelChiselBlock.java rename to src/main/java/mekanism/client/render/ctm/CTMModelFactory.java index 8ee65da96..dbd9e0a2b 100644 --- a/src/main/java/mekanism/client/render/ctm/ModelChiselBlock.java +++ b/src/main/java/mekanism/client/render/ctm/CTMModelFactory.java @@ -37,7 +37,7 @@ import com.google.common.collect.Lists; * Model for all chisel blocks */ @SuppressWarnings("deprecation") -public class ModelChiselBlock implements ISmartBlockModel, ISmartItemModel, IPerspectiveAwareModel +public class CTMModelFactory implements ISmartBlockModel, ISmartItemModel, IPerspectiveAwareModel { public static final TRSRTransformation DEFAULT_BLOCK_THIRD_PERSON_TRANSOFRM = new TRSRTransformation(new Vector3f(0, 1.5f / 16f, -2.75f / 16f), TRSRTransformation.quatFromYXZDegrees(new Vector3f(10, -45, 170)), new Vector3f(0.375f, 0.375f, 0.375f), null); public static final Matrix4f DEFAULT_BLOCK_THIRD_PERSON_MATRIX = DEFAULT_BLOCK_THIRD_PERSON_TRANSOFRM.getMatrix(); @@ -45,16 +45,16 @@ public class ModelChiselBlock implements ISmartBlockModel, ISmartItemModel, IPer private List face; private List general; - private ModelChisel model; + private ModelCTM model; - public ModelChiselBlock(List face, List general, ModelChisel model) + public CTMModelFactory(List f, List g, ModelCTM m) { - this.face = face; - this.general = general; - this.model = model; + face = f; + general = g; + model = m; } - public ModelChiselBlock(ModelChisel model) + public CTMModelFactory(ModelCTM model) { this(Collections.emptyList(), Collections.emptyList(), model); } @@ -124,7 +124,7 @@ public class ModelChiselBlock implements ISmartBlockModel, ISmartItemModel, IPer return createModel(block.getDefaultState(), model, null); } - private ModelChiselBlock createModel(IBlockState state, ModelChisel model, CTMBlockRenderContext ctx) + private CTMModelFactory createModel(IBlockState state, ModelCTM model, CTMBlockRenderContext ctx) { List faceQuads = Lists.newArrayList(); List generalQuads = Lists.newArrayList(); @@ -148,7 +148,7 @@ public class ModelChiselBlock implements ISmartBlockModel, ISmartItemModel, IPer addAllQuads(origGeneralQuads, face, ctx, state, quadGoal, generalQuads); } - return new ModelChiselBlock(faceQuads, generalQuads, model); + return new CTMModelFactory(faceQuads, generalQuads, model); } private void addAllQuads(List from, ChiselTextureCTM tex, @Nullable CTMBlockRenderContext ctx, IBlockState state, int quadGoal, List to) diff --git a/src/main/java/mekanism/client/render/ctm/CTMRegistry.java b/src/main/java/mekanism/client/render/ctm/CTMRegistry.java index 52b54128d..ba193fce4 100644 --- a/src/main/java/mekanism/client/render/ctm/CTMRegistry.java +++ b/src/main/java/mekanism/client/render/ctm/CTMRegistry.java @@ -49,9 +49,9 @@ public class CTMRegistry for(Pair pair : ctmTypes) { - ModelChisel chiselModel = new ModelChisel(baseModel, pair.getRight()); + ModelCTM chiselModel = new ModelCTM(baseModel, pair.getRight()); chiselModel.load(); - event.modelRegistry.putObject(new ModelResourceLocation(pair.getLeft() + ":" + pair.getRight()), new ModelChiselBlock(chiselModel)); + event.modelRegistry.putObject(new ModelResourceLocation(pair.getLeft() + ":" + pair.getRight()), new CTMModelFactory(chiselModel)); } } diff --git a/src/main/java/mekanism/client/render/ctm/ModelCTM.java b/src/main/java/mekanism/client/render/ctm/ModelCTM.java index f71de198b..701b9fec6 100644 --- a/src/main/java/mekanism/client/render/ctm/ModelCTM.java +++ b/src/main/java/mekanism/client/render/ctm/ModelCTM.java @@ -1,143 +1,94 @@ -//package team.chisel.client.render.ctm; -// -//import team.chisel.common.block.BlockCarvable; -//import team.chisel.common.block.subblocks.ICTMSubBlock; -//import team.chisel.common.block.subblocks.ISubBlock; -//import team.chisel.common.connections.CTMConnections; -//import team.chisel.common.util.EnumConnection; -//import team.chisel.common.util.SubBlockUtil; -//import team.chisel.common.variation.PropertyVariation; -//import team.chisel.common.variation.Variation; -//import net.minecraft.block.state.IBlockState; -//import net.minecraft.client.renderer.block.model.BakedQuad; -//import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -//import net.minecraft.client.renderer.texture.TextureAtlasSprite; -//import net.minecraft.client.resources.model.IBakedModel; -//import net.minecraft.util.EnumFacing; -//import net.minecraftforge.client.model.ISmartBlockModel; -//import net.minecraftforge.common.property.IExtendedBlockState; -// -//import javax.vecmath.Vector3f; -//import java.util.ArrayList; -//import java.util.List; -// -///** -// * Block Model for Connected textures -// * Deals with the Connected texture rendering basically -// * -// * @author minecreatr -// */ -//public class ModelCTM implements ISmartBlockModel { -// -// -// private List quads; -// -// private TextureAtlasSprite particle; -// -// -// @Override -// public List getFaceQuads(EnumFacing face) { -// List toReturn = new ArrayList(); -// for (BakedQuad quad : quads) { -// if (quad == null) { -// continue; -// } -// if (quad.getFace() == face) { -// toReturn.add(quad); -// } -// } -// return toReturn; -// } -// -// @Override -// public List getGeneralQuads() { -// return this.quads; -// } -// -// @Override -// public boolean isAmbientOcclusion() { -// return true; -// } -// -// @Override -// public boolean isGui3d() { -// return true; -// } -// -// @Override -// public boolean isBuiltInRenderer() { -// return false; -// } -// -// @Override -// public TextureAtlasSprite getTexture() { -// return particle; -// } -// -// @Override -// public ItemCameraTransforms getItemCameraTransforms() { -// return ItemCameraTransforms.DEFAULT; -// } -// -// @Override -// public IBakedModel handleBlockState(IBlockState state) { -// // /throw new RuntimeException(state.getValue(BlockCarvable.VARIATION).toString()); -// PropertyVariation VARIATION = null; -// if (state.getBlock() instanceof BlockCarvable) { -// VARIATION = ((BlockCarvable) state.getBlock()).variation; -// } -// List newQuads = generateQuads(state, VARIATION); -// this.quads = newQuads; -// this.particle = SubBlockUtil.getResources(state.getBlock(), (Variation) state.getValue(VARIATION)).getDefaultTexture(); -// return this; -// } -// -// private List generateQuads(IBlockState state, PropertyVariation VARIATION) { -// List newQuads = new ArrayList(); -// Variation variation = (Variation) state.getValue(VARIATION); -// if (state.getBlock() instanceof BlockCarvable) { -// ISubBlock subBlock = ((BlockCarvable) state.getBlock()).getSubBlock(variation); -// if (subBlock instanceof ICTMSubBlock) { -// ICTMSubBlock ctmSubBlock = (ICTMSubBlock) subBlock; -// for (EnumFacing f : EnumFacing.values()) { -// if (!isTouchingSide(state, f)) { -// CTMFaceBakery.instance.makeCtmFace(f, ctmSubBlock.getResources(), CTM.getInstance().getSubmapIndices((IExtendedBlockState) state, f)).addToList(newQuads); -// } -// } -// } -// } -// return newQuads; -// } -// -// public static boolean isTouchingSide(IBlockState inState, EnumFacing f) { -// if (inState == null) { -// return false; -// } -// if (!(inState instanceof IExtendedBlockState)) { -// return false; -// } -// IExtendedBlockState state = (IExtendedBlockState) inState; -// CTMConnections connections = state.getValue(BlockCarvable.CONNECTIONS); -// if (connections.isConnected(EnumConnection.UP) && f == EnumFacing.UP) { -// return true; -// } -// if (connections.isConnected(EnumConnection.DOWN) && f == EnumFacing.DOWN) { -// return true; -// } -// if (connections.isConnected(EnumConnection.NORTH) && f == EnumFacing.NORTH) { -// return true; -// } -// if (connections.isConnected(EnumConnection.SOUTH) && f == EnumFacing.SOUTH) { -// return true; -// } -// if (connections.isConnected(EnumConnection.WEST) && f == EnumFacing.WEST) { -// return true; -// } -// if (connections.isConnected(EnumConnection.EAST) && f == EnumFacing.EAST) { -// return true; -// } -// return false; -// } -// -// -//} +package mekanism.client.render.ctm; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.client.resources.model.IBakedModel; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.IFlexibleBakedModel; +import net.minecraftforge.client.model.IModel; +import net.minecraftforge.client.model.IModelState; +import net.minecraftforge.client.model.TRSRTransformation; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +public class ModelCTM implements IModel +{ + private Map overrides = Maps.newHashMap(); + + private transient ChiselTextureCTM faceObj; + private transient Map overridesObj = new EnumMap<>(EnumFacing.class); + + private transient IBakedModel modelObj; + + private transient List textures = Lists.newArrayList(); + + public String modelName; + + public ModelCTM(IBakedModel model, String name) + { + modelObj = model; + modelName = name; + } + + @Override + public Collection getDependencies() + { + return new ArrayList(); + } + + @Override + public Collection getTextures() + { + return ImmutableList.copyOf(textures); + } + + @Override + public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) + { + return null; + } + + @Override + public IModelState getDefaultState() + { + return TRSRTransformation.identity(); + } + + void load() + { + if(faceObj != null) + { + return; + } + + faceObj = CTMRegistry.textureCache.get(modelName); + textures.addAll(faceObj.getTextures()); + overridesObj.values().forEach(t -> textures.addAll(t.getTextures())); + } + + public ChiselTextureCTM getDefaultFace() + { + return faceObj; + } + + public ChiselTextureCTM getFace(EnumFacing facing) + { + return overridesObj.getOrDefault(facing, faceObj); + } + + public IBakedModel getModel(IBlockState state) + { + return modelObj; + } +} diff --git a/src/main/java/mekanism/client/render/ctm/ModelChisel.java b/src/main/java/mekanism/client/render/ctm/ModelChisel.java deleted file mode 100644 index ac0492585..000000000 --- a/src/main/java/mekanism/client/render/ctm/ModelChisel.java +++ /dev/null @@ -1,94 +0,0 @@ -package mekanism.client.render.ctm; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.EnumMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.model.IFlexibleBakedModel; -import net.minecraftforge.client.model.IModel; -import net.minecraftforge.client.model.IModelState; -import net.minecraftforge.client.model.TRSRTransformation; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -public class ModelChisel implements IModel -{ - private Map overrides = Maps.newHashMap(); - - private transient ChiselTextureCTM faceObj; - private transient Map overridesObj = new EnumMap<>(EnumFacing.class); - - private transient IBakedModel modelObj; - - private transient List textures = Lists.newArrayList(); - - public String modelName; - - public ModelChisel(IBakedModel model, String name) - { - modelObj = model; - modelName = name; - } - - @Override - public Collection getDependencies() - { - return new ArrayList(); - } - - @Override - public Collection getTextures() - { - return ImmutableList.copyOf(textures); - } - - @Override - public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) - { - return null; - } - - @Override - public IModelState getDefaultState() - { - return TRSRTransformation.identity(); - } - - void load() - { - if(faceObj != null) - { - return; - } - - faceObj = CTMRegistry.textureCache.get(modelName); - textures.addAll(faceObj.getTextures()); - overridesObj.values().forEach(t -> textures.addAll(t.getTextures())); - } - - public ChiselTextureCTM getDefaultFace() - { - return faceObj; - } - - public ChiselTextureCTM getFace(EnumFacing facing) - { - return overridesObj.getOrDefault(facing, faceObj); - } - - public IBakedModel getModel(IBlockState state) - { - return modelObj; - } -} diff --git a/src/main/java/mekanism/client/render/ctm/Quad.java b/src/main/java/mekanism/client/render/ctm/Quad.java index b674c180b..494483633 100644 --- a/src/main/java/mekanism/client/render/ctm/Quad.java +++ b/src/main/java/mekanism/client/render/ctm/Quad.java @@ -52,26 +52,31 @@ public class Quad this(BASE, data); } - private UVs(TextureAtlasSprite sprite, Vector2f... data) { + private UVs(TextureAtlasSprite sprite, Vector2f... data) + { this.data = data; this.sprite = sprite; float minU = Float.MAX_VALUE; float minV = Float.MAX_VALUE; float maxU = 0, maxV = 0; - for (Vector2f v : data) { + + for (Vector2f v : data) + { minU = Math.min(minU, v.x); minV = Math.min(minV, v.y); maxU = Math.max(maxU, v.x); maxV = Math.max(maxV, v.y); } + this.minU = minU; this.minV = minV; this.maxU = maxU; this.maxV = maxV; } - public UVs(float minU, float minV, float maxU, float maxV, TextureAtlasSprite sprite) { + public UVs(float minU, float minV, float maxU, float maxV, TextureAtlasSprite sprite) + { this.minU = minU; this.minV = minV; this.maxU = maxU; @@ -80,7 +85,8 @@ public class Quad this.data = vectorize(); } - public UVs transform(TextureAtlasSprite other, ISubmap submap) { + public UVs transform(TextureAtlasSprite other, ISubmap submap) + { UVs normal = normalize(); submap = submap.normalize(); @@ -104,7 +110,8 @@ public class Quad .relativize(); } - UVs normalizeQuadrant() { + public UVs normalizeQuadrant() + { UVs normal = normalize(); int quadrant = normal.getQuadrant(); @@ -117,13 +124,15 @@ public class Quad return normal.relativize(); } - public UVs normalize() { + public UVs normalize() + { Vector2f min = new Vector2f(sprite.getMinU(), sprite.getMinV()); Vector2f max = new Vector2f(sprite.getMaxU(), sprite.getMaxV()); return new UVs(sprite, normalize(min, max, data)); } - public UVs relativize() { + public UVs relativize() + { return relativize(sprite); } @@ -132,51 +141,70 @@ public class Quad return sprite; } - public UVs relativize(TextureAtlasSprite sprite) { + public UVs relativize(TextureAtlasSprite sprite) + { Vector2f min = new Vector2f(sprite.getMinU(), sprite.getMinV()); Vector2f max = new Vector2f(sprite.getMaxU(), sprite.getMaxV()); return new UVs(sprite, lerp(min, max, data)); } - public Vector2f[] vectorize() { + public Vector2f[] vectorize() + { return data == null ? new Vector2f[]{ new Vector2f(minU, minV), new Vector2f(minU, maxV), new Vector2f(maxU, maxV), new Vector2f(maxU, minV) } : data; } - private Vector2f[] normalize(Vector2f min, Vector2f max, Vector2f... vecs) { + private Vector2f[] normalize(Vector2f min, Vector2f max, Vector2f... vecs) + { Vector2f[] ret = new Vector2f[vecs.length]; - for (int i = 0; i < ret.length; i++) { + + for(int i = 0; i < ret.length; i++) + { ret[i] = normalize(min, max, vecs[i]); } + return ret; } - private Vector2f normalize(Vector2f min, Vector2f max, Vector2f vec) { + private Vector2f normalize(Vector2f min, Vector2f max, Vector2f vec) + { return new Vector2f(Quad.normalize(min.x, max.x, vec.x), Quad.normalize(min.y, max.y, vec.y)); } - private Vector2f[] lerp(Vector2f min, Vector2f max, Vector2f... vecs) { + private Vector2f[] lerp(Vector2f min, Vector2f max, Vector2f... vecs) + { Vector2f[] ret = new Vector2f[vecs.length]; - for (int i = 0; i < ret.length; i++) { + + for(int i = 0; i < ret.length; i++) + { ret[i] = lerp(min, max, vecs[i]); } + return ret; } - private Vector2f lerp(Vector2f min, Vector2f max, Vector2f vec) { + private Vector2f lerp(Vector2f min, Vector2f max, Vector2f vec) + { return new Vector2f(Quad.lerp(min.x, max.x, vec.x), Quad.lerp(min.y, max.y, vec.y)); } - public int getQuadrant() { - if (maxU <= 0.5f) { - if (maxV <= 0.5f) { + public int getQuadrant() + { + if(maxU <= 0.5f) + { + if(maxV <= 0.5f) + { return 3; - } else { + } + else { return 0; } - } else { - if (maxV <= 0.5f) { + } + else { + if(maxV <= 0.5f) + { return 2; - } else { + } + else { return 1; } } @@ -191,16 +219,18 @@ public class Quad private final Builder builder; - private Quad(Vector3f[] verts, Vector2f[] uvs, Builder builder) { - this.vertPos = verts; - this.vertUv = uvs; - this.builder = builder; - this.uvsObj = new UVs(uvs); + private Quad(Vector3f[] verts, Vector2f[] uvs, Builder b) + { + vertPos = verts; + vertUv = uvs; + builder = b; + uvsObj = new UVs(uvs); } - private Quad(Vector3f[] verts, UVs uvs, Builder builder) { + private Quad(Vector3f[] verts, UVs uvs, Builder builder) + { this(verts, uvs.vectorize(), builder); - this.uvsObj = new UVs(uvs.getSprite(), vertUv); + uvsObj = new UVs(uvs.getSprite(), vertUv); } public UVs getUVs() @@ -208,18 +238,21 @@ public class Quad return uvsObj; } - public Quad[] subdivide(int count) { + public Quad[] subdivide(int count) + { List rects = Lists.newArrayList(); Pair firstDivide = divide(false); Pair secondDivide = firstDivide.getLeft().divide(true); rects.add(secondDivide.getLeft()); - if (firstDivide.getRight() != null) { + if(firstDivide.getRight() != null) + { Pair thirdDivide = firstDivide.getRight().divide(true); rects.add(thirdDivide.getLeft()); rects.add(thirdDivide.getRight()); - } else { + } + else { rects.add(null); rects.add(null); } @@ -230,23 +263,32 @@ public class Quad } @Nullable - private Pair divide(boolean vertical) { + private Pair divide(boolean vertical) + { float min, max; UVs uvs = uvsObj.normalize(); - if (vertical) { + + if(vertical) + { min = uvs.minV; max = uvs.maxV; - } else { + } + else { min = uvs.minU; max = uvs.maxU; } - if (min < 0.5 && max > 0.5) { + + if(min < 0.5 && max > 0.5) + { UVs first = new UVs(vertical ? uvs.minU : 0.5f, vertical ? 0.5f : uvs.minV, uvs.maxU, uvs.maxV, uvs.getSprite()); UVs second = new UVs(uvs.minU, uvs.minV, vertical ? uvs.maxU : 0.5f, vertical ? 0.5f : uvs.maxV, uvs.getSprite()); int firstIndex = 0; - for (int i = 0; i < vertUv.length; i++) { - if (vertUv[i].y == uvsObj.minV && vertUv[i].x == uvsObj.minU) { + + for(int i = 0; i < vertUv.length; i++) + { + if(vertUv[i].y == uvsObj.minV && vertUv[i].x == uvsObj.minU) + { firstIndex = i; break; } @@ -256,7 +298,9 @@ public class Quad Vector3f[] firstQuad = new Vector3f[4]; Vector3f[] secondQuad = new Vector3f[4]; - for (int i = 0; i < 4; i++) { + + for(int i = 0; i < 4; i++) + { int idx = (firstIndex + i) % 4; firstQuad[i] = new Vector3f(vertPos[idx]); secondQuad[i] = new Vector3f(vertPos[idx]); @@ -283,91 +327,116 @@ public class Quad Quad q1 = new Quad(firstQuad, first.relativize(), builder); Quad q2 = new Quad(secondQuad, second.relativize(), builder); + return Pair.of(q1, q2); - } else { + } + else { return Pair.of(this, null); } } - static float lerp(float a, float b, float f) { + static float lerp(float a, float b, float f) + { float ret = (a * (1 - f)) + (b * f); return ret; } - static float normalize(float min, float max, float x) { + static float normalize(float min, float max, float x) + { float ret = (x - min) / (max - min); return ret; } - public Quad rotate(int amount) { + public Quad rotate(int amount) + { Vector2f[] uvs = new Vector2f[4]; TextureAtlasSprite s = uvsObj.getSprite(); - for (int i = 0; i < 4; i++) { + for(int i = 0; i < 4; i++) + { Vector2f normalized = new Vector2f(normalize(s.getMinU(), s.getMaxU(), vertUv[i].x), normalize(s.getMinV(), s.getMaxV(), vertUv[i].y)); Vector2f uv; - switch (amount) { - case 1: - uv = new Vector2f(normalized.y, 1 - normalized.x); - break; - case 2: - uv = new Vector2f(1 - normalized.x, 1 - normalized.y); - break; - case 3: - uv = new Vector2f(1 - normalized.y, normalized.x); - break; - default: - uv = new Vector2f(normalized.x, normalized.y); - break; + + switch(amount) + { + case 1: + uv = new Vector2f(normalized.y, 1 - normalized.x); + break; + case 2: + uv = new Vector2f(1 - normalized.x, 1 - normalized.y); + break; + case 3: + uv = new Vector2f(1 - normalized.y, normalized.x); + break; + default: + uv = new Vector2f(normalized.x, normalized.y); + break; } + uvs[i] = uv; } - for (int i = 0; i < uvs.length; i++) { + for(int i = 0; i < uvs.length; i++) + { uvs[i] = new Vector2f(lerp(s.getMinU(), s.getMaxU(), uvs[i].x), lerp(s.getMinV(), s.getMaxV(), uvs[i].y)); } Quad ret = new Quad(vertPos, uvs, builder); ret.uvsObj = new UVs(uvsObj.getSprite(), ret.vertUv); + return ret; } - public Quad derotate() { + public Quad derotate() + { int start = 0; - for (int i = 0; i < 4; i++) { - if (vertUv[i].x <= uvsObj.minU && vertUv[i].y <= uvsObj.minV) { + + for(int i = 0; i < 4; i++) + { + if(vertUv[i].x <= uvsObj.minU && vertUv[i].y <= uvsObj.minV) + { start = i; break; } } Vector2f[] uvs = new Vector2f[4]; - for (int i = 0; i < 4; i++) { + + for(int i = 0; i < 4; i++) + { uvs[i] = vertUv[(i + start) % 4]; } + return new Quad(vertPos, uvs, builder); } - public BakedQuad rebake() { + public BakedQuad rebake() + { UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(this.builder.vertexFormat); builder.setQuadOrientation(this.builder.quadOrientation); builder.setQuadTint(this.builder.quadTint); - for (int v = 0; v < 4; v++) { - for (int i = 0; i < this.builder.vertexFormat.getElementCount(); i++) { + for(int v = 0; v < 4; v++) + { + for(int i = 0; i < this.builder.vertexFormat.getElementCount(); i++) + { VertexFormatElement ele = this.builder.vertexFormat.getElement(i); - switch (ele.getUsage()) { - case UV: - Vector2f uv = vertUv[v]; - builder.put(i, uv.x, uv.y, 0, 1); - break; - case POSITION: - Vector3f p = vertPos[v]; - builder.put(i, p.x, p.y, p.z, 1); - break; - default: - builder.put(i, this.builder.data.get(ele.getUsage()).get(v)); + + switch(ele.getUsage()) + { + case UV: + Vector2f uv = vertUv[v]; + builder.put(i, uv.x, uv.y, 0, 1); + + break; + case POSITION: + Vector3f p = vertPos[v]; + builder.put(i, p.x, p.y, p.z, 1); + + break; + default: + builder.put(i, this.builder.vertexData.get(ele.getUsage()).get(v)); } } } @@ -375,19 +444,23 @@ public class Quad return builder.build(); } - public Quad transformUVs(TextureAtlasSprite sprite) { + public Quad transformUVs(TextureAtlasSprite sprite) + { return transformUVs(sprite, CTM.FULL_TEXTURE.normalize()); } - public Quad transformUVs(TextureAtlasSprite sprite, ISubmap submap) { + public Quad transformUVs(TextureAtlasSprite sprite, ISubmap submap) + { return new Quad(vertPos, uvsObj.transform(sprite, submap), builder); } - public Quad grow() { + public Quad grow() + { return new Quad(vertPos, uvsObj.normalizeQuadrant(), builder); } - public static Quad from(BakedQuad baked, VertexFormat fmt) { + public static Quad from(BakedQuad baked, VertexFormat fmt) + { Builder b = new Builder(fmt); baked.pipe(b); return b.build().derotate(); // for now we will ignore rotated UVs @@ -427,29 +500,36 @@ public class Quad @Override public void setQuadColored() {} - private ListMultimap data = MultimapBuilder.enumKeys(EnumUsage.class).arrayListValues().build(); + private ListMultimap vertexData = MultimapBuilder.enumKeys(EnumUsage.class).arrayListValues().build(); @Override - public void put(int element, float... data) { + public void put(int element, float... data) + { float[] copy = new float[data.length]; System.arraycopy(data, 0, copy, 0, data.length); VertexFormatElement ele = vertexFormat.getElement(element); - this.data.put(ele.getUsage(), copy); + vertexData.put(ele.getUsage(), copy); } - public Quad build() { - Vector3f[] verts = fromData(data.get(EnumUsage.POSITION), 3); - Vector2f[] uvs = fromData(data.get(EnumUsage.UV), 2); + public Quad build() + { + Vector3f[] verts = fromData(vertexData.get(EnumUsage.POSITION), 3); + Vector2f[] uvs = fromData(vertexData.get(EnumUsage.UV), 2); + return new Quad(verts, uvs, this); } @SuppressWarnings("unchecked") - private T[] fromData(List data, int size) { + private T[] fromData(List data, int size) + { Vector[] ret = size == 2 ? new Vector2f[data.size()] : new Vector3f[data.size()]; - for (int i = 0; i < data.size(); i++) { + + for(int i = 0; i < data.size(); i++) + { ret[i] = size == 2 ? new Vector2f(data.get(i)[0], data.get(i)[1]) : new Vector3f(data.get(i)[0], data.get(i)[1], data.get(i)[2]); } - return (T[]) ret; + + return (T[])ret; } } } diff --git a/src/main/java/mekanism/client/render/item/BakedCustomItemModel.java b/src/main/java/mekanism/client/render/item/BakedCustomItemModel.java index acddeab2b..8bf2c2f58 100644 --- a/src/main/java/mekanism/client/render/item/BakedCustomItemModel.java +++ b/src/main/java/mekanism/client/render/item/BakedCustomItemModel.java @@ -23,7 +23,7 @@ import mekanism.client.model.ModelSecurityDesk; import mekanism.client.model.ModelSeismicVibrator; import mekanism.client.model.ModelSolarNeutronActivator; import mekanism.client.render.MekanismRenderer; -import mekanism.client.render.ctm.ModelChiselBlock; +import mekanism.client.render.ctm.CTMModelFactory; import mekanism.client.render.tileentity.RenderBin; import mekanism.client.render.tileentity.RenderEnergyCube; import mekanism.client.render.tileentity.RenderFluidTank; @@ -444,7 +444,7 @@ public class BakedCustomItemModel implements IBakedModel, IPerspectiveAwareModel { if(cameraTransformType == TransformType.THIRD_PERSON) { - ForgeHooksClient.multiplyCurrentGlMatrix(ModelChiselBlock.DEFAULT_BLOCK_THIRD_PERSON_MATRIX); + ForgeHooksClient.multiplyCurrentGlMatrix(CTMModelFactory.DEFAULT_BLOCK_THIRD_PERSON_MATRIX); } GlStateManager.pushMatrix(); diff --git a/src/main/java/mekanism/client/render/obj/MekanismOBJLoader.java b/src/main/java/mekanism/client/render/obj/MekanismOBJLoader.java new file mode 100644 index 000000000..f48eb683e --- /dev/null +++ b/src/main/java/mekanism/client/render/obj/MekanismOBJLoader.java @@ -0,0 +1,46 @@ +package mekanism.client.render.obj; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.IModel; +import net.minecraftforge.client.model.ModelLoaderRegistry; +import net.minecraftforge.client.model.obj.OBJLoader; +import net.minecraftforge.client.model.obj.OBJModel; + +public class MekanismOBJLoader extends OBJLoader +{ + private final Map modelCache = new HashMap(); + + @Override + public boolean accepts(ResourceLocation modelLocation) + { + return modelLocation.getResourcePath().endsWith(".obj.mek"); + } + + @Override + public IModel loadModel(ResourceLocation loc) throws IOException + { + if(!modelCache.containsKey(loc)) + { + IModel model = super.loadModel(loc); + + if(model instanceof OBJModel) + { + MekanismOBJModel mekModel = new MekanismOBJModel(((OBJModel)model).getMatLib(), loc); + modelCache.put(loc, mekModel); + } + } + + MekanismOBJModel mekModel = modelCache.get(loc); + + if(mekModel == null) + { + return ModelLoaderRegistry.getMissingModel(); + } + + return mekModel; + } +} diff --git a/src/main/java/mekanism/client/render/obj/MekanismOBJModel.java b/src/main/java/mekanism/client/render/obj/MekanismOBJModel.java new file mode 100644 index 000000000..0bf0d8cc7 --- /dev/null +++ b/src/main/java/mekanism/client/render/obj/MekanismOBJModel.java @@ -0,0 +1,25 @@ +package mekanism.client.render.obj; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.IFlexibleBakedModel; +import net.minecraftforge.client.model.IModelState; +import net.minecraftforge.client.model.obj.OBJModel; + +import com.google.common.base.Function; + +public class MekanismOBJModel extends OBJModel +{ + public MekanismOBJModel(MaterialLibrary matLib, ResourceLocation modelLocation) + { + super(matLib, modelLocation); + } + + @Override + public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) + { + IFlexibleBakedModel preBaked = super.bake(state, format, bakedTextureGetter); + return new MekanismSmartOBJModel(preBaked, this, state, format, MekanismSmartOBJModel.getTexturesForOBJModel(preBaked), null); + } +} diff --git a/src/main/java/mekanism/client/render/obj/MekanismSmartOBJModel.java b/src/main/java/mekanism/client/render/obj/MekanismSmartOBJModel.java new file mode 100644 index 000000000..36581dd9e --- /dev/null +++ b/src/main/java/mekanism/client/render/obj/MekanismSmartOBJModel.java @@ -0,0 +1,96 @@ +package mekanism.client.render.obj; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import mekanism.api.EnumColor; +import mekanism.common.multipart.GlowPanelBlockState; +import mekanism.common.multipart.PartGlowPanel; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.client.resources.model.IBakedModel; +import net.minecraftforge.client.model.IModelState; +import net.minecraftforge.client.model.obj.OBJModel; +import net.minecraftforge.client.model.obj.OBJModel.Group; +import net.minecraftforge.client.model.obj.OBJModel.OBJBakedModel; +import codechicken.lib.vec.Matrix4; + +import com.google.common.collect.ImmutableMap; + +public class MekanismSmartOBJModel extends OBJBakedModel +{ + private IBakedModel baseModel; + + private HashMap transformationMap = new HashMap(); + + private static Map glowPanelCache = new HashMap(); + + private IBlockState tempState; + + public MekanismSmartOBJModel(IBakedModel base, OBJModel model, IModelState state, VertexFormat format, ImmutableMap textures, HashMap transform) + { + model.super(model, state, format, textures); + baseModel = base; + transformationMap = transform; + } + + @Override + public OBJBakedModel handleBlockState(IBlockState state) + { + if(state instanceof GlowPanelBlockState) + { + EnumColor color = state.getValue(PartGlowPanel.colorProperty); + + if(!glowPanelCache.containsKey(color)) + { + MekanismSmartOBJModel model = new MekanismSmartOBJModel(baseModel, getModel(), getState(), getFormat(), getTextures(), transformationMap); + model.tempState = state; + glowPanelCache.put(color, model); + } + + return glowPanelCache.get(color); + } + + return this; + } + + @Override + public List getGeneralQuads() + { + for(Map.Entry g : getModel().getMatLib().getGroups().entrySet()) + { + System.out.println("BAKED " + g.getKey() + " " + g.getValue().getName() + " " + g.getValue().getFaces()); + } + + return super.getGeneralQuads(); + } + + private static Field f_textures; + + public static ImmutableMap getTexturesForOBJModel(IBakedModel model) + { + try { + if(f_textures == null) + { + f_textures = OBJBakedModel.class.getDeclaredField("textures"); + f_textures.setAccessible(true); + } + + return (ImmutableMap)f_textures.get(model); + } catch(Exception e) { + e.printStackTrace(); + } + + return null; + } + + public ImmutableMap getTextures() + { + return getTexturesForOBJModel(this); + } +} diff --git a/src/main/java/mekanism/client/render/transmitter/TransmitterRenderState.java b/src/main/java/mekanism/client/render/transmitter/TransmitterRenderState.java new file mode 100644 index 000000000..20b3ae979 --- /dev/null +++ b/src/main/java/mekanism/client/render/transmitter/TransmitterRenderState.java @@ -0,0 +1,6 @@ +package mekanism.client.render.transmitter; + +public class TransmitterRenderState +{ + +} \ No newline at end of file diff --git a/src/main/java/mekanism/common/item/ItemConfigurator.java b/src/main/java/mekanism/common/item/ItemConfigurator.java index a04576257..222f7cbb8 100644 --- a/src/main/java/mekanism/common/item/ItemConfigurator.java +++ b/src/main/java/mekanism/common/item/ItemConfigurator.java @@ -81,7 +81,7 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool { if(!player.isSneaking()) { - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + getViewModeText(getState(stack).getTransmission()) + ": " + initial.color + initial.localize() + " (" + initial.color.getName() + ")")); + player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + getViewModeText(getState(stack).getTransmission()) + ": " + initial.color + initial.localize() + " (" + initial.color.getColoredName() + ")")); } else { if(getEnergy(stack) >= ENERGY_PER_CONFIGURE) @@ -91,7 +91,7 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool setEnergy(stack, getEnergy(stack) - ENERGY_PER_CONFIGURE); MekanismUtils.incrementOutput(config, getState(stack).getTransmission(), MekanismUtils.getBaseOrientation(side, config.getOrientation())); SideData data = config.getConfig().getOutput(getState(stack).getTransmission(), side, config.getOrientation()); - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + getToggleModeText(getState(stack).getTransmission()) + ": " + data.color + data.localize() + " (" + data.color.getName() + ")")); + player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + getToggleModeText(getState(stack).getTransmission()) + ": " + data.color + data.localize() + " (" + data.color.getColoredName() + ")")); if(config instanceof TileEntityBasicBlock) { diff --git a/src/main/java/mekanism/common/multipart/GlowPanelBlockState.java b/src/main/java/mekanism/common/multipart/GlowPanelBlockState.java new file mode 100644 index 000000000..ad5f6128e --- /dev/null +++ b/src/main/java/mekanism/common/multipart/GlowPanelBlockState.java @@ -0,0 +1,15 @@ +package mekanism.common.multipart; + +import mcmultipart.MCMultiPartMod; +import mekanism.common.block.states.BlockStateFacing; +import net.minecraft.block.properties.IProperty; +import net.minecraftforge.common.property.ExtendedBlockState; +import net.minecraftforge.common.property.IUnlistedProperty; + +public class GlowPanelBlockState extends ExtendedBlockState +{ + public GlowPanelBlockState() + { + super(MCMultiPartMod.multipart, new IProperty[] {BlockStateFacing.facingProperty, PartGlowPanel.colorProperty}, new IUnlistedProperty[] {}); + } +} diff --git a/src/main/java/mekanism/common/multipart/PartGlowPanel.java b/src/main/java/mekanism/common/multipart/PartGlowPanel.java index 12355154b..73bdd0e3d 100644 --- a/src/main/java/mekanism/common/multipart/PartGlowPanel.java +++ b/src/main/java/mekanism/common/multipart/PartGlowPanel.java @@ -9,11 +9,12 @@ import mcmultipart.multipart.IOccludingPart; import mcmultipart.multipart.Multipart; import mcmultipart.multipart.PartSlot; import mcmultipart.raytrace.PartMOP; +import mcmultipart.util.TransformationHelper; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.common.MekanismItems; import mekanism.common.block.states.BlockStateFacing; - +import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; @@ -40,22 +41,11 @@ import codechicken.multipart.NormalOcclusionTest; import codechicken.multipart.TMultiPart; import codechicken.multipart.TileMultipart; */ -import mcmultipart.MCMultiPartMod; -import mcmultipart.block.TileMultipart; -import mcmultipart.microblock.IMicroblock; -import mcmultipart.microblock.IMicroblock.IFaceMicroblock; -import mcmultipart.multipart.IMultipart; -import mcmultipart.multipart.IOccludingPart; -import mcmultipart.multipart.Multipart; -import mcmultipart.multipart.PartSlot; -import mcmultipart.raytrace.PartMOP; -import mcmultipart.util.TransformationHelper; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class PartGlowPanel extends Multipart implements IOccludingPart//, JIconHitEffects +public class PartGlowPanel extends Multipart implements IOccludingPart { + public static PropertyEnum colorProperty = PropertyEnum.create("color", EnumColor.class); + public EnumColor colour = EnumColor.WHITE; public EnumFacing side = EnumFacing.DOWN; @@ -153,22 +143,7 @@ public class PartGlowPanel extends Multipart implements IOccludingPart//, JIconH side = EnumFacing.getFront(nbt.getInteger("side")); colour = EnumColor.DYES[nbt.getInteger("colour")]; } - -/* - @Override - @SideOnly(Side.CLIENT) - public boolean renderStatic(Vector3 pos, int pass) - { - if(pass == 0) - { - RenderGlowPanel.getInstance().renderStatic(this); - return true; - } - - return false; - } -*/ - + @Override public int getLightValue() { @@ -180,35 +155,7 @@ public class PartGlowPanel extends Multipart implements IOccludingPart//, JIconH { addSelectionBoxes(list); } - -/* - @Override - public TextureAtlasSprite getBreakingIcon(Object subPart, EnumFacing side) - { - return RenderGlowPanel.icon; - } - - @Override - public TextureAtlasSprite getBrokenIcon(EnumFacing side) - { - return RenderGlowPanel.icon; - } -*/ - -/* - @Override - public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer) - { - IconHitEffects.addHitEffects(this, hit, effectRenderer); - } - - @Override - public void addDestroyEffects(MovingObjectPosition mop, EffectRenderer effectRenderer) - { - IconHitEffects.addDestroyEffects(this, effectRenderer, false); - } -*/ - + @Override public List getDrops() { @@ -236,12 +183,12 @@ public class PartGlowPanel extends Multipart implements IOccludingPart//, JIconH @Override public BlockState createBlockState() { - return new BlockStateFacing(MCMultiPartMod.multipart); + return new GlowPanelBlockState(); } @Override public IBlockState getExtendedState(IBlockState state) { - return state.withProperty(BlockStateFacing.facingProperty, side); + return state.withProperty(BlockStateFacing.facingProperty, side).withProperty(colorProperty, colour); } } diff --git a/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java b/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java index 873ea1d14..9054f750d 100644 --- a/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java +++ b/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java @@ -394,7 +394,7 @@ public class PartLogisticalTransporter extends PartTransmitter