diff --git a/src/api/java/net/darkhax/tesla/Tesla.java b/src/api/java/net/darkhax/tesla/Tesla.java old mode 100644 new mode 100755 index 5f32c9919..540c2ca8d --- a/src/api/java/net/darkhax/tesla/Tesla.java +++ b/src/api/java/net/darkhax/tesla/Tesla.java @@ -13,7 +13,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -@Mod(modid = Constants.MOD_ID, name = Constants.MOD_NAME, version = Constants.VERSION_NUMBER) +@Mod(modid = Constants.MOD_ID, name = Constants.MOD_NAME, version = Constants.VERSION_NUMBER, acceptedMinecraftVersions = "[1.9.4,1.10.2]") public class Tesla { @Mod.Instance(Constants.MOD_ID) diff --git a/src/api/java/net/darkhax/tesla/api/BaseTeslaContainer.java b/src/api/java/net/darkhax/tesla/api/BaseTeslaContainer.java deleted file mode 100644 index ee5203966..000000000 --- a/src/api/java/net/darkhax/tesla/api/BaseTeslaContainer.java +++ /dev/null @@ -1,225 +0,0 @@ -package net.darkhax.tesla.api; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.INBTSerializable; - -/** - * A basic Tesla container that serves as a consumer, producer and holder. Custom - * implementations do not need to use all three. The INBTSerializable interface is also - * optional. - * - * @deprecated Moved to net.darkhax.tesla.api.implementation - */ -@Deprecated -public class BaseTeslaContainer implements ITeslaConsumer, ITeslaProducer, ITeslaHolder, INBTSerializable { - - /** - * The amount of stored Tesla power. - */ - private long stored; - - /** - * The maximum amount of Tesla power that can be stored. - */ - private long capacity; - - /** - * The maximum amount of Tesla power that can be accepted. - */ - private long inputRate; - - /** - * The maximum amount of Tesla power that can be extracted - */ - private long outputRate; - - /** - * Default constructor. Sets capacity to 5000 and transfer rate to 50. This constructor - * will not set the amount of stored power. These values are arbitrary and should not be - * taken as a base line for balancing. - */ - public BaseTeslaContainer() { - - this(5000, 50, 50); - } - - /** - * Constructor for setting the basic values. Will not construct with any stored power. - * - * @param capacity The maximum amount of Tesla power that the container should hold. - * @param input The maximum rate of power that can be accepted at a time. - * @param output The maximum rate of power that can be extracted at a time. - */ - public BaseTeslaContainer(long capacity, long input, long output) { - - this(0, capacity, input, output); - } - - /** - * Constructor for setting all of the base values, including the stored power. - * - * @param power The amount of stored power to initialize the container with. - * @param capacity The maximum amount of Tesla power that the container should hold. - * @param input The maximum rate of power that can be accepted at a time. - * @param output The maximum rate of power that can be extracted at a time. - */ - public BaseTeslaContainer(long power, long capacity, long input, long output) { - - this.stored = power; - this.capacity = capacity; - this.inputRate = input; - this.outputRate = output; - } - - /** - * Constructor for creating an instance directly from a compound tag. This expects that the - * compound tag has some of the required data. @See {@link #deserializeNBT(NBTTagCompound)} - * for precise info on what is expected. This constructor will only set the stored power if - * it has been written on the compound tag. - * - * @param dataTag The NBTCompoundTag to read the important data from. - */ - public BaseTeslaContainer(NBTTagCompound dataTag) { - - this.deserializeNBT(dataTag); - } - - @Override - public long getStoredPower () { - - return this.stored; - } - - @Override - public long givePower (long Tesla, boolean simulated) { - - final long acceptedTesla = Math.min(this.capacity - this.stored, Math.min(this.inputRate, Tesla)); - - if (!simulated) - this.stored += acceptedTesla; - - return acceptedTesla; - } - - @Override - public long takePower (long Tesla, boolean simulated) { - - final long removedPower = Math.min(this.stored, Math.min(this.outputRate, Tesla)); - - if (!simulated) - this.stored -= removedPower; - - return removedPower; - } - - @Override - public long getCapacity () { - - return this.capacity; - } - - @Override - public NBTTagCompound serializeNBT () { - - final NBTTagCompound dataTag = new NBTTagCompound(); - dataTag.setLong("TeslaPower", this.stored); - dataTag.setLong("TeslaCapacity", this.capacity); - dataTag.setLong("TeslaInput", this.inputRate); - dataTag.setLong("TeslaOutput", this.outputRate); - - return dataTag; - } - - @Override - public void deserializeNBT (NBTTagCompound nbt) { - - this.stored = nbt.getLong("TeslaPower"); - - if (nbt.hasKey("TeslaCapacity")) - this.capacity = nbt.getLong("TeslaCapacity"); - - if (nbt.hasKey("TeslaInput")) - this.inputRate = nbt.getLong("TeslaInput"); - - if (nbt.hasKey("TeslaOutput")) - this.outputRate = nbt.getLong("TeslaOutput"); - - if (this.stored > this.capacity) - this.stored = this.capacity; - } - - /** - * Sets the capacity of the the container. If the existing stored power is more than the - * new capacity, the stored power will be decreased to match the new capacity. - * - * @param capacity The new capacity for the container. - * @return The instance of the container being updated. - */ - public BaseTeslaContainer setCapacity (long capacity) { - - this.capacity = capacity; - - if (this.stored > capacity) - this.stored = capacity; - - return this; - } - - /** - * Gets the maximum amount of Tesla power that can be accepted by the container. - * - * @return The amount of Tesla power that can be accepted at any time. - */ - public long getInputRate () { - - return this.inputRate; - } - - /** - * Sets the maximum amount of Tesla power that can be accepted by the container. - * - * @param rate The amount of Tesla power to accept at a time. - * @return The instance of the container being updated. - */ - public BaseTeslaContainer setInputRate (long rate) { - - this.inputRate = rate; - return this; - } - - /** - * Gets the maximum amount of Tesla power that can be pulled from the container. - * - * @return The amount of Tesla power that can be extracted at any time. - */ - public long getOutputRate () { - - return this.outputRate; - } - - /** - * Sets the maximum amount of Tesla power that can be pulled from the container. - * - * @param rate The amount of Tesla power that can be extracted. - * @return The instance of the container being updated. - */ - public BaseTeslaContainer setOutputRate (long rate) { - - this.outputRate = rate; - return this; - } - - /** - * Sets both the input and output rates of the container at the same time. Both rates will - * be the same. - * - * @param rate The input/output rate for the Tesla container. - * @return The instance of the container being updated. - */ - public BaseTeslaContainer setTransferRate (long rate) { - - this.setInputRate(rate); - this.setOutputRate(rate); - return this; - } -} \ No newline at end of file diff --git a/src/api/java/net/darkhax/tesla/api/ITeslaConsumer.java b/src/api/java/net/darkhax/tesla/api/ITeslaConsumer.java old mode 100644 new mode 100755 index 049840c8e..1f44d716f --- a/src/api/java/net/darkhax/tesla/api/ITeslaConsumer.java +++ b/src/api/java/net/darkhax/tesla/api/ITeslaConsumer.java @@ -7,7 +7,7 @@ public interface ITeslaConsumer { * * @param power The amount of power to offer. * @param simulated Whether or not this is being called as part of a simulation. - * Simulations are used to get information without affecting the Tesla Producer. + * Simulations are used to get information without affecting the Tesla Producer. * @return The amount of power that the consumer accepts. */ long givePower (long power, boolean simulated); diff --git a/src/api/java/net/darkhax/tesla/api/ITeslaHolder.java b/src/api/java/net/darkhax/tesla/api/ITeslaHolder.java old mode 100644 new mode 100755 diff --git a/src/api/java/net/darkhax/tesla/api/ITeslaProducer.java b/src/api/java/net/darkhax/tesla/api/ITeslaProducer.java old mode 100644 new mode 100755 index ec3e17b10..71f1b570b --- a/src/api/java/net/darkhax/tesla/api/ITeslaProducer.java +++ b/src/api/java/net/darkhax/tesla/api/ITeslaProducer.java @@ -7,7 +7,7 @@ public interface ITeslaProducer { * * @param power The amount of power to request. * @param simulated Whether or not this is being called as part of a simulation. - * Simulations are used to get information without affecting the Tesla Producer. + * Simulations are used to get information without affecting the Tesla Producer. * @return The amount of power that the Tesla Producer will give. */ long takePower (long power, boolean simulated); diff --git a/src/api/java/net/darkhax/tesla/api/InfiniteTeslaConsumer.java b/src/api/java/net/darkhax/tesla/api/InfiniteTeslaConsumer.java deleted file mode 100644 index 7f1d670eb..000000000 --- a/src/api/java/net/darkhax/tesla/api/InfiniteTeslaConsumer.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.darkhax.tesla.api; - -/** - * Logic for a Tesla Consumer that will consume infinite amounts of power. - * - * @deprecated Moved to net.darkhax.tesla.api.implementation - */ -@Deprecated -public class InfiniteTeslaConsumer implements ITeslaConsumer { - - @Override - public long givePower (long power, boolean simulated) { - - return power; - } -} \ No newline at end of file diff --git a/src/api/java/net/darkhax/tesla/api/InfiniteTeslaProducer.java b/src/api/java/net/darkhax/tesla/api/InfiniteTeslaProducer.java deleted file mode 100644 index 31987b886..000000000 --- a/src/api/java/net/darkhax/tesla/api/InfiniteTeslaProducer.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.darkhax.tesla.api; - -/** - * Logic for a Tesla Producer that will produce an infinite amount of energy. - * - * @deprecated Moved to net.darkhax.tesla.api.implementation - */ -@Deprecated -public class InfiniteTeslaProducer implements ITeslaProducer { - - @Override - public long takePower (long power, boolean simulated) { - - return power; - } -} \ No newline at end of file diff --git a/src/api/java/net/darkhax/tesla/api/implementation/BaseTeslaContainer.java b/src/api/java/net/darkhax/tesla/api/implementation/BaseTeslaContainer.java old mode 100644 new mode 100755 index 9b68444cf..6d25952f8 --- a/src/api/java/net/darkhax/tesla/api/implementation/BaseTeslaContainer.java +++ b/src/api/java/net/darkhax/tesla/api/implementation/BaseTeslaContainer.java @@ -93,7 +93,7 @@ public class BaseTeslaContainer implements ITeslaConsumer, ITeslaProducer, ITesl @Override public long givePower (long Tesla, boolean simulated) { - final long acceptedTesla = Math.min(this.capacity - this.stored, Math.min(this.inputRate, Tesla)); + final long acceptedTesla = Math.min(this.getCapacity() - this.stored, Math.min(this.getInputRate(), Tesla)); if (!simulated) this.stored += acceptedTesla; @@ -104,7 +104,7 @@ public class BaseTeslaContainer implements ITeslaConsumer, ITeslaProducer, ITesl @Override public long takePower (long Tesla, boolean simulated) { - final long removedPower = Math.min(this.stored, Math.min(this.outputRate, Tesla)); + final long removedPower = Math.min(this.stored, Math.min(this.getOutputRate(), Tesla)); if (!simulated) this.stored -= removedPower; @@ -144,8 +144,8 @@ public class BaseTeslaContainer implements ITeslaConsumer, ITeslaProducer, ITesl if (nbt.hasKey("TeslaOutput")) this.outputRate = nbt.getLong("TeslaOutput"); - if (this.stored > this.capacity) - this.stored = this.capacity; + if (this.stored > this.getCapacity()) + this.stored = this.getCapacity(); } /** diff --git a/src/api/java/net/darkhax/tesla/api/implementation/BaseTeslaContainerProvider.java b/src/api/java/net/darkhax/tesla/api/implementation/BaseTeslaContainerProvider.java old mode 100644 new mode 100755 diff --git a/src/api/java/net/darkhax/tesla/api/implementation/InfiniteTeslaConsumer.java b/src/api/java/net/darkhax/tesla/api/implementation/InfiniteTeslaConsumer.java old mode 100644 new mode 100755 diff --git a/src/api/java/net/darkhax/tesla/api/implementation/InfiniteTeslaConsumerProvider.java b/src/api/java/net/darkhax/tesla/api/implementation/InfiniteTeslaConsumerProvider.java old mode 100644 new mode 100755 diff --git a/src/api/java/net/darkhax/tesla/api/implementation/InfiniteTeslaProducer.java b/src/api/java/net/darkhax/tesla/api/implementation/InfiniteTeslaProducer.java old mode 100644 new mode 100755 diff --git a/src/api/java/net/darkhax/tesla/api/implementation/InfiniteTeslaProducerProvider.java b/src/api/java/net/darkhax/tesla/api/implementation/InfiniteTeslaProducerProvider.java old mode 100644 new mode 100755 diff --git a/src/api/java/net/darkhax/tesla/capability/TeslaCapabilities.java b/src/api/java/net/darkhax/tesla/capability/TeslaCapabilities.java old mode 100644 new mode 100755 index 47c4b17d6..eead19a05 --- a/src/api/java/net/darkhax/tesla/capability/TeslaCapabilities.java +++ b/src/api/java/net/darkhax/tesla/capability/TeslaCapabilities.java @@ -11,12 +11,21 @@ import net.minecraftforge.common.capabilities.CapabilityInject; public class TeslaCapabilities { + /** + * Access to the consumer capability. Can be used for making checks. + */ @CapabilityInject(ITeslaConsumer.class) public static Capability CAPABILITY_CONSUMER = null; + /** + * Access to the producer capability. Can be used for making checks. + */ @CapabilityInject(ITeslaProducer.class) public static Capability CAPABILITY_PRODUCER = null; + /** + * Access to the holder capability. Can be used for making checks. + */ @CapabilityInject(ITeslaHolder.class) public static Capability CAPABILITY_HOLDER = null; diff --git a/src/api/java/net/darkhax/tesla/lib/Constants.java b/src/api/java/net/darkhax/tesla/lib/Constants.java old mode 100644 new mode 100755 index 513e53583..1264984bf --- a/src/api/java/net/darkhax/tesla/lib/Constants.java +++ b/src/api/java/net/darkhax/tesla/lib/Constants.java @@ -2,7 +2,7 @@ package net.darkhax.tesla.lib; public class Constants { - public static final String MOD_ID = "Tesla"; + public static final String MOD_ID = "tesla"; public static final String MOD_NAME = "TESLA"; - public static final String VERSION_NUMBER = "1.1.0.0"; + public static final String VERSION_NUMBER = "1.2.1.0"; } diff --git a/src/api/java/net/darkhax/tesla/lib/PowerBar.java b/src/api/java/net/darkhax/tesla/lib/PowerBar.java new file mode 100755 index 000000000..1ac5f4737 --- /dev/null +++ b/src/api/java/net/darkhax/tesla/lib/PowerBar.java @@ -0,0 +1,103 @@ +package net.darkhax.tesla.lib; + +import net.darkhax.tesla.api.ITeslaHolder; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class PowerBar { + + /** + * Constant reference to the included gui element sheet. + */ + private static final ResourceLocation TEXTURE_SHEET = new ResourceLocation("tesla", "textures/gui/elements.png"); + + /** + * The x position of the power bar on the screen. + */ + private final int x; + + /** + * The y position of the power bar on the screen. + */ + private final int y; + + /** + * The screen to draw the power bar on. + */ + private final GuiScreen screen; + + /** + * The type of background the use when drawing the power bar. + */ + private final BackgroundType background; + + /** + * Object that can be used to draw a power bar on the screen. + * + * @param screen The screen to draw the power bar on. + * @param x The x position of the power bar on the screen. + * @param y The y position of the power bar on the screen. + * @param type The background type to use for the power bar. + */ + public PowerBar(GuiScreen screen, int x, int y, BackgroundType type) { + + this.background = type; + this.screen = screen; + this.x = x; + this.y = y; + } + + /** + * Draws a power bar that represents the power held within an ITeslaHolder. + * + * @param holder The holder to represent. + */ + public void draw (ITeslaHolder holder) { + + draw(holder.getStoredPower(), holder.getCapacity()); + } + + /** + * Draws a power bard that represents the based power information. + * + * @param power The amount of power to represent. + * @param capacity The capacity to represent. + */ + public void draw (long power, long capacity) { + + screen.mc.getTextureManager().bindTexture(TEXTURE_SHEET); + + if (this.background == BackgroundType.LIGHT) + screen.drawTexturedModalRect(x, y, 3, 1, 14, 50); + + else if (this.background == BackgroundType.DARK) + screen.drawTexturedModalRect(x, y, 3, 53, 14, 50); + + long powerOffset = (power * 51) / capacity; + screen.drawTexturedModalRect(x + 1, (int) (y + 50 - powerOffset), 18, (int) (51 - powerOffset), 14, (int) (powerOffset + 2)); + } + + /** + * Describes a background image to be rendered for a power bar. + */ + public enum BackgroundType { + + /** + * No background texture. + */ + NONE, + + /** + * The lighter background texture. + */ + LIGHT, + + /** + * The darker background texture. + */ + DARK, + } +} \ No newline at end of file diff --git a/src/api/java/net/darkhax/tesla/lib/TeslaUtils.java b/src/api/java/net/darkhax/tesla/lib/TeslaUtils.java old mode 100644 new mode 100755 index 5588f1765..2d9f9012d --- a/src/api/java/net/darkhax/tesla/lib/TeslaUtils.java +++ b/src/api/java/net/darkhax/tesla/lib/TeslaUtils.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import net.darkhax.tesla.api.ITeslaConsumer; +import net.darkhax.tesla.api.ITeslaHolder; import net.darkhax.tesla.api.ITeslaProducer; import net.darkhax.tesla.capability.TeslaCapabilities; import net.minecraft.client.resources.I18n; @@ -12,6 +13,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ICapabilityProvider; public class TeslaUtils { @@ -102,6 +104,140 @@ public class TeslaUtils { return I18n.format("unit.tesla." + getUnitType(tesla)); } + /** + * Checks if a capability provider has support for Tesla. + * + * @param provider The provider to check. ItemStack/TileEntity/Entity and so on. + * @param side The side to check. + * @return Whether or not the provider has support for Tesla. + */ + public static boolean hasTeslaSupport (ICapabilityProvider provider, EnumFacing side) { + + return isTeslaHolder(provider, side) || isTeslaConsumer(provider, side) || isTeslaProducer(provider, side); + } + + /** + * Checks if a capability provider is a Tesla holder. + * + * @param provider The provider to check. ItemStack/TileEntity/Entity and so on. + * @param side The side to check. + * @return Whether or not the provider is a Tesla holder. + */ + public static boolean isTeslaHolder (ICapabilityProvider provider, EnumFacing side) { + + return provider.hasCapability(TeslaCapabilities.CAPABILITY_HOLDER, side); + } + + /** + * Checks if a capability provider is a Tesla consumer. + * + * @param provider The provider to check. ItemStack/TileEntity/Entity and so on. + * @param side The side to check. + * @return Whether or not the provider is a Tesla consumer. + */ + public static boolean isTeslaConsumer (ICapabilityProvider provider, EnumFacing side) { + + return provider.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side); + } + + /** + * Checks if a capability provider is a Tesla producer. + * + * @param provider The provider to check. ItemStack/TileEntity/Entity and so on. + * @param side The side to check. + * @return Whether or not the provider is a Tesla producer. + */ + public static boolean isTeslaProducer (ICapabilityProvider provider, EnumFacing side) { + + return provider.hasCapability(TeslaCapabilities.CAPABILITY_PRODUCER, side); + } + + /** + * Gets an ITeslaHolder implementation from the capability provider. + * + * @param provider The provider to get the capability from. + * @param side The side to access; + * @return A Tesla holder implementation, or null if none could be found. + */ + public static ITeslaHolder getTeslaHolder (ICapabilityProvider provider, EnumFacing side) { + + return (ITeslaHolder) provider.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, side); + } + + /** + * Gets an ITeslaConsumer implementation from the capability provider. + * + * @param provider The provider to get the capability from. + * @param side The side to access; + * @return A Tesla consumer implementation, or null if none could be found. + */ + public static ITeslaConsumer getTeslaConsumer (ICapabilityProvider provider, EnumFacing side) { + + return (ITeslaConsumer) provider.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, side); + } + + /** + * Gets an ITeslaProducer implementation from the capability provider. + * + * @param provider The provider to get the capability from. + * @param side The side to access; + * @return A Tesla producer implementation, or null if none could be found. + */ + public static ITeslaProducer getTeslaProducer (ICapabilityProvider provider, EnumFacing side) { + + return (ITeslaProducer) provider.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, side); + } + + /** + * Gets the capacity of a provider. + * + * @param provider The provider to access. + * @param side The side to access. + * @return The capacity of the provider. 0 if it has no capacity. + */ + public static long getCapacity (ICapabilityProvider provider, EnumFacing side) { + + return isTeslaHolder(provider, side) ? getTeslaHolder(provider, side).getCapacity() : 0; + } + + /** + * Gets the stored power of a provider. + * + * @param provider The provider to access. + * @param side The side to access. + * @return The amount of power stored. + */ + public static long getStoredPower (ICapabilityProvider provider, EnumFacing side) { + + return isTeslaHolder(provider, side) ? getTeslaHolder(provider, side).getStoredPower() : 0; + } + + /** + * Attempt to give power to a provider. + * + * @param power The amount of power to offer. + * @param simulated Whether or not this is being called as part of a simulation. + * Simulations are used to get information without affecting the Tesla Producer. + * @return The amount of power that the consumer accepts. + */ + public static long givePower (ICapabilityProvider provider, EnumFacing side, long power, boolean simulated) { + + return isTeslaConsumer(provider, side) ? getTeslaConsumer(provider, side).givePower(power, simulated) : 0; + } + + /** + * Attempts to take power from a provider. + * + * @param power The amount of power to request. + * @param simulated Whether or not this is being called as part of a simulation. + * Simulations are used to get information without affecting the Tesla Producer. + * @return The amount of power that the Tesla Producer will give. + */ + public static long takePower (ICapabilityProvider provider, EnumFacing side, long power, boolean simulated) { + + return isTeslaProducer(provider, side) ? getTeslaProducer(provider, side).takePower(power, simulated) : 0; + } + /** * Gets a list of all capabilities that touch a BlockPos. This will search for tile * entities touching the BlockPos and then query them for access to their capabilities. diff --git a/src/main/java/mekanism/client/render/MekanismRenderer.java b/src/main/java/mekanism/client/render/MekanismRenderer.java index 895b09439..9443e47ec 100644 --- a/src/main/java/mekanism/client/render/MekanismRenderer.java +++ b/src/main/java/mekanism/client/render/MekanismRenderer.java @@ -34,6 +34,7 @@ import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -225,6 +226,30 @@ public class MekanismRenderer return map.containsKey(fluid) ? map.get(fluid) : missingIcon; } + private static VertexFormat prevFormat = null; + private static int prevMode = -1; + + public static void pauseRenderer(Tessellator tess) + { + if(MekanismRenderer.isDrawing(tess)) + { + prevFormat = tess.getBuffer().getVertexFormat(); + prevMode = tess.getBuffer().getDrawMode(); + tess.draw(); + } + } + + public static void resumeRenderer(Tessellator tess) + { + if(prevFormat != null) + { + tess.getBuffer().begin(prevMode, prevFormat); + } + + prevFormat = null; + prevMode = -1; + } + public static boolean isDrawing(Tessellator tess) { return isDrawing(tess.getBuffer()); diff --git a/src/main/java/mekanism/client/render/item/BakedCustomItemModel.java b/src/main/java/mekanism/client/render/item/BakedCustomItemModel.java index b999af21d..88dd0ba1f 100644 --- a/src/main/java/mekanism/client/render/item/BakedCustomItemModel.java +++ b/src/main/java/mekanism/client/render/item/BakedCustomItemModel.java @@ -62,7 +62,6 @@ import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; @@ -426,12 +425,9 @@ public class BakedCustomItemModel implements IBakedModel, IPerspectiveAwareModel Tessellator tessellator = Tessellator.getInstance(); VertexFormat prevFormat = null; + int prevMode = -1; - if(MekanismRenderer.isDrawing(tessellator)) - { - prevFormat = tessellator.getBuffer().getVertexFormat(); - tessellator.draw(); - } + MekanismRenderer.pauseRenderer(tessellator); List generalQuads = new LinkedList(); @@ -448,11 +444,7 @@ public class BakedCustomItemModel implements IBakedModel, IPerspectiveAwareModel Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); GlStateManager.popMatrix(); - if(prevFormat != null) - { - VertexBuffer worldrenderer = tessellator.getBuffer(); - worldrenderer.begin(7, prevFormat); - } + MekanismRenderer.resumeRenderer(tessellator); if(Block.getBlockFromItem(stack.getItem()) != null) { diff --git a/src/main/java/mekanism/generators/client/render/item/BakedGeneratorItemModel.java b/src/main/java/mekanism/generators/client/render/item/BakedGeneratorItemModel.java index f5edc8105..3dcf2fc0f 100644 --- a/src/main/java/mekanism/generators/client/render/item/BakedGeneratorItemModel.java +++ b/src/main/java/mekanism/generators/client/render/item/BakedGeneratorItemModel.java @@ -21,7 +21,6 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; @@ -130,11 +129,7 @@ public class BakedGeneratorItemModel implements IBakedModel, IPerspectiveAwareMo Tessellator tessellator = Tessellator.getInstance(); VertexFormat prevFormat = null; - if(MekanismRenderer.isDrawing(tessellator)) - { - prevFormat = tessellator.getBuffer().getVertexFormat(); - tessellator.draw(); - } + MekanismRenderer.pauseRenderer(tessellator); List generalQuads = new LinkedList(); @@ -150,11 +145,7 @@ public class BakedGeneratorItemModel implements IBakedModel, IPerspectiveAwareMo Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); GlStateManager.popMatrix(); - if(prevFormat != null) - { - VertexBuffer worldrenderer = tessellator.getBuffer(); - worldrenderer.begin(7, prevFormat); - } + MekanismRenderer.resumeRenderer(tessellator); if(Block.getBlockFromItem(stack.getItem()) != null) {