From b395473720905631ebc3aecdb888169512e29416 Mon Sep 17 00:00:00 2001 From: Timo Ley Date: Tue, 6 Apr 2021 11:51:35 +0200 Subject: [PATCH] Fix server side model crash --- src/main/scala/edx/basic/Models.java | 17 +++++++++ .../edx/basic/fluid/gutter/TileGutter.scala | 10 +++--- .../process/grinding/TileWorkbench.scala | 9 ++--- .../basic/process/mixing/TileGlassJar.scala | 6 ++-- .../edx/basic/process/sifting/TileSieve.scala | 12 ++----- src/main/scala/edx/core/Reference.java | 32 +++++++++++++++++ src/main/scala/edx/core/Reference.scala | 36 ------------------- src/main/scala/edx/electrical/Models.java | 20 +++++++++++ .../component/laser/TileLaserEmitter.scala | 9 ++--- .../component/laser/TileLaserReceiver.scala | 7 ++-- .../laser/focus/TileFocusCrystal.scala | 7 ++-- .../component/laser/focus/TileMirror.scala | 7 ++-- .../electrical/circuit/source/TileMotor.scala | 8 ++--- .../circuit/source/battery/TileBattery.scala | 24 ++++++------- src/main/scala/edx/mechanical/Models.java | 18 ++++++++++ .../mechanical/fluid/transport/TilePump.scala | 7 ++-- .../process/grinder/TileGrindingWheel.scala | 11 +++--- .../mech/process/mixer/TileMixer.scala | 2 -- .../mech/turbine/TileWindTurbine.scala | 29 +++++---------- src/main/scala/edx/quantum/Models.java | 17 +++++++++ .../edx/quantum/reactor/TileReactorCell.scala | 14 +++----- 21 files changed, 160 insertions(+), 142 deletions(-) create mode 100644 src/main/scala/edx/basic/Models.java create mode 100644 src/main/scala/edx/core/Reference.java delete mode 100644 src/main/scala/edx/core/Reference.scala create mode 100644 src/main/scala/edx/electrical/Models.java create mode 100644 src/main/scala/edx/mechanical/Models.java create mode 100644 src/main/scala/edx/quantum/Models.java diff --git a/src/main/scala/edx/basic/Models.java b/src/main/scala/edx/basic/Models.java new file mode 100644 index 000000000..65ed4f21d --- /dev/null +++ b/src/main/scala/edx/basic/Models.java @@ -0,0 +1,17 @@ +package edx.basic; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import edx.core.Reference; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.AdvancedModelLoader; +import net.minecraftforge.client.model.IModelCustom; + +@SideOnly(Side.CLIENT) +public class Models { + + public static IModelCustom gutter = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "gutter.tcn")); + public static IModelCustom[] workbench = new IModelCustom[] {AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "workbench_0.obj")), AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "workbench_1.obj"))}; + public static IModelCustom glassjar = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "glassJar.tcn")); + public static IModelCustom sieve = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "sieve.tcn")); +} diff --git a/src/main/scala/edx/basic/fluid/gutter/TileGutter.scala b/src/main/scala/edx/basic/fluid/gutter/TileGutter.scala index 65fb61900..37c40f02a 100644 --- a/src/main/scala/edx/basic/fluid/gutter/TileGutter.scala +++ b/src/main/scala/edx/basic/fluid/gutter/TileGutter.scala @@ -3,6 +3,7 @@ package edx.basic.fluid.gutter import java.util.{ArrayList, List} import cpw.mods.fml.relauncher.{Side, SideOnly} +import edx.basic.Models import edx.basic.fluid.tank.TileTank import edx.core.Reference import edx.core.prefab.node.{NodeFluid, NodeFluidPressure, TileFluidProvider} @@ -14,7 +15,6 @@ import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.tileentity.TileEntity import net.minecraft.util.ResourceLocation -import net.minecraftforge.client.model.AdvancedModelLoader import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.fluids._ import org.lwjgl.opengl.GL11 @@ -30,8 +30,6 @@ import scala.collection.convert.wrapAll._ object TileGutter { - @SideOnly(Side.CLIENT) - private val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "gutter.tcn")) @SideOnly(Side.CLIENT) private val texture = new ResourceLocation(Reference.domain, Reference.modelPath + "gutter.png") } @@ -232,11 +230,11 @@ class TileGutter extends TileFluidProvider(Material.rock) } if (!sides.mask(dir)) { - TileGutter.model.renderOnly("left") + Models.gutter.renderOnly("left") } if (!sides.mask(dir) || !sides.mask(dir.getRotation(ForgeDirection.UP))) { - TileGutter.model.renderOnly("backCornerL") + Models.gutter.renderOnly("backCornerL") } GL11.glPopMatrix() } @@ -244,7 +242,7 @@ class TileGutter extends TileFluidProvider(Material.rock) if (!sides.mask(ForgeDirection.DOWN)) { - TileGutter.model.renderOnly("base") + Models.gutter.renderOnly("base") } } diff --git a/src/main/scala/edx/basic/process/grinding/TileWorkbench.scala b/src/main/scala/edx/basic/process/grinding/TileWorkbench.scala index 8716ba85a..d8e121187 100644 --- a/src/main/scala/edx/basic/process/grinding/TileWorkbench.scala +++ b/src/main/scala/edx/basic/process/grinding/TileWorkbench.scala @@ -1,5 +1,6 @@ package edx.basic.process.grinding +import edx.basic.Models import edx.core.{Electrodynamics, Reference} import io.netty.buffer.ByteBuf import net.minecraft.block.Block @@ -7,8 +8,6 @@ import net.minecraft.block.material.Material import net.minecraft.entity.player.EntityPlayer import net.minecraft.init.Blocks import net.minecraft.item.{Item, ItemBlock, ItemStack} -import net.minecraft.util.ResourceLocation -import net.minecraftforge.client.model.AdvancedModelLoader import net.minecraftforge.oredict.OreDictionary import org.lwjgl.opengl.GL11 import resonantengine.api.edx.recipe.{MachineRecipes, RecipeType} @@ -36,10 +35,6 @@ import resonantengine.prefab.network.{TPacketReceiver, TPacketSender} * * @author Calclavia */ -object TileWorkbench -{ - val model = Array(AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "workbench_0.obj")), AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "workbench_1.obj"))) -} class TileWorkbench extends ResonantTile(Material.wood) with TInventory with TPacketSender with TPacketReceiver { @@ -167,7 +162,7 @@ class TileWorkbench extends ResonantTile(Material.wood) with TInventory with TPa GL11.glColor4f(1, 1, 1, 1) GL11.glTranslated(pos.x, pos.y, pos.z) RenderUtility.bind(Reference.domain, Reference.modelPath + "workbench_" + metadata + ".png") - TileWorkbench.model(metadata).renderAll() + Models.workbench(metadata).renderAll() GL11.glPopMatrix() } diff --git a/src/main/scala/edx/basic/process/mixing/TileGlassJar.scala b/src/main/scala/edx/basic/process/mixing/TileGlassJar.scala index 35c1e7fbf..b71ec998d 100644 --- a/src/main/scala/edx/basic/process/mixing/TileGlassJar.scala +++ b/src/main/scala/edx/basic/process/mixing/TileGlassJar.scala @@ -4,7 +4,7 @@ import java.awt.Color import java.util.ArrayList import cpw.mods.fml.relauncher.{Side, SideOnly} -import edx.basic.BasicContent +import edx.basic.{BasicContent, Models} import edx.core.Reference import edx.core.resource.alloy.{Alloy, AlloyUtility} import edx.core.resource.content.{ItemDust, ItemRefinedDust} @@ -16,7 +16,6 @@ import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound import net.minecraft.util.ResourceLocation import net.minecraftforge.client.IItemRenderer.ItemRenderType -import net.minecraftforge.client.model.AdvancedModelLoader import org.lwjgl.opengl.GL11 import resonantengine.api.item.ISimpleItemRenderer import resonantengine.core.network.discriminator.PacketType @@ -39,7 +38,6 @@ import resonantengine.prefab.network.{TPacketReceiver, TPacketSender} */ object TileGlassJar { - val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "glassJar.tcn")) val dustMaterialTexture = new ResourceLocation(Reference.domain, Reference.blockTextureDirectory + "material_sand.png") } @@ -175,7 +173,7 @@ class TileGlassJar extends ResonantTile(Material.wood) with TPacketReceiver with GL11.glScalef(1.6f, 1.6f, 1.6f) GL11.glColor4f(1, 1, 1, 1) RenderUtility.bind(Reference.domain, Reference.modelPath + "glassJar.png") - TileGlassJar.model.renderAll() + Models.glassjar.renderAll() RenderUtility.disableBlending() } diff --git a/src/main/scala/edx/basic/process/sifting/TileSieve.scala b/src/main/scala/edx/basic/process/sifting/TileSieve.scala index b3ed6d094..bb60db5a9 100644 --- a/src/main/scala/edx/basic/process/sifting/TileSieve.scala +++ b/src/main/scala/edx/basic/process/sifting/TileSieve.scala @@ -3,6 +3,7 @@ package edx.basic.process.sifting import java.util.ArrayList import cpw.mods.fml.relauncher.{Side, SideOnly} +import edx.basic.Models import edx.core.Reference import edx.core.resource.content.ItemRubble import io.netty.buffer.ByteBuf @@ -10,9 +11,7 @@ import net.minecraft.block.Block import net.minecraft.block.material.Material import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack -import net.minecraft.util.ResourceLocation import net.minecraftforge.client.IItemRenderer.ItemRenderType -import net.minecraftforge.client.model.AdvancedModelLoader import org.lwjgl.opengl.GL11 import resonantengine.api.item.ISimpleItemRenderer import resonantengine.core.network.discriminator.PacketType @@ -26,11 +25,6 @@ import resonantengine.lib.wrapper.ByteBufWrapper._ import resonantengine.prefab.block.itemblock.ItemBlockSaved import resonantengine.prefab.network.{TPacketReceiver, TPacketSender} -object TileSieve -{ - val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "sieve.tcn")) -} - class TileSieve extends ResonantTile(Material.wood) with TInventory with TPacketSender with TPacketReceiver with ISimpleItemRenderer { //Constructor @@ -80,7 +74,7 @@ class TileSieve extends ResonantTile(Material.wood) with TInventory with TPacket GL11.glTranslatef(0.5f, 1f, 0.5f) GL11.glScalef(1.4f, 1.4f, 1.4f) RenderUtility.bind(Reference.domain, Reference.modelPath + "sieve.png") - TileSieve.model.renderAll() + Models.sieve.renderAll() GL11.glPopMatrix() } @@ -99,7 +93,7 @@ class TileSieve extends ResonantTile(Material.wood) with TInventory with TPacket GL11.glTranslatef(0.5f, 0.65f, 0.5f) GL11.glScalef(1.4f, 1.4f, 1.4f) RenderUtility.bind(Reference.domain, Reference.modelPath + "sieve.png") - TileSieve.model.renderAll() + Models.sieve.renderAll() GL11.glPopMatrix() } diff --git a/src/main/scala/edx/core/Reference.java b/src/main/scala/edx/core/Reference.java new file mode 100644 index 000000000..6f5f42b59 --- /dev/null +++ b/src/main/scala/edx/core/Reference.java @@ -0,0 +1,32 @@ +package edx.core; + +import java.util.logging.Logger; + +public class Reference { + + public static final String id = "EDX"; + + /** The official name of the mod */ + public static final String name = "Electrodynamics"; + public static final Logger logger = Logger.getLogger(Reference.name); + + public static final String majorVersion = "@MAJOR@"; + public static final String minorVersion = "@MINOR@"; + public static final String revisionVersion = "@REVIS@"; + public static final String build = "@BUILD@"; + public static final String version = majorVersion + "." + minorVersion + "." + revisionVersion; + /** + * Directory Information + */ + public static final String domain = "edx"; + public static final String prefix = domain + ":"; + public static final String assetDirectory = "/assets/" + domain + "/"; + public static final String textureDirectory = "textures/"; + public static final String guiDirectory = textureDirectory + "gui/"; + public static final String blockTextureDirectory = textureDirectory + "blocks/"; + public static final String itemTextureDirectory = textureDirectory + "items/"; + public static final String modelPath = "models/"; + public static final String modelDirectory = assetDirectory + modelPath; + public static final String FX_DIRECTORY = textureDirectory + "fx/"; + +} diff --git a/src/main/scala/edx/core/Reference.scala b/src/main/scala/edx/core/Reference.scala deleted file mode 100644 index 71091e64e..000000000 --- a/src/main/scala/edx/core/Reference.scala +++ /dev/null @@ -1,36 +0,0 @@ -package edx.core - -import java.util.logging.Logger - -/** - * A class for global references. - * - * @author Calclavia - */ -object Reference -{ - final val id = "EDX" - - /** The official name of the mod */ - final val name = "Electrodynamics" - final val logger = Logger.getLogger(Reference.name) - - final val majorVersion = "@MAJOR@" - final val minorVersion = "@MINOR@" - final val revisionVersion = "@REVIS@" - final val build = "@BUILD@" - final val version = majorVersion + "." + minorVersion + "." + revisionVersion - /** - * Directory Information - */ - final val domain: String = "edx" - final val prefix: String = domain + ":" - final val assetDirectory: String = "/assets/" + domain + "/" - final val textureDirectory: String = "textures/" - final val guiDirectory: String = textureDirectory + "gui/" - final val blockTextureDirectory: String = textureDirectory + "blocks/" - final val itemTextureDirectory: String = textureDirectory + "items/" - final val modelPath: String = "models/" - final val modelDirectory: String = assetDirectory + modelPath - final val FX_DIRECTORY = textureDirectory + "fx/" -} \ No newline at end of file diff --git a/src/main/scala/edx/electrical/Models.java b/src/main/scala/edx/electrical/Models.java new file mode 100644 index 000000000..9c0141d36 --- /dev/null +++ b/src/main/scala/edx/electrical/Models.java @@ -0,0 +1,20 @@ +package edx.electrical; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import edx.core.Reference; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.AdvancedModelLoader; +import net.minecraftforge.client.model.IModelCustom; + +@SideOnly(Side.CLIENT) +public class Models { + + public static IModelCustom motor = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "motor.tcn")); + public static IModelCustom laseremitter = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "laserEmitter.tcn")); + public static IModelCustom laserreceiver = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "laserReceiver.tcn")); + public static IModelCustom battery = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "battery/battery.tcn")); + public static IModelCustom mirror = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "mirror.tcn")); + public static IModelCustom focuscrystal = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "focusCrystal.tcn")); + +} diff --git a/src/main/scala/edx/electrical/circuit/component/laser/TileLaserEmitter.scala b/src/main/scala/edx/electrical/circuit/component/laser/TileLaserEmitter.scala index aa6b44a8e..327f7d8e5 100644 --- a/src/main/scala/edx/electrical/circuit/component/laser/TileLaserEmitter.scala +++ b/src/main/scala/edx/electrical/circuit/component/laser/TileLaserEmitter.scala @@ -3,13 +3,13 @@ package edx.electrical.circuit.component.laser import cpw.mods.fml.client.FMLClientHandler import cpw.mods.fml.relauncher.{Side, SideOnly} import edx.core.Reference +import edx.electrical.Models import net.minecraft.block.BlockPistonBase import net.minecraft.block.material.Material import net.minecraft.entity.EntityLivingBase import net.minecraft.item.ItemStack import net.minecraft.util.{MovingObjectPosition, ResourceLocation} import net.minecraft.world.IBlockAccess -import net.minecraftforge.client.model.AdvancedModelLoader import net.minecraftforge.common.util.ForgeDirection import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL11._ @@ -30,9 +30,6 @@ import scala.collection.convert.wrapAll._ */ object TileLaserEmitter { - @SideOnly(Side.CLIENT) - val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "laserEmitter.tcn")) - @SideOnly(Side.CLIENT) val texture = new ResourceLocation(Reference.domain, Reference.modelPath + "laserEmitter.png") } @@ -99,7 +96,7 @@ class TileLaserEmitter extends ResonantTile(Material.iron) with ILaserHandler wi glRotatef(180, 1, 0, 0) FMLClientHandler.instance.getClient.renderEngine.bindTexture(TileLaserEmitter.texture) - TileLaserEmitter.model.renderAll() + Models.laseremitter.renderAll() RenderUtility.disableBlending() GL11.glPopMatrix() @@ -114,7 +111,7 @@ class TileLaserEmitter extends ResonantTile(Material.iron) with ILaserHandler wi RenderUtility.enableBlending() FMLClientHandler.instance.getClient.renderEngine.bindTexture(TileLaserEmitter.texture) - TileLaserEmitter.model.renderAll() + Models.laseremitter.renderAll() RenderUtility.disableBlending() diff --git a/src/main/scala/edx/electrical/circuit/component/laser/TileLaserReceiver.scala b/src/main/scala/edx/electrical/circuit/component/laser/TileLaserReceiver.scala index ebb44630c..d1e714d3a 100644 --- a/src/main/scala/edx/electrical/circuit/component/laser/TileLaserReceiver.scala +++ b/src/main/scala/edx/electrical/circuit/component/laser/TileLaserReceiver.scala @@ -3,12 +3,12 @@ package edx.electrical.circuit.component.laser import cpw.mods.fml.client.FMLClientHandler import cpw.mods.fml.relauncher.{Side, SideOnly} import edx.core.Reference +import edx.electrical.Models import net.minecraft.block.BlockPistonBase import net.minecraft.block.material.Material import net.minecraft.entity.EntityLivingBase import net.minecraft.item.ItemStack import net.minecraft.util.{MovingObjectPosition, ResourceLocation} -import net.minecraftforge.client.model.AdvancedModelLoader import net.minecraftforge.common.util.ForgeDirection import org.lwjgl.opengl.GL11._ import resonantengine.lib.grid.energy.electric.NodeElectricComponent @@ -25,7 +25,6 @@ import scala.collection.convert.wrapAll._ */ object TileLaserReceiver { - @SideOnly(Side.CLIENT) val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "laserReceiver.tcn")) @SideOnly(Side.CLIENT) val texture = new ResourceLocation(Reference.domain, Reference.modelPath + "laserReceiver.png") } @@ -88,7 +87,7 @@ class TileLaserReceiver extends ResonantTile(Material.rock) with ILaserHandler w glRotatef(180, 1, 0, 0) FMLClientHandler.instance.getClient.renderEngine.bindTexture(TileLaserReceiver.texture) - TileLaserReceiver.model.renderAll() + Models.laserreceiver.renderAll() RenderUtility.disableBlending() @@ -104,7 +103,7 @@ class TileLaserReceiver extends ResonantTile(Material.rock) with ILaserHandler w RenderUtility.enableBlending() FMLClientHandler.instance.getClient.renderEngine.bindTexture(TileLaserReceiver.texture) - TileLaserReceiver.model.renderAll() + Models.laserreceiver.renderAll() RenderUtility.disableBlending() diff --git a/src/main/scala/edx/electrical/circuit/component/laser/focus/TileFocusCrystal.scala b/src/main/scala/edx/electrical/circuit/component/laser/focus/TileFocusCrystal.scala index 19ed08abe..9dcab42c4 100644 --- a/src/main/scala/edx/electrical/circuit/component/laser/focus/TileFocusCrystal.scala +++ b/src/main/scala/edx/electrical/circuit/component/laser/focus/TileFocusCrystal.scala @@ -2,6 +2,7 @@ package edx.electrical.circuit.component.laser.focus import cpw.mods.fml.relauncher.{Side, SideOnly} import edx.core.{Electrodynamics, Reference} +import edx.electrical.Models import edx.electrical.circuit.component.laser.{ILaserHandler, Laser} import net.minecraft.block.material.Material import net.minecraft.item.ItemStack @@ -9,7 +10,6 @@ import net.minecraft.nbt.NBTTagCompound import net.minecraft.network.play.server.S35PacketUpdateTileEntity import net.minecraft.network.{NetworkManager, Packet} import net.minecraft.util.{MovingObjectPosition, ResourceLocation} -import net.minecraftforge.client.model.AdvancedModelLoader import net.minecraftforge.common.util.ForgeDirection import org.lwjgl.opengl.GL11._ import resonantengine.lib.render.RenderUtility @@ -23,7 +23,6 @@ import resonantengine.lib.transform.vector.Vector3 */ object TileFocusCrystal { - @SideOnly(Side.CLIENT) val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "focusCrystal.tcn")) @SideOnly(Side.CLIENT) val texture = new ResourceLocation(Reference.domain, Reference.modelPath + "focusCrystal.png") } @@ -132,7 +131,7 @@ class TileFocusCrystal extends TileFocus(Material.rock) with ILaserHandler with RenderUtility.bind(TileFocusCrystal.texture) glTranslatef(0, 0, 0.08f) glScalef(1.3f, 1.3f, 1.3f) - TileFocusCrystal.model.renderAll() + Models.focuscrystal.renderAll() RenderUtility.disableBlending() @@ -148,7 +147,7 @@ class TileFocusCrystal extends TileFocus(Material.rock) with ILaserHandler with glScaled(2.2, 2.2, 2.2) RenderUtility.bind(TileFocusCrystal.texture) - TileFocusCrystal.model.renderAll() + Models.focuscrystal.renderAll() RenderUtility.disableBlending() glPopMatrix() diff --git a/src/main/scala/edx/electrical/circuit/component/laser/focus/TileMirror.scala b/src/main/scala/edx/electrical/circuit/component/laser/focus/TileMirror.scala index 4155e1966..6fc989c0f 100644 --- a/src/main/scala/edx/electrical/circuit/component/laser/focus/TileMirror.scala +++ b/src/main/scala/edx/electrical/circuit/component/laser/focus/TileMirror.scala @@ -3,6 +3,7 @@ package edx.electrical.circuit.component.laser.focus import cpw.mods.fml.client.FMLClientHandler import cpw.mods.fml.relauncher.{Side, SideOnly} import edx.core.{Electrodynamics, Reference} +import edx.electrical.Models import edx.electrical.circuit.component.laser.{ILaserHandler, Laser} import net.minecraft.block.material.Material import net.minecraft.item.ItemStack @@ -10,7 +11,6 @@ import net.minecraft.nbt.NBTTagCompound import net.minecraft.network.play.server.S35PacketUpdateTileEntity import net.minecraft.network.{NetworkManager, Packet} import net.minecraft.util.{MovingObjectPosition, ResourceLocation} -import net.minecraftforge.client.model.AdvancedModelLoader import net.minecraftforge.common.util.ForgeDirection import org.lwjgl.opengl.GL11._ import resonantengine.lib.transform.rotation.Quaternion @@ -20,7 +20,6 @@ import scala.collection.convert.wrapAsJava._ object TileMirror { - @SideOnly(Side.CLIENT) val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "mirror.tcn")) @SideOnly(Side.CLIENT) val texture = new ResourceLocation(Reference.domain, Reference.modelPath + "mirror.png") } @@ -147,7 +146,7 @@ class TileMirror extends TileFocus(Material.glass) with ILaserHandler with IFocu glRotated(angle.yaw, 0, 1, 0) glRotated(angle.pitch, 1, 0, 0) glRotated(90, 1, 0, 0) - TileMirror.model.renderOnly("mirror", "mirrorBacking", "standConnector") + Models.mirror.renderOnly("mirror", "mirrorBacking", "standConnector") glPopMatrix() } @@ -158,7 +157,7 @@ class TileMirror extends TileFocus(Material.glass) with ILaserHandler with IFocu glPushMatrix() FMLClientHandler.instance.getClient.renderEngine.bindTexture(TileMirror.texture) - TileMirror.model.renderAll() + Models.mirror.renderAll() glPopMatrix() } diff --git a/src/main/scala/edx/electrical/circuit/source/TileMotor.scala b/src/main/scala/edx/electrical/circuit/source/TileMotor.scala index 2e7600289..4b4551515 100644 --- a/src/main/scala/edx/electrical/circuit/source/TileMotor.scala +++ b/src/main/scala/edx/electrical/circuit/source/TileMotor.scala @@ -2,12 +2,12 @@ package edx.electrical.circuit.source import cpw.mods.fml.relauncher.{Side, SideOnly} import edx.core.Reference +import edx.electrical.Models import edx.mechanical.mech.grid.NodeMechanical import net.minecraft.block.material.Material import net.minecraft.entity.player.EntityPlayer import net.minecraft.nbt.NBTTagCompound import net.minecraft.util.{ChatComponentText, ResourceLocation} -import net.minecraftforge.client.model.AdvancedModelLoader import net.minecraftforge.common.util.ForgeDirection import org.lwjgl.opengl.GL11 import resonantengine.lib.content.prefab.TIO @@ -24,8 +24,6 @@ import resonantengine.prefab.block.impl.{TBlockNodeProvider, TRotatable} */ object TileMotor { - @SideOnly(Side.CLIENT) - val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "motor.tcn")) @SideOnly(Side.CLIENT) val texture = new ResourceLocation(Reference.domain, Reference.modelPath + "motor.png") @@ -126,7 +124,7 @@ class TileMotor extends ResonantTile(Material.iron) with TIO with TBlockNodeProv GL11.glRotatef(90, 0, 1, 0) RenderUtility.rotateBlockBasedOnDirection(getDirection) RenderUtility.bind(TileMotor.texture) - TileMotor.model.renderAll() + Models.motor.renderAll() GL11.glPopMatrix() } @@ -161,4 +159,4 @@ class TileMotor extends ResonantTile(Material.iron) with TIO with TBlockNodeProv return super.configure(player, side, hit) } -} \ No newline at end of file +} diff --git a/src/main/scala/edx/electrical/circuit/source/battery/TileBattery.scala b/src/main/scala/edx/electrical/circuit/source/battery/TileBattery.scala index 91da7b01d..9830044d2 100644 --- a/src/main/scala/edx/electrical/circuit/source/battery/TileBattery.scala +++ b/src/main/scala/edx/electrical/circuit/source/battery/TileBattery.scala @@ -4,15 +4,14 @@ import java.util.ArrayList import cpw.mods.fml.relauncher.{Side, SideOnly} import edx.core.Reference +import edx.electrical.Models import io.netty.buffer.ByteBuf import net.minecraft.block.material.Material import net.minecraft.client.Minecraft import net.minecraft.entity.EntityLivingBase import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound -import net.minecraft.util.ResourceLocation import net.minecraftforge.client.IItemRenderer.ItemRenderType -import net.minecraftforge.client.model.AdvancedModelLoader import net.minecraftforge.common.util.ForgeDirection import org.lwjgl.opengl.GL11._ import resonantengine.api.item.ISimpleItemRenderer @@ -37,9 +36,6 @@ object TileBattery /** Tiers: 0, 1, 2 */ final val maxTier = 2 - @SideOnly(Side.CLIENT) - val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "battery/battery.tcn")) - /** * @param tier - 0, 1, 2 * @return @@ -172,16 +168,16 @@ class TileBattery extends ResonantTile(Material.iron) with TIO with TBlockNodePr disabledParts ++= Set("coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8") disabledParts ++= Set("coil1lit", "coil2lit", "coil3lit", "coil4lit", "coil5lit", "coil6lit", "coil7lit", "coil8lit") disabledParts ++= Set("frame1con", "frame2con", "frame3con", "frame4con") - TileBattery.model.renderAllExcept(disabledParts.toList: _*) + Models.battery.renderAllExcept(disabledParts.toList: _*) for (i <- 1 until 8) { if (i != 1 || !disabledParts.contains("coil1")) { if ((8 - i) <= energyLevel) - TileBattery.model.renderOnly("coil" + i + "lit") + Models.battery.renderOnly("coil" + i + "lit") else - TileBattery.model.renderOnly("coil" + i) + Models.battery.renderOnly("coil" + i) } } glPopMatrix() @@ -229,8 +225,8 @@ class TileBattery extends ResonantTile(Material.iron) with TIO with TBlockNodePr getIO(check) match { - case 1 => TileBattery.model.renderOnly("connectorIn") - case 2 => TileBattery.model.renderOnly("connectorOut") + case 1 => Models.battery.renderOnly("connectorIn") + case 2 => Models.battery.renderOnly("connectorOut") case _ => } @@ -245,9 +241,9 @@ class TileBattery extends ResonantTile(Material.iron) with TIO with TBlockNodePr if (i != 1 || enabledParts.contains("coil1")) { if ((8 - i) < energyRenderLevel) - TileBattery.model.renderOnly("coil" + i + "lit") + Models.battery.renderOnly("coil" + i + "lit") else - TileBattery.model.renderOnly("coil" + i) + Models.battery.renderOnly("coil" + i) } } @@ -256,8 +252,8 @@ class TileBattery extends ResonantTile(Material.iron) with TIO with TBlockNodePr disabledParts ++= Set("coil1lit", "coil2lit", "coil3lit", "coil4lit", "coil5lit", "coil6lit", "coil7lit", "coil8lit") disabledParts ++= Set("frame1con", "frame2con", "frame3con", "frame4con") enabledParts --= Set("coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8") - TileBattery.model.renderAllExcept(disabledParts.toList: _*) - TileBattery.model.renderOnly(enabledParts.toList: _*) + Models.battery.renderAllExcept(disabledParts.toList: _*) + Models.battery.renderOnly(enabledParts.toList: _*) /** * Render energy tooltip diff --git a/src/main/scala/edx/mechanical/Models.java b/src/main/scala/edx/mechanical/Models.java new file mode 100644 index 000000000..5a75bc8b2 --- /dev/null +++ b/src/main/scala/edx/mechanical/Models.java @@ -0,0 +1,18 @@ +package edx.mechanical; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import edx.core.Reference; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.AdvancedModelLoader; +import net.minecraftforge.client.model.IModelCustom; + +@SideOnly(Side.CLIENT) +public class Models { + + public static IModelCustom pump = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "pump.tcn")); + public static IModelCustom grinder = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "grinder.obj")); + public static IModelCustom mixer = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "mixer.tcn")); + public static IModelCustom wind = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "windTurbines.obj")); + +} diff --git a/src/main/scala/edx/mechanical/fluid/transport/TilePump.scala b/src/main/scala/edx/mechanical/fluid/transport/TilePump.scala index 1692f97b3..8684d012c 100644 --- a/src/main/scala/edx/mechanical/fluid/transport/TilePump.scala +++ b/src/main/scala/edx/mechanical/fluid/transport/TilePump.scala @@ -1,10 +1,10 @@ package edx.mechanical.fluid.transport import edx.core.Reference +import edx.mechanical.Models import edx.mechanical.mech.TileMechanical import net.minecraft.block.material.Material import net.minecraft.util.ResourceLocation -import net.minecraftforge.client.model.AdvancedModelLoader import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.fluids.{Fluid, FluidStack, FluidTankInfo, IFluidHandler} import org.lwjgl.opengl.GL11 @@ -16,7 +16,6 @@ import scala.collection.mutable object TilePump { - val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "pump.tcn")) val texture = new ResourceLocation(Reference.domain, Reference.modelPath + "pump.png") } @@ -79,11 +78,11 @@ class TilePump extends TileMechanical(Material.iron) with IRotatable with IFluid val innerFin: String = "innerFin" + i notRendered.add(fin) notRendered.add(innerFin) - TilePump.model.renderOnly(fin, innerFin) + Models.pump.renderOnly(fin, innerFin) } GL11.glPopMatrix() - TilePump.model.renderAllExcept(notRendered.toArray[String]: _*) + Models.pump.renderAllExcept(notRendered.toArray[String]: _*) GL11.glPopMatrix() } diff --git a/src/main/scala/edx/mechanical/mech/process/grinder/TileGrindingWheel.scala b/src/main/scala/edx/mechanical/mech/process/grinder/TileGrindingWheel.scala index 7993c1972..6a61675e8 100644 --- a/src/main/scala/edx/mechanical/mech/process/grinder/TileGrindingWheel.scala +++ b/src/main/scala/edx/mechanical/mech/process/grinder/TileGrindingWheel.scala @@ -1,14 +1,13 @@ package edx.mechanical.mech.process.grinder -import cpw.mods.fml.relauncher.{Side, SideOnly} import edx.core.{Electrodynamics, Reference} +import edx.mechanical.Models import edx.mechanical.mech.TileMechanical import net.minecraft.block.material.Material import net.minecraft.entity.Entity import net.minecraft.entity.item.EntityItem import net.minecraft.item.{ItemBlock, ItemStack} -import net.minecraft.util.{DamageSource, ResourceLocation} -import net.minecraftforge.client.model.AdvancedModelLoader +import net.minecraft.util.DamageSource import net.minecraftforge.common.util.ForgeDirection import org.lwjgl.opengl.GL11._ import resonantengine.api.edx.recipe.{MachineRecipes, RecipeType} @@ -30,8 +29,6 @@ object TileGrindingWheel */ final val grindingTimer = new Timer[EntityItem] - @SideOnly(Side.CLIENT) - final val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "grinder.obj")) } class TileGrindingWheel extends TileMechanical(Material.rock) @@ -203,9 +200,9 @@ class TileGrindingWheel extends TileMechanical(Material.rock) RenderUtility.rotateBlockBasedOnDirection(dir) glRotated(Math.toDegrees(mechanicalNode.angle), 0, 0, 1) RenderUtility.bind(Reference.blockTextureDirectory + "planks_oak.png") - TileGrindingWheel.model.renderAllExcept("teeth") + Models.grinder.renderAllExcept("teeth") RenderUtility.bind(Reference.blockTextureDirectory + "cobblestone.png") - TileGrindingWheel.model.renderOnly("teeth") + Models.grinder.renderOnly("teeth") glPopMatrix() } } diff --git a/src/main/scala/edx/mechanical/mech/process/mixer/TileMixer.scala b/src/main/scala/edx/mechanical/mech/process/mixer/TileMixer.scala index adde05064..e25e84665 100644 --- a/src/main/scala/edx/mechanical/mech/process/mixer/TileMixer.scala +++ b/src/main/scala/edx/mechanical/mech/process/mixer/TileMixer.scala @@ -11,7 +11,6 @@ import net.minecraft.entity.Entity import net.minecraft.entity.item.EntityItem import net.minecraft.item.ItemStack import net.minecraft.util.{AxisAlignedBB, ResourceLocation} -import net.minecraftforge.client.model.{AdvancedModelLoader, IModelCustom} import net.minecraftforge.fluids.IFluidBlock import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL11._ @@ -30,7 +29,6 @@ object TileMixer { final val PROCESS_TIME: Int = 12 * 20 final val MIXER_ITEM_TIMER: Timer[EntityItem] = new Timer[EntityItem] - @SideOnly(Side.CLIENT) val MODEL: IModelCustom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "mixer.tcn")) @SideOnly(Side.CLIENT) var TEXTURE: ResourceLocation = new ResourceLocation(Reference.domain, Reference.modelPath + "mixer.png") } diff --git a/src/main/scala/edx/mechanical/mech/turbine/TileWindTurbine.scala b/src/main/scala/edx/mechanical/mech/turbine/TileWindTurbine.scala index 80151c47c..24165a8e5 100644 --- a/src/main/scala/edx/mechanical/mech/turbine/TileWindTurbine.scala +++ b/src/main/scala/edx/mechanical/mech/turbine/TileWindTurbine.scala @@ -4,13 +4,12 @@ import java.util.List import cpw.mods.fml.relauncher.{Side, SideOnly} import edx.core.{Reference, Settings} +import edx.mechanical.Models import net.minecraft.creativetab.CreativeTabs import net.minecraft.init.{Blocks, Items} import net.minecraft.item.{Item, ItemStack} import net.minecraft.nbt.NBTTagCompound -import net.minecraft.util.ResourceLocation import net.minecraft.world.biome.{BiomeGenBase, BiomeGenOcean, BiomeGenPlains} -import net.minecraftforge.client.model.AdvancedModelLoader import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.fluids.{Fluid, FluidStack, FluidTank, FluidTankInfo} import org.lwjgl.opengl.GL11 @@ -23,18 +22,6 @@ import resonantengine.lib.wrapper.CollectionWrapper._ import resonantengine.lib.wrapper.NBTWrapper._ import resonantengine.prefab.block.itemblock.ItemBlockMetadata -/** - * The vertical wind turbine collects airflow. - * - * The horizontal wind turbine collects steam from steam power plants. - * - * @author Calclavia - */ -object TileWindTurbine -{ - @SideOnly(Side.CLIENT) - val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "windTurbines.obj")) -} class TileWindTurbine extends TileTurbine with IBoilHandler { @@ -227,24 +214,24 @@ class TileWindTurbine extends TileTurbine with IBoilHandler if (tier == 2) { GL11.glTranslatef(0, -0.11f, 0) - TileWindTurbine.model.renderOnly("LargeMetalBlade") - TileWindTurbine.model.renderOnly("LargeMetalHub") + Models.wind.renderOnly("LargeMetalBlade") + Models.wind.renderOnly("LargeMetalHub") } else { - TileWindTurbine.model.renderOnly("LargeBladeArm") + Models.wind.renderOnly("LargeBladeArm") GL11.glScalef(1f, 2f, 1f) GL11.glTranslatef(0, -0.05f, 0) - TileWindTurbine.model.renderOnly("LargeHub") + Models.wind.renderOnly("LargeHub") RenderUtility.bind(Reference.blockTextureDirectory + "wool_colored_white.png") - TileWindTurbine.model.renderOnly("LargeBlade") + Models.wind.renderOnly("LargeBlade") } } else { - TileWindTurbine.model.renderOnly("SmallBlade") + Models.wind.renderOnly("SmallBlade") RenderUtility.bind(Reference.blockTextureDirectory + "log_oak.png") - TileWindTurbine.model.renderOnly("SmallHub") + Models.wind.renderOnly("SmallHub") } } } diff --git a/src/main/scala/edx/quantum/Models.java b/src/main/scala/edx/quantum/Models.java new file mode 100644 index 000000000..c4569364f --- /dev/null +++ b/src/main/scala/edx/quantum/Models.java @@ -0,0 +1,17 @@ +package edx.quantum; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import edx.core.Reference; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.AdvancedModelLoader; +import net.minecraftforge.client.model.IModelCustom; + +@SideOnly(Side.CLIENT) +public class Models { + + public static IModelCustom cellTop = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellTop.tcn")); + public static IModelCustom cellMiddle = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellMiddle.tcn")); + public static IModelCustom cellBottom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellBottom.tcn")); + +} diff --git a/src/main/scala/edx/quantum/reactor/TileReactorCell.scala b/src/main/scala/edx/quantum/reactor/TileReactorCell.scala index 2c2c2b0cf..ec0f6c58c 100644 --- a/src/main/scala/edx/quantum/reactor/TileReactorCell.scala +++ b/src/main/scala/edx/quantum/reactor/TileReactorCell.scala @@ -5,7 +5,7 @@ import java.util.List import cpw.mods.fml.relauncher.{Side, SideOnly} import edx.core.{Electrodynamics, Reference} -import edx.quantum.QuantumContent +import edx.quantum.{Models, QuantumContent} import net.minecraft.block.Block import net.minecraft.block.material.Material import net.minecraft.entity.EntityLiving @@ -16,7 +16,6 @@ import net.minecraft.nbt.NBTTagCompound import net.minecraft.tileentity.TileEntity import net.minecraft.util.{AxisAlignedBB, ResourceLocation} import net.minecraft.world.World -import net.minecraftforge.client.model.AdvancedModelLoader import net.minecraftforge.common.util.ForgeDirection import org.lwjgl.opengl.GL11 import resonantengine.api.edx.machine.{IReactor, IReactorComponent} @@ -42,9 +41,6 @@ object TileReactorCell final val specificHeatCapacity = 1000 final val mass = ThermalPhysics.getMass(1000, 7) - final val modelTop = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellTop.tcn")) - final val modelMiddle = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellMiddle.tcn")) - final val modelBottom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellBottom.tcn")) final val textureTop = new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellTop.png") final val textureMiddle = new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellMiddle.png") final val textureBottom = new ResourceLocation(Reference.domain, Reference.modelPath + "reactorCellBottom.png") @@ -345,14 +341,14 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc if (meta == 0) { RenderUtility.bind(TileReactorCell.textureBottom) - TileReactorCell.modelBottom.renderAll() + Models.cellBottom.renderAll() } else if (meta == 1) { RenderUtility.bind(TileReactorCell.textureMiddle) GL11.glTranslatef(0, 0.075f, 0) GL11.glScalef(1f, 1.15f, 1f) - TileReactorCell.modelMiddle.renderAll() + Models.cellMiddle.renderAll() } else { @@ -370,11 +366,11 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc if (hasBelow) { - TileReactorCell.modelTop.renderAllExcept("BottomPad", "BaseDepth", "BaseWidth", "Base") + Models.cellTop.renderAllExcept("BottomPad", "BaseDepth", "BaseWidth", "Base") } else { - TileReactorCell.modelTop.renderAll() + Models.cellTop.renderAll() } } GL11.glPopMatrix()