diff --git a/gradle.properties b/gradle.properties index 169f8a41f..4d40ab766 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ mcversion=1.11.2 -forgeversion=13.20.0.2207 +forgeversion=13.20.0.2230 mcp_mappings=snapshot_20161220 tesla_version=1.11-1.3.0.51 diff --git a/src/main/java/forestry/Forestry.java b/src/main/java/forestry/Forestry.java index 8a886601b..f9c4f7b70 100644 --- a/src/main/java/forestry/Forestry.java +++ b/src/main/java/forestry/Forestry.java @@ -54,7 +54,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry; version = Constants.VERSION, guiFactory = "forestry.core.config.ForestryGuiConfigFactory", acceptedMinecraftVersions = "[1.11]", - dependencies = "required-after:forge@[13.19.1.2189,);" + dependencies = "required-after:forge@[13.20.0.2230,);" + "after:JEI@[4.1.1,);") // + "after:" + PluginIC2.modId + ";") public class Forestry { @@ -101,7 +101,7 @@ public class Forestry { Preconditions.checkState(gameMode != null); ForestryAPI.activeMode = new GameMode(gameMode); - PluginManager.runPreInit(); + PluginManager.runPreInit(event.getSide()); Proxies.render.registerModels(); } diff --git a/src/main/java/forestry/api/apiculture/IAlleleBeeEffect.java b/src/main/java/forestry/api/apiculture/IAlleleBeeEffect.java index c3215e925..9a5d76bb8 100644 --- a/src/main/java/forestry/api/apiculture/IAlleleBeeEffect.java +++ b/src/main/java/forestry/api/apiculture/IAlleleBeeEffect.java @@ -7,6 +7,8 @@ package forestry.api.apiculture; import forestry.api.genetics.IAlleleEffect; import forestry.api.genetics.IEffectData; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IAlleleBeeEffect extends IAlleleEffect { @@ -28,6 +30,7 @@ public interface IAlleleBeeEffect extends IAlleleEffect { * @param housing {@link IBeeHousing} the bee currently resides in. * @return storedData, may have been manipulated. */ + @SideOnly(Side.CLIENT) IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing); } diff --git a/src/main/java/forestry/api/apiculture/IBee.java b/src/main/java/forestry/api/apiculture/IBee.java index f51c085aa..d2218493f 100644 --- a/src/main/java/forestry/api/apiculture/IBee.java +++ b/src/main/java/forestry/api/apiculture/IBee.java @@ -16,6 +16,8 @@ import forestry.api.genetics.IIndividualLiving; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.world.biome.Biome; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * Other implementations than Forestry's default one are not supported. @@ -54,6 +56,7 @@ public interface IBee extends IIndividualLiving { IEffectData[] doEffect(IEffectData[] storedData, IBeeHousing housing); + @SideOnly(Side.CLIENT) IEffectData[] doFX(IEffectData[] storedData, IBeeHousing housing); /** diff --git a/src/main/java/forestry/api/apiculture/IBeekeepingLogic.java b/src/main/java/forestry/api/apiculture/IBeekeepingLogic.java index 4f2584f91..48a38d1d7 100644 --- a/src/main/java/forestry/api/apiculture/IBeekeepingLogic.java +++ b/src/main/java/forestry/api/apiculture/IBeekeepingLogic.java @@ -13,6 +13,8 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * Stores beekeeping logic for bee housings. @@ -62,12 +64,14 @@ public interface IBeekeepingLogic extends INbtWritable, INbtReadable { * Whether bee fx should be active. * Internally, this is automatically synced to the client. */ + @SideOnly(Side.CLIENT) boolean canDoBeeFX(); /** * Display bee fx. Calls IBee.doFX(IEffectData[] storedData, IBeeHousing housing) on the queen. * Internally, the queen is automatically synced to the client for the fx. */ + @SideOnly(Side.CLIENT) void doBeeFX(); /** diff --git a/src/main/java/forestry/api/arboriculture/IGermlingModelProvider.java b/src/main/java/forestry/api/arboriculture/IGermlingModelProvider.java index fe127fdf2..ccea41e57 100644 --- a/src/main/java/forestry/api/arboriculture/IGermlingModelProvider.java +++ b/src/main/java/forestry/api/arboriculture/IGermlingModelProvider.java @@ -20,6 +20,7 @@ public interface IGermlingModelProvider { @SideOnly(Side.CLIENT) void registerModels(Item item, IModelManager manager, EnumGermlingType type); + @SideOnly(Side.CLIENT) ModelResourceLocation getModel(EnumGermlingType type); /** diff --git a/src/main/java/forestry/api/arboriculture/ITree.java b/src/main/java/forestry/api/arboriculture/ITree.java index ee9a29a0b..6dc43e6fe 100644 --- a/src/main/java/forestry/api/arboriculture/ITree.java +++ b/src/main/java/forestry/api/arboriculture/ITree.java @@ -19,6 +19,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface ITree extends IIndividual, ITreeGenData { @@ -26,6 +28,7 @@ public interface ITree extends IIndividual, ITreeGenData { IEffectData[] doEffect(IEffectData[] storedData, World world, BlockPos pos); + @SideOnly(Side.CLIENT) IEffectData[] doFX(IEffectData[] storedData, World world, BlockPos pos); @Override diff --git a/src/main/java/forestry/api/circuits/ICircuitBoard.java b/src/main/java/forestry/api/circuits/ICircuitBoard.java index 7ed2b4962..0157492ef 100644 --- a/src/main/java/forestry/api/circuits/ICircuitBoard.java +++ b/src/main/java/forestry/api/circuits/ICircuitBoard.java @@ -8,13 +8,17 @@ package forestry.api.circuits; import java.util.List; import forestry.api.core.INbtWritable; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface ICircuitBoard extends INbtWritable { - + @SideOnly(Side.CLIENT) int getPrimaryColor(); + @SideOnly(Side.CLIENT) int getSecondaryColor(); + @SideOnly(Side.CLIENT) void addTooltip(List list); void onInsertion(Object tile); diff --git a/src/main/java/forestry/api/core/ITextureManager.java b/src/main/java/forestry/api/core/ITextureManager.java index 6e12fee3f..9ba81e871 100644 --- a/src/main/java/forestry/api/core/ITextureManager.java +++ b/src/main/java/forestry/api/core/ITextureManager.java @@ -6,6 +6,7 @@ package forestry.api.core; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -18,7 +19,7 @@ public interface ITextureManager { /** * Location of the Forestry Gui Texture Map. - * Used for binding with {@link net.minecraft.client.renderer.texture.TextureManager#bindTexture(ResourceLocation)} + * Used for binding with {@link TextureManager#bindTexture(ResourceLocation)} */ ResourceLocation getGuiTextureMap(); diff --git a/src/main/java/forestry/api/multiblock/MultiblockTileEntityBase.java b/src/main/java/forestry/api/multiblock/MultiblockTileEntityBase.java index 9df5cc248..5f1d87a21 100644 --- a/src/main/java/forestry/api/multiblock/MultiblockTileEntityBase.java +++ b/src/main/java/forestry/api/multiblock/MultiblockTileEntityBase.java @@ -10,6 +10,8 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * Base logic class for Multiblock-connected tile entities. @@ -86,6 +88,7 @@ public abstract class MultiblockTileEntityBase exten } @Override + @SideOnly(Side.CLIENT) public final void onDataPacket(NetworkManager network, SPacketUpdateTileEntity packet) { super.onDataPacket(network, packet); NBTTagCompound nbtData = packet.getNbtCompound(); diff --git a/src/main/java/forestry/apiculture/BeekeepingLogic.java b/src/main/java/forestry/apiculture/BeekeepingLogic.java index f0357d15b..2f7b042a4 100644 --- a/src/main/java/forestry/apiculture/BeekeepingLogic.java +++ b/src/main/java/forestry/apiculture/BeekeepingLogic.java @@ -40,8 +40,9 @@ import forestry.core.config.Constants; import forestry.core.errors.EnumErrorCode; import forestry.core.network.IStreamable; import forestry.core.network.PacketBufferForestry; -import forestry.core.proxy.Proxies; import forestry.core.utils.Log; +import forestry.core.utils.NetworkUtil; +import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -50,6 +51,8 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class BeekeepingLogic implements IBeekeepingLogic, IStreamable { @@ -457,9 +460,9 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable { if (world != null && !world.isRemote) { if (housing instanceof Entity) { Entity housingEntity = (Entity) this.housing; - Proxies.net.sendNetworkPacket(new PacketBeeLogicActiveEntity(this.housing, housingEntity), housingEntity.getPosition(), world); + NetworkUtil.sendNetworkPacket(new PacketBeeLogicActiveEntity(this.housing, housingEntity), housingEntity.getPosition(), world); } else { - Proxies.net.sendNetworkPacket(new PacketBeeLogicActive(housing), housing.getCoordinates(), world); + NetworkUtil.sendNetworkPacket(new PacketBeeLogicActive(housing), housing.getCoordinates(), world); } } } @@ -469,9 +472,9 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable { World world = housing.getWorldObj(); if (world != null && !world.isRemote) { if (housing instanceof TileEntity) { - Proxies.net.sendToPlayer(new PacketBeeLogicActive(housing), player); + NetworkUtil.sendToPlayer(new PacketBeeLogicActive(housing), player); } else if (housing instanceof Entity) { - Proxies.net.sendToPlayer(new PacketBeeLogicActiveEntity(housing, (Entity) housing), player); + NetworkUtil.sendToPlayer(new PacketBeeLogicActiveEntity(housing, (Entity) housing), player); } } } @@ -486,11 +489,13 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable { } @Override + @SideOnly(Side.CLIENT) public boolean canDoBeeFX() { - return !Proxies.common.getClientInstance().isGamePaused() && active; + return !Minecraft.getMinecraft().isGamePaused() && active; } @Override + @SideOnly(Side.CLIENT) public void doBeeFX() { if (queen != null) { queen.doFX(effectData, housing); @@ -498,7 +503,6 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable { } @Override - public List getFlowerPositions() { return hasFlowersCache.getFlowerCoords(); } diff --git a/src/main/java/forestry/apiculture/PluginApiculture.java b/src/main/java/forestry/apiculture/PluginApiculture.java index 9f8132517..1438cfaee 100644 --- a/src/main/java/forestry/apiculture/PluginApiculture.java +++ b/src/main/java/forestry/apiculture/PluginApiculture.java @@ -65,8 +65,6 @@ import forestry.apiculture.multiblock.TileAlvearySieve; import forestry.apiculture.multiblock.TileAlvearyStabiliser; import forestry.apiculture.multiblock.TileAlvearySwarmer; import forestry.apiculture.network.PacketRegistryApiculture; -import forestry.apiculture.proxy.ProxyApiculture; -import forestry.apiculture.proxy.ProxyApicultureClient; import forestry.apiculture.tiles.TileCandle; import forestry.apiculture.tiles.TileHive; import forestry.apiculture.worldgen.HiveDecorator; @@ -99,6 +97,7 @@ import forestry.plugins.ForestryPlugin; import forestry.plugins.ForestryPluginUids; import net.minecraft.block.BlockFlower; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -117,7 +116,6 @@ import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; @@ -127,21 +125,21 @@ import net.minecraftforge.fml.relauncher.SideOnly; @ForestryPlugin(pluginID = ForestryPluginUids.APICULTURE, name = "Apiculture", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.apiculture.description") public class PluginApiculture extends BlankForestryPlugin { - - @SuppressWarnings("NullableProblems") - @SidedProxy(clientSide = "forestry.apiculture.proxy.ProxyApicultureClient", serverSide = "forestry.apiculture.proxy.ProxyApiculture") - public static ProxyApiculture proxy; private static final String CONFIG_CATEGORY = "apiculture"; - public static String beekeepingMode = "NORMAL"; private static float secondPrincessChance = 0; - public static final int ticksPerBeeWorkCycle = 550; + @SideOnly(Side.CLIENT) + @Nullable + private static TextureAtlasSprite beeSprite; @Nullable private static ItemRegistryApiculture items; @Nullable private static BlockRegistryApiculture blocks; @Nullable private static HiveRegistry hiveRegistry; + + public static String beekeepingMode = "NORMAL"; + public static final int ticksPerBeeWorkCycle = 550; @Nullable public static VillagerRegistry.VillagerProfession villagerApiarist; @@ -160,6 +158,12 @@ public class PluginApiculture extends BlankForestryPlugin { return hiveRegistry; } + @SideOnly(Side.CLIENT) + public static TextureAtlasSprite getBeeSprite() { + Preconditions.checkState(beeSprite != null, "Bee sprite has not been registered"); + return beeSprite; + } + @Override public void setupAPI() { super.setupAPI(); @@ -901,7 +905,7 @@ public class PluginApiculture extends BlankForestryPlugin { for (int i = 0; i < ParticleSnow.sprites.length; i++) { ParticleSnow.sprites[i] = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/snow." + (i + 1))); } - ProxyApicultureClient.beeSprite = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/swarm_bee")); + beeSprite = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/swarm_bee")); } private static class EndFlowerAcceptableRule implements IFlowerAcceptableRule { diff --git a/src/main/java/forestry/apiculture/blocks/BlockAlveary.java b/src/main/java/forestry/apiculture/blocks/BlockAlveary.java index 68a9ede4c..d7f6281f9 100644 --- a/src/main/java/forestry/apiculture/blocks/BlockAlveary.java +++ b/src/main/java/forestry/apiculture/blocks/BlockAlveary.java @@ -31,10 +31,10 @@ import forestry.apiculture.multiblock.TileAlvearyStabiliser; import forestry.apiculture.multiblock.TileAlvearySwarmer; import forestry.apiculture.network.packets.PacketAlvearyChange; import forestry.core.blocks.BlockStructure; -import forestry.core.proxy.Proxies; import forestry.core.tiles.IActivatable; import forestry.core.tiles.TileUtil; import forestry.core.utils.BlockUtil; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.Translator; import net.minecraft.block.Block; import net.minecraft.block.SoundType; @@ -52,6 +52,7 @@ import net.minecraft.util.IStringSerializable; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -224,7 +225,7 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe @Override @SideOnly(Side.CLIENT) public void registerStateMapper() { - Proxies.render.registerStateMapper(this, new AlvearyStateMapper(getAlvearyType())); + ModelLoader.setCustomStateMapper(this, new AlvearyStateMapper(getAlvearyType())); } @SideOnly(Side.CLIENT) @@ -255,7 +256,7 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe IAlvearyControllerInternal alveary = tileAlveary.getMultiblockLogic().getController(); alveary.reassemble(); BlockPos referenceCoord = alveary.getReferenceCoord(); - Proxies.net.sendNetworkPacket(new PacketAlvearyChange(referenceCoord), referenceCoord, worldIn); + NetworkUtil.sendNetworkPacket(new PacketAlvearyChange(referenceCoord), referenceCoord, worldIn); } } diff --git a/src/main/java/forestry/apiculture/blocks/BlockCandle.java b/src/main/java/forestry/apiculture/blocks/BlockCandle.java index d7d00aace..bef9a83d7 100644 --- a/src/main/java/forestry/apiculture/blocks/BlockCandle.java +++ b/src/main/java/forestry/apiculture/blocks/BlockCandle.java @@ -297,6 +297,7 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile } @Override + @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { TileCandle tileCandle = TileUtil.getTile(worldIn, pos, TileCandle.class); if (tileCandle != null && tileCandle.isLit()) { diff --git a/src/main/java/forestry/apiculture/blocks/BlockTypeApicultureTesr.java b/src/main/java/forestry/apiculture/blocks/BlockTypeApicultureTesr.java index 2008317b1..61ca639a4 100644 --- a/src/main/java/forestry/apiculture/blocks/BlockTypeApicultureTesr.java +++ b/src/main/java/forestry/apiculture/blocks/BlockTypeApicultureTesr.java @@ -10,28 +10,26 @@ ******************************************************************************/ package forestry.apiculture.blocks; -import javax.annotation.Nullable; - import forestry.apiculture.tiles.TileApiaristChest; import forestry.core.blocks.IBlockTypeTesr; import forestry.core.blocks.IMachinePropertiesTesr; import forestry.core.blocks.MachinePropertiesTesr; import forestry.core.config.Constants; import forestry.core.proxy.Proxies; -import forestry.core.tiles.TileForestry; import forestry.core.tiles.TileNaturalistChest; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.util.math.AxisAlignedBB; public enum BlockTypeApicultureTesr implements IBlockTypeTesr { - APIARIST_CHEST(TileApiaristChest.class, "api_chest", Proxies.render.getRenderChest("apiaristchest"), TileNaturalistChest.chestBoundingBox); + APIARIST_CHEST(TileApiaristChest.class, "api_chest", "apiaristchest", TileNaturalistChest.chestBoundingBox); public static final BlockTypeApicultureTesr[] VALUES = values(); private final IMachinePropertiesTesr machineProperties; - BlockTypeApicultureTesr(Class teClass, String name, @Nullable TileEntitySpecialRenderer renderer, AxisAlignedBB boundingBox) { - this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0", false); + BlockTypeApicultureTesr(Class teClass, String name, String textureName, AxisAlignedBB boundingBox) { + MachinePropertiesTesr machineProperties = new MachinePropertiesTesr<>(teClass, name, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0", false); + Proxies.render.setRenderChest(machineProperties, textureName); + this.machineProperties = machineProperties; } @Override diff --git a/src/main/java/forestry/apiculture/entities/EntityMinecartApiary.java b/src/main/java/forestry/apiculture/entities/EntityMinecartApiary.java index 33e5590f8..eb8cc7006 100644 --- a/src/main/java/forestry/apiculture/entities/EntityMinecartApiary.java +++ b/src/main/java/forestry/apiculture/entities/EntityMinecartApiary.java @@ -29,9 +29,13 @@ import forestry.apiculture.inventory.IApiaryInventory; import forestry.apiculture.inventory.InventoryApiary; import forestry.core.inventory.IInventoryAdapter; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implements IApiary { @@ -98,13 +102,14 @@ public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implement } @Override - public Object getGui(EntityPlayer player, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, int data) { ContainerMinecartBeehouse container = new ContainerMinecartBeehouse(player.inventory, this, true); return new GuiBeeHousing<>(this, container, GuiBeeHousing.Icon.APIARY); } @Override - public Object getContainer(EntityPlayer player, int data) { + public Container getContainer(EntityPlayer player, int data) { return new ContainerMinecartBeehouse(player.inventory, this, true); } } diff --git a/src/main/java/forestry/apiculture/entities/EntityMinecartBeeHousingBase.java b/src/main/java/forestry/apiculture/entities/EntityMinecartBeeHousingBase.java index db0742b09..708ff0465 100644 --- a/src/main/java/forestry/apiculture/entities/EntityMinecartBeeHousingBase.java +++ b/src/main/java/forestry/apiculture/entities/EntityMinecartBeeHousingBase.java @@ -33,9 +33,9 @@ import forestry.core.owner.GameProfileDataSerializer; import forestry.core.owner.IOwnedTile; import forestry.core.owner.IOwnerHandler; import forestry.core.owner.OwnerHandler; -import forestry.core.proxy.Proxies; import forestry.core.tiles.IClimatised; import forestry.core.utils.ClimateUtil; +import forestry.core.utils.NetworkUtil; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.EntityDataManager; @@ -191,7 +191,7 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain } else { if (needsActiveUpdate) { IForestryPacketServer packet = new PacketBeeLogicEntityRequest(this); - Proxies.net.sendToServer(packet); + NetworkUtil.sendToServer(packet); needsActiveUpdate = false; } diff --git a/src/main/java/forestry/apiculture/entities/EntityMinecartBeehouse.java b/src/main/java/forestry/apiculture/entities/EntityMinecartBeehouse.java index 6d9ce7035..5dc8d5a73 100644 --- a/src/main/java/forestry/apiculture/entities/EntityMinecartBeehouse.java +++ b/src/main/java/forestry/apiculture/entities/EntityMinecartBeehouse.java @@ -23,9 +23,13 @@ import forestry.apiculture.gui.ContainerMinecartBeehouse; import forestry.apiculture.gui.GuiBeeHousing; import forestry.core.inventory.IInventoryAdapter; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class EntityMinecartBeehouse extends EntityMinecartBeeHousingBase { private static final IBeeModifier beeModifier = new BeehouseBeeModifier(); @@ -80,13 +84,14 @@ public class EntityMinecartBeehouse extends EntityMinecartBeeHousingBase { } @Override - public Object getGui(EntityPlayer player, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, int data) { ContainerMinecartBeehouse container = new ContainerMinecartBeehouse(player.inventory, this, false); return new GuiBeeHousing<>(this, container, GuiBeeHousing.Icon.BEE_HOUSE); } @Override - public Object getContainer(EntityPlayer player, int data) { + public Container getContainer(EntityPlayer player, int data) { return new ContainerMinecartBeehouse(player.inventory, this, false); } } diff --git a/src/main/java/forestry/apiculture/entities/ParticleBeeExplore.java b/src/main/java/forestry/apiculture/entities/ParticleBeeExplore.java index b63e871b2..5e5d130be 100644 --- a/src/main/java/forestry/apiculture/entities/ParticleBeeExplore.java +++ b/src/main/java/forestry/apiculture/entities/ParticleBeeExplore.java @@ -10,7 +10,7 @@ ******************************************************************************/ package forestry.apiculture.entities; -import forestry.apiculture.proxy.ProxyApicultureClient; +import forestry.apiculture.PluginApiculture; import net.minecraft.client.particle.Particle; import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.entity.Entity; @@ -23,7 +23,7 @@ public class ParticleBeeExplore extends Particle { public ParticleBeeExplore(World world, Vec3d origin, BlockPos destination, int color) { super(world, origin.xCoord, origin.yCoord, origin.zCoord, 0.0D, 0.0D, 0.0D); - setParticleTexture(ProxyApicultureClient.beeSprite); + setParticleTexture(PluginApiculture.getBeeSprite()); this.origin = origin; this.motionX = (destination.getX() + 0.5 - this.posX) * 0.015; diff --git a/src/main/java/forestry/apiculture/entities/ParticleBeeRoundTrip.java b/src/main/java/forestry/apiculture/entities/ParticleBeeRoundTrip.java index 9ef7ae414..58b042476 100644 --- a/src/main/java/forestry/apiculture/entities/ParticleBeeRoundTrip.java +++ b/src/main/java/forestry/apiculture/entities/ParticleBeeRoundTrip.java @@ -10,7 +10,7 @@ ******************************************************************************/ package forestry.apiculture.entities; -import forestry.apiculture.proxy.ProxyApicultureClient; +import forestry.apiculture.PluginApiculture; import net.minecraft.client.particle.Particle; import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.entity.Entity; @@ -24,7 +24,7 @@ public class ParticleBeeRoundTrip extends Particle { public ParticleBeeRoundTrip(World world, Vec3d origin, BlockPos destination, int color) { super(world, origin.xCoord, origin.yCoord, origin.zCoord, 0.0D, 0.0D, 0.0D); - setParticleTexture(ProxyApicultureClient.beeSprite); + setParticleTexture(PluginApiculture.getBeeSprite()); this.origin = origin; this.destination = destination; diff --git a/src/main/java/forestry/apiculture/entities/ParticleBeeTargetEntity.java b/src/main/java/forestry/apiculture/entities/ParticleBeeTargetEntity.java index d31e595e7..416e616d2 100644 --- a/src/main/java/forestry/apiculture/entities/ParticleBeeTargetEntity.java +++ b/src/main/java/forestry/apiculture/entities/ParticleBeeTargetEntity.java @@ -10,7 +10,7 @@ ******************************************************************************/ package forestry.apiculture.entities; -import forestry.apiculture.proxy.ProxyApicultureClient; +import forestry.apiculture.PluginApiculture; import net.minecraft.client.particle.Particle; import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.entity.Entity; @@ -23,7 +23,7 @@ public class ParticleBeeTargetEntity extends Particle { public ParticleBeeTargetEntity(World world, Vec3d origin, Entity entity, int color) { super(world, origin.xCoord, origin.yCoord, origin.zCoord, 0.0D, 0.0D, 0.0D); - setParticleTexture(ProxyApicultureClient.beeSprite); + setParticleTexture(PluginApiculture.getBeeSprite()); this.origin = origin; this.entity = entity; diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index ef163640c..a6fec4099 100644 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -65,6 +65,8 @@ import net.minecraft.util.math.Vec3i; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class Bee extends IndividualLiving implements IBee { @@ -182,6 +184,7 @@ public class Bee extends IndividualLiving implements IBee { } @Override + @SideOnly(Side.CLIENT) public IEffectData[] doFX(IEffectData[] storedData, IBeeHousing housing) { IAlleleBeeEffect effect = genome.getEffect(); @@ -202,6 +205,7 @@ public class Bee extends IndividualLiving implements IBee { return storedData; } + @SideOnly(Side.CLIENT) private IEffectData doFX(IAlleleBeeEffect effect, IEffectData storedData, IBeeHousing housing) { return effect.doFX(genome, storedData, housing); } diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java index 0f5b550d5..343502431 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java @@ -183,6 +183,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies } @Override + @SideOnly(Side.CLIENT) public ModelResourceLocation getModel(EnumBeeType type) { return beeModelProvider.getModel(type); } diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffect.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffect.java index 7d6d3e860..17675a246 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffect.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffect.java @@ -21,12 +21,14 @@ import forestry.api.apiculture.IBeekeepingLogic; import forestry.api.genetics.IEffectData; import forestry.core.config.Constants; import forestry.core.genetics.alleles.AlleleCategorized; -import forestry.core.proxy.Proxies; +import forestry.core.render.ParticleRender; import forestry.core.utils.VectUtil; import net.minecraft.entity.Entity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3i; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public abstract class AlleleEffect extends AlleleCategorized implements IAlleleBeeEffect { protected AlleleEffect(String valueName, boolean isDominant) { @@ -49,11 +51,12 @@ public abstract class AlleleEffect extends AlleleCategorized implements IAlleleB } @Override + @SideOnly(Side.CLIENT) public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { IBeekeepingLogic beekeepingLogic = housing.getBeekeepingLogic(); List flowerPositions = beekeepingLogic.getFlowerPositions(); - Proxies.render.addBeeHiveFX(housing, genome, flowerPositions); + ParticleRender.addBeeHiveFX(housing, genome, flowerPositions); return storedData; } diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectIgnition.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectIgnition.java index a78d4600b..f6be69d49 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectIgnition.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectIgnition.java @@ -16,10 +16,12 @@ import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; -import forestry.core.proxy.Proxies; +import forestry.core.render.ParticleRender; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class AlleleEffectIgnition extends AlleleEffectThrottled { private static final int ignitionChance = 50; @@ -63,13 +65,14 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled { } @Override + @SideOnly(Side.CLIENT) public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { World world = housing.getWorldObj(); if (world.rand.nextInt(2) != 0) { super.doFX(genome, storedData, housing); } else { Vec3d beeFXCoordinates = housing.getBeeFXCoordinates(); - Proxies.render.addEntityIgnitionFX(world, beeFXCoordinates.xCoord, beeFXCoordinates.yCoord + 0.5, beeFXCoordinates.zCoord); + ParticleRender.addEntityIgnitionFX(world, beeFXCoordinates.xCoord, beeFXCoordinates.yCoord + 0.5, beeFXCoordinates.zCoord); } return storedData; } diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectPotion.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectPotion.java index 3aecb2749..efaf2ae8e 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectPotion.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectPotion.java @@ -18,7 +18,7 @@ import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; -import forestry.core.proxy.Proxies; +import forestry.core.render.ParticleRender; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.IMob; import net.minecraft.potion.Potion; @@ -26,6 +26,8 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionUtils; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class AlleleEffectPotion extends AlleleEffectThrottled { @@ -84,13 +86,14 @@ public class AlleleEffectPotion extends AlleleEffectThrottled { } @Override + @SideOnly(Side.CLIENT) public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { World world = housing.getWorldObj(); if (world.rand.nextBoolean()) { super.doFX(genome, storedData, housing); } else { Vec3d beeFXCoordinates = housing.getBeeFXCoordinates(); - Proxies.render.addEntityPotionFX(world, beeFXCoordinates.xCoord, beeFXCoordinates.yCoord + 0.5, beeFXCoordinates.zCoord, potionFXColor); + ParticleRender.addEntityPotionFX(world, beeFXCoordinates.xCoord, beeFXCoordinates.yCoord + 0.5, beeFXCoordinates.zCoord, potionFXColor); } return storedData; } diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectSnowing.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectSnowing.java index 1d8616aa7..6349d40d0 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectSnowing.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectSnowing.java @@ -14,7 +14,7 @@ import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.core.EnumTemperature; import forestry.api.genetics.IEffectData; -import forestry.core.proxy.Proxies; +import forestry.core.render.ParticleRender; import forestry.core.utils.VectUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockSnow; @@ -24,6 +24,8 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class AlleleEffectSnowing extends AlleleEffectThrottled { @@ -78,6 +80,7 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled { } @Override + @SideOnly(Side.CLIENT) public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { if (housing.getWorldObj().rand.nextInt(3) == 0) { Vec3i area = getModifiedArea(genome, housing); @@ -87,7 +90,7 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled { World world = housing.getWorldObj(); BlockPos spawn = VectUtil.getRandomPositionInArea(world.rand, area).add(coordinates).add(offset); - Proxies.render.addEntitySnowFX(world, spawn.getX(), spawn.getY(), spawn.getZ()); + ParticleRender.addEntitySnowFX(world, spawn.getX(), spawn.getY(), spawn.getZ()); return storedData; } else { return super.doFX(genome, storedData, housing); diff --git a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java index 9a72da8a4..cdb6c1e30 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java +++ b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java @@ -16,7 +16,7 @@ import forestry.core.gui.ContainerItemInventory; import forestry.core.gui.IGuiSelectable; import forestry.core.gui.slots.SlotFiltered; import forestry.core.gui.slots.SlotOutput; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -48,7 +48,7 @@ public class ContainerImprinter extends ContainerItemInventory { } private static void sendSelectionChange(int index, int advance) { - Proxies.net.sendToServer(new PacketGuiSelectRequest(index, advance)); + NetworkUtil.sendToServer(new PacketGuiSelectRequest(index, advance)); } @Override diff --git a/src/main/java/forestry/apiculture/gui/HabitatSlot.java b/src/main/java/forestry/apiculture/gui/HabitatSlot.java index 45c67430f..984adcbb2 100644 --- a/src/main/java/forestry/apiculture/gui/HabitatSlot.java +++ b/src/main/java/forestry/apiculture/gui/HabitatSlot.java @@ -17,8 +17,7 @@ import java.util.Locale; import forestry.core.gui.tooltips.ToolTip; import forestry.core.gui.widgets.Widget; import forestry.core.gui.widgets.WidgetManager; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraftforge.common.BiomeDictionary; @@ -47,7 +46,7 @@ public class HabitatSlot extends Widget { @SideOnly(Side.CLIENT) public TextureAtlasSprite getIcon() { - return TextureManager.getInstance().getDefault(iconIndex); + return TextureManagerForestry.getInstance().getDefault(iconIndex); } public void setActive(Collection biomes) { @@ -62,7 +61,7 @@ public class HabitatSlot extends Widget { GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); } - Proxies.render.bindTexture(TextureManager.getInstance().getGuiTextureMap()); + TextureManagerForestry.getInstance().bindGuiTextureMap(); manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, getIcon(), 16, 16); } } diff --git a/src/main/java/forestry/apiculture/items/HabitatLocatorLogic.java b/src/main/java/forestry/apiculture/items/HabitatLocatorLogic.java index 2a2359d5e..199f8fecb 100644 --- a/src/main/java/forestry/apiculture/items/HabitatLocatorLogic.java +++ b/src/main/java/forestry/apiculture/items/HabitatLocatorLogic.java @@ -17,7 +17,8 @@ import java.util.Set; import forestry.api.apiculture.IBee; import forestry.apiculture.network.packets.PacketHabitatBiomePointer; -import forestry.core.proxy.Proxies; +import forestry.apiculture.render.TextureHabitatLocator; +import forestry.core.utils.NetworkUtil; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -72,7 +73,9 @@ public class HabitatLocatorLogic { removeInvalidBiomes(currentBiome, targetBiomes); // reset the locator coordinates - Proxies.render.setHabitatLocatorTexture(null, null); + if (player.world.isRemote) { + TextureHabitatLocator.getInstance().setTargetCoordinates(null); + } } public void onUpdate(World world, Entity player) { @@ -93,7 +96,7 @@ public class HabitatLocatorLogic { // send an update if we find the biome if (target != null && player instanceof EntityPlayerMP) { - Proxies.net.sendToPlayer(new PacketHabitatBiomePointer(target), (EntityPlayerMP) player); + NetworkUtil.sendToPlayer(new PacketHabitatBiomePointer(target), (EntityPlayerMP) player); biomeFound = true; } } diff --git a/src/main/java/forestry/apiculture/items/ItemBeeGE.java b/src/main/java/forestry/apiculture/items/ItemBeeGE.java index 51a47fceb..8d8973a8d 100755 --- a/src/main/java/forestry/apiculture/items/ItemBeeGE.java +++ b/src/main/java/forestry/apiculture/items/ItemBeeGE.java @@ -80,6 +80,7 @@ public class ItemBeeGE extends ItemGE implements IColoredItem { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { if (itemstack.getTagCompound() == null) { return; @@ -142,6 +143,7 @@ public class ItemBeeGE extends ItemGE implements IColoredItem { manager.registerItemModel(item, new BeeMeshDefinition()); } + @SideOnly(Side.CLIENT) private class BeeMeshDefinition implements ItemMeshDefinition { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { diff --git a/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java b/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java index 2402b3fca..4e0a04d26 100644 --- a/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java +++ b/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java @@ -26,9 +26,11 @@ import forestry.core.items.ItemWithGui; import forestry.core.utils.ClimateUtil; import forestry.core.utils.Translator; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; @@ -66,6 +68,7 @@ public class ItemHabitatLocator extends ItemWithGui implements ISpriteRegister { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { super.addInformation(itemstack, player, list, flag); @@ -81,12 +84,13 @@ public class ItemHabitatLocator extends ItemWithGui implements ISpriteRegister { } @Override - public Object getGui(EntityPlayer player, ItemStack heldItem, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, ItemStack heldItem, int data) { return new GuiHabitatLocator(player, new ItemInventoryHabitatLocator(player, heldItem)); } @Override - public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) { + public Container getContainer(EntityPlayer player, ItemStack heldItem, int data) { return new ContainerHabitatLocator(player, new ItemInventoryHabitatLocator(player, heldItem)); } } diff --git a/src/main/java/forestry/apiculture/items/ItemHiveFrame.java b/src/main/java/forestry/apiculture/items/ItemHiveFrame.java index b70e90c27..b191b74cc 100755 --- a/src/main/java/forestry/apiculture/items/ItemHiveFrame.java +++ b/src/main/java/forestry/apiculture/items/ItemHiveFrame.java @@ -23,6 +23,8 @@ import forestry.core.items.ItemForestry; import forestry.core.utils.Translator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemHiveFrame extends ItemForestry implements IHiveFrame { @@ -52,6 +54,7 @@ public class ItemHiveFrame extends ItemForestry implements IHiveFrame { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { super.addInformation(stack, playerIn, tooltip, advanced); beeModifier.addInformation(stack, playerIn, tooltip, advanced); @@ -78,6 +81,7 @@ public class ItemHiveFrame extends ItemForestry implements IHiveFrame { return this.geneticDecay; } + @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { tooltip.add(Translator.translateToLocalFormatted("item.for.bee.modifier.production", production)); tooltip.add(Translator.translateToLocalFormatted("item.for.bee.modifier.genetic.decay", geneticDecay)); diff --git a/src/main/java/forestry/apiculture/items/ItemImprinter.java b/src/main/java/forestry/apiculture/items/ItemImprinter.java index 17be9f46b..8d95f2959 100644 --- a/src/main/java/forestry/apiculture/items/ItemImprinter.java +++ b/src/main/java/forestry/apiculture/items/ItemImprinter.java @@ -15,8 +15,12 @@ import forestry.apiculture.gui.ContainerImprinter; import forestry.apiculture.gui.GuiImprinter; import forestry.apiculture.inventory.ItemInventoryImprinter; import forestry.core.items.ItemWithGui; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemImprinter extends ItemWithGui { public ItemImprinter() { @@ -24,12 +28,13 @@ public class ItemImprinter extends ItemWithGui { } @Override - public Object getGui(EntityPlayer player, ItemStack heldItem, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, ItemStack heldItem, int data) { return new GuiImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem)); } @Override - public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) { + public Container getContainer(EntityPlayer player, ItemStack heldItem, int data) { return new ContainerImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem)); } } diff --git a/src/main/java/forestry/apiculture/items/ItemSmoker.java b/src/main/java/forestry/apiculture/items/ItemSmoker.java index 8217e0621..171b7cdb8 100644 --- a/src/main/java/forestry/apiculture/items/ItemSmoker.java +++ b/src/main/java/forestry/apiculture/items/ItemSmoker.java @@ -6,7 +6,7 @@ import forestry.api.apiculture.ApicultureCapabilities; import forestry.api.apiculture.IHiveTile; import forestry.api.core.Tabs; import forestry.core.items.ItemForestry; -import forestry.core.proxy.Proxies; +import forestry.core.render.ParticleRender; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -77,7 +77,10 @@ public class ItemSmoker extends ItemForestry { Vec3d scaledOffset = handOffset.scale(1.0 / distance); Vec3d smokePos = lookDistance.add(entity.getPositionVector()).add(scaledOffset); - Proxies.render.addEntitySmokeFX(world, smokePos.xCoord, smokePos.yCoord + 1, smokePos.zCoord); + if (world.isRemote) { + ParticleRender.addEntitySmokeFX(world, smokePos.xCoord, smokePos.yCoord + 1, smokePos.zCoord); + } + BlockPos blockPos = new BlockPos(smokePos.xCoord, smokePos.yCoord + 1, smokePos.zCoord); TileEntity tileEntity = world.getTileEntity(blockPos); if (tileEntity instanceof IHiveTile) { diff --git a/src/main/java/forestry/apiculture/multiblock/AlvearyController.java b/src/main/java/forestry/apiculture/multiblock/AlvearyController.java index 00c7de18c..b73d492e5 100644 --- a/src/main/java/forestry/apiculture/multiblock/AlvearyController.java +++ b/src/main/java/forestry/apiculture/multiblock/AlvearyController.java @@ -36,7 +36,7 @@ import forestry.core.multiblock.IMultiblockControllerInternal; import forestry.core.multiblock.MultiblockValidationException; import forestry.core.multiblock.RectangularMultiblockControllerBase; import forestry.core.network.PacketBufferForestry; -import forestry.core.proxy.Proxies; +import forestry.core.render.ParticleRender; import forestry.core.utils.BlockUtil; import forestry.core.utils.ClimateUtil; import forestry.core.utils.Translator; @@ -47,6 +47,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class AlvearyController extends RectangularMultiblockControllerBase implements IAlvearyControllerInternal, IClimateControlled { private final InventoryBeeHousing inventory; @@ -256,6 +258,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple } @Override + @SideOnly(Side.CLIENT) protected void updateClient(int tickCount) { for (IAlvearyComponent.Active activeComponent : activeComponents) { activeComponent.updateClient(tickCount); @@ -276,10 +279,10 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple fxY += upSpread; // display fx on all 4 sides - Proxies.render.addEntityHoneyDustFX(world, fxX - distanceFromCenter, fxY, fxZ + leftRightSpreadFromCenter); - Proxies.render.addEntityHoneyDustFX(world, fxX + distanceFromCenter, fxY, fxZ + leftRightSpreadFromCenter); - Proxies.render.addEntityHoneyDustFX(world, fxX + leftRightSpreadFromCenter, fxY, fxZ - distanceFromCenter); - Proxies.render.addEntityHoneyDustFX(world, fxX + leftRightSpreadFromCenter, fxY, fxZ + distanceFromCenter); + ParticleRender.addEntityHoneyDustFX(world, fxX - distanceFromCenter, fxY, fxZ + leftRightSpreadFromCenter); + ParticleRender.addEntityHoneyDustFX(world, fxX + distanceFromCenter, fxY, fxZ + leftRightSpreadFromCenter); + ParticleRender.addEntityHoneyDustFX(world, fxX + leftRightSpreadFromCenter, fxY, fxZ - distanceFromCenter); + ParticleRender.addEntityHoneyDustFX(world, fxX + leftRightSpreadFromCenter, fxY, fxZ + distanceFromCenter); } } } diff --git a/src/main/java/forestry/apiculture/multiblock/TileAlveary.java b/src/main/java/forestry/apiculture/multiblock/TileAlveary.java index 5085724d7..e4802f28a 100644 --- a/src/main/java/forestry/apiculture/multiblock/TileAlveary.java +++ b/src/main/java/forestry/apiculture/multiblock/TileAlveary.java @@ -34,11 +34,15 @@ import forestry.core.owner.IOwnerHandler; import forestry.core.tiles.IClimatised; import forestry.core.tiles.ITitled; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public abstract class TileAlveary extends MultiblockTileEntityForestry implements IBeeHousing, IAlvearyComponent, IOwnedTile, IStreamableGui, ITitled, IClimatised { private final String unlocalizedTitle; @@ -172,17 +176,19 @@ public abstract class TileAlveary extends MultiblockTileEntityForestry(this, container, GuiBeeHousing.Icon.APIARY); } @Override - public Object getContainer(EntityPlayer player, int data) { + public Container getContainer(EntityPlayer player, int data) { return new ContainerBeeHousing(player.inventory, this, true); } } diff --git a/src/main/java/forestry/apiculture/tiles/TileBeeHouse.java b/src/main/java/forestry/apiculture/tiles/TileBeeHouse.java index 4ab649787..2c2488b72 100644 --- a/src/main/java/forestry/apiculture/tiles/TileBeeHouse.java +++ b/src/main/java/forestry/apiculture/tiles/TileBeeHouse.java @@ -20,7 +20,11 @@ import forestry.apiculture.BeehouseBeeModifier; import forestry.apiculture.InventoryBeeHousing; import forestry.apiculture.gui.ContainerBeeHousing; import forestry.apiculture.gui.GuiBeeHousing; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TileBeeHouse extends TileBeeHousingBase { private static final IBeeModifier beeModifier = new BeehouseBeeModifier(); @@ -53,13 +57,14 @@ public class TileBeeHouse extends TileBeeHousingBase { } @Override - public Object getGui(EntityPlayer player, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, int data) { ContainerBeeHousing container = new ContainerBeeHousing(player.inventory, this, false); return new GuiBeeHousing<>(this, container, GuiBeeHousing.Icon.BEE_HOUSE); } @Override - public Object getContainer(EntityPlayer player, int data) { + public Container getContainer(EntityPlayer player, int data) { return new ContainerBeeHousing(player.inventory, this, false); } } diff --git a/src/main/java/forestry/apiculture/tiles/TileBeeHousingBase.java b/src/main/java/forestry/apiculture/tiles/TileBeeHousingBase.java index 844bb63a3..cea74cdd7 100644 --- a/src/main/java/forestry/apiculture/tiles/TileBeeHousingBase.java +++ b/src/main/java/forestry/apiculture/tiles/TileBeeHousingBase.java @@ -26,7 +26,7 @@ import forestry.core.network.PacketBufferForestry; import forestry.core.owner.IOwnedTile; import forestry.core.owner.IOwnerHandler; import forestry.core.owner.OwnerHandler; -import forestry.core.proxy.Proxies; +import forestry.core.render.ParticleRender; import forestry.core.tiles.IClimatised; import forestry.core.tiles.TileBase; import forestry.core.utils.ClimateUtil; @@ -34,6 +34,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing, IOwnedTile, IClimatised, IGuiBeeHousingDelegate, IStreamableGui { private final String hintKey; @@ -83,6 +85,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing } @Override + @SideOnly(Side.CLIENT) public void handleUpdateTag(NBTTagCompound tag) { super.handleUpdateTag(tag); beeLogic.readFromNBT(tag); @@ -117,6 +120,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing /* UPDATING */ @Override + @SideOnly(Side.CLIENT) public void updateClientSide() { if (beeLogic.canDoBeeFX() && updateOnInterval(4)) { beeLogic.doBeeFX(); @@ -127,6 +131,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing } } + @SideOnly(Side.CLIENT) public static void doPollenFX(World world, double xCoord, double yCoord, double zCoord) { double fxX = xCoord + 0.5F; double fxY = yCoord + 0.25F; @@ -136,10 +141,10 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing float upSpread = world.rand.nextFloat() * 6F / 16F; fxY += upSpread; - Proxies.render.addEntityHoneyDustFX(world, fxX - distanceFromCenter, fxY, fxZ + leftRightSpreadFromCenter); - Proxies.render.addEntityHoneyDustFX(world, fxX + distanceFromCenter, fxY, fxZ + leftRightSpreadFromCenter); - Proxies.render.addEntityHoneyDustFX(world, fxX + leftRightSpreadFromCenter, fxY, fxZ - distanceFromCenter); - Proxies.render.addEntityHoneyDustFX(world, fxX + leftRightSpreadFromCenter, fxY, fxZ + distanceFromCenter); + ParticleRender.addEntityHoneyDustFX(world, fxX - distanceFromCenter, fxY, fxZ + leftRightSpreadFromCenter); + ParticleRender.addEntityHoneyDustFX(world, fxX + distanceFromCenter, fxY, fxZ + leftRightSpreadFromCenter); + ParticleRender.addEntityHoneyDustFX(world, fxX + leftRightSpreadFromCenter, fxY, fxZ - distanceFromCenter); + ParticleRender.addEntityHoneyDustFX(world, fxX + leftRightSpreadFromCenter, fxY, fxZ + distanceFromCenter); } @Override diff --git a/src/main/java/forestry/apiculture/tiles/TileCandle.java b/src/main/java/forestry/apiculture/tiles/TileCandle.java index fd338abc0..68bb0ee6c 100644 --- a/src/main/java/forestry/apiculture/tiles/TileCandle.java +++ b/src/main/java/forestry/apiculture/tiles/TileCandle.java @@ -14,6 +14,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TileCandle extends TileEntity { private int colour; @@ -25,6 +27,7 @@ public class TileCandle extends TileEntity { } @Override + @SideOnly(Side.CLIENT) public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); NBTTagCompound nbt = pkt.getNbtCompound(); diff --git a/src/main/java/forestry/apiculture/tiles/TileHive.java b/src/main/java/forestry/apiculture/tiles/TileHive.java index 61fce8130..1c21677a6 100644 --- a/src/main/java/forestry/apiculture/tiles/TileHive.java +++ b/src/main/java/forestry/apiculture/tiles/TileHive.java @@ -38,12 +38,12 @@ import forestry.apiculture.genetics.alleles.AlleleEffect; import forestry.apiculture.network.packets.PacketActiveUpdate; import forestry.core.config.Config; import forestry.core.inventory.InventoryAdapter; -import forestry.core.proxy.Proxies; import forestry.core.tiles.IActivatable; import forestry.core.utils.ClimateUtil; import forestry.core.utils.DamageSourceForestry; import forestry.core.utils.InventoryUtil; import forestry.core.utils.ItemStackUtil; +import forestry.core.utils.NetworkUtil; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; @@ -65,6 +65,8 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TileHive extends TileEntity implements ITickable, IHiveTile, IActivatable, IBeeHousing { private static final DamageSource damageSourceBeeHive = new DamageSourceForestry("bee.hive"); @@ -252,7 +254,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv this.active = active; if (!world.isRemote) { - Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), pos, world); + NetworkUtil.sendNetworkPacket(new PacketActiveUpdate(this), pos, world); } } @@ -279,6 +281,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv } @Override + @SideOnly(Side.CLIENT) public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); NBTTagCompound nbt = pkt.getNbtCompound(); diff --git a/src/main/java/forestry/arboriculture/FruitProviderNone.java b/src/main/java/forestry/arboriculture/FruitProviderNone.java index caacd2cfb..b0c092027 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderNone.java +++ b/src/main/java/forestry/arboriculture/FruitProviderNone.java @@ -20,8 +20,8 @@ import forestry.api.arboriculture.IFruitProvider; import forestry.api.arboriculture.ITreeGenome; import forestry.api.genetics.IFruitFamily; import forestry.core.config.Constants; -import forestry.core.proxy.Proxies; import forestry.core.utils.Translator; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -29,6 +29,8 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class FruitProviderNone implements IFruitProvider { @@ -144,9 +146,10 @@ public class FruitProviderNone implements IFruitProvider { } @Override + @SideOnly(Side.CLIENT) public void registerSprites() { if (overlay != null) { - TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks(); + TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks(); map.registerSprite(overlay.sprite); } } diff --git a/src/main/java/forestry/arboriculture/FruitProviderPod.java b/src/main/java/forestry/arboriculture/FruitProviderPod.java index f937bc6ba..3c415db79 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderPod.java +++ b/src/main/java/forestry/arboriculture/FruitProviderPod.java @@ -29,6 +29,8 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class FruitProviderPod extends FruitProviderNone { @@ -106,6 +108,7 @@ public class FruitProviderPod extends FruitProviderNone { } @Override + @SideOnly(Side.CLIENT) public void registerSprites() { } diff --git a/src/main/java/forestry/arboriculture/PluginArboriculture.java b/src/main/java/forestry/arboriculture/PluginArboriculture.java index 5e48be22e..d471ecae8 100644 --- a/src/main/java/forestry/arboriculture/PluginArboriculture.java +++ b/src/main/java/forestry/arboriculture/PluginArboriculture.java @@ -70,9 +70,8 @@ import forestry.core.fluids.Fluids; import forestry.core.items.ItemFruit.EnumFruit; import forestry.core.items.ItemRegistryCore; import forestry.core.network.IPacketRegistry; -import forestry.core.proxy.Proxies; import forestry.core.recipes.RecipeUtil; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import forestry.core.utils.IMCUtil; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.OreDictUtil; @@ -85,6 +84,7 @@ import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockNewLeaf; import net.minecraft.block.BlockOldLeaf; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -599,7 +599,7 @@ public class PluginArboriculture extends BlankForestryPlugin { @SideOnly(Side.CLIENT) public void registerSprites(TextureStitchEvent.Pre event) { TextureLeaves.registerAllSprites(); - WoodTextureManager.parseFile(Proxies.render.getSelectedTexturePack()); + WoodTextureManager.parseFile(Minecraft.getMinecraft().getResourceManager()); for (IAlleleFruit alleleFruit : AlleleFruits.getFruitAlleles()) { alleleFruit.getProvider().registerSprites(); } @@ -617,7 +617,7 @@ public class PluginArboriculture extends BlankForestryPlugin { } } for (ResourceLocation loc : textures) { - TextureManager.registerSprite(loc); + TextureManagerForestry.registerSprite(loc); } } diff --git a/src/main/java/forestry/arboriculture/blocks/BlockCharcoal.java b/src/main/java/forestry/arboriculture/blocks/BlockCharcoal.java index b1474dfcc..f435997f3 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockCharcoal.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockCharcoal.java @@ -2,11 +2,11 @@ package forestry.arboriculture.blocks; import java.util.Collections; import java.util.List; + import forestry.api.core.IItemModelRegister; import forestry.api.core.IModelManager; import forestry.api.core.IStateMapperRegister; import forestry.api.core.Tabs; -import forestry.core.proxy.Proxies; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.MapColor; @@ -20,6 +20,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; +import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -67,7 +68,7 @@ public class BlockCharcoal extends Block implements IStateMapperRegister, IItemM @SideOnly(Side.CLIENT) @Override public void registerStateMapper() { - Proxies.render.registerStateMapper(this, new StateMap.Builder().ignore(AMOUNT).build()); + ModelLoader.setCustomStateMapper(this, new StateMap.Builder().ignore(AMOUNT).build()); } } diff --git a/src/main/java/forestry/arboriculture/blocks/BlockDecorativeLeaves.java b/src/main/java/forestry/arboriculture/blocks/BlockDecorativeLeaves.java index b51b00feb..d90ecf484 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockDecorativeLeaves.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockDecorativeLeaves.java @@ -114,6 +114,7 @@ public abstract class BlockDecorativeLeaves extends Block implements IItemModelR } @Override + @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { return (Proxies.render.fancyGraphicsEnabled() || blockAccess.getBlockState(pos.offset(side)).getBlock() != this) && super.shouldSideBeRendered(blockState, blockAccess, pos, side); } diff --git a/src/main/java/forestry/arboriculture/blocks/BlockForestryLeaves.java b/src/main/java/forestry/arboriculture/blocks/BlockForestryLeaves.java index 0184ecd8b..fb09f5b96 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockForestryLeaves.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockForestryLeaves.java @@ -46,6 +46,7 @@ import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.EnchantmentHelper; @@ -345,12 +346,13 @@ public class BlockForestryLeaves extends BlockLeaves implements ITileEntityProvi } @Override + @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) { if (worldIn != null && pos != null) { TileLeaves leaves = TileUtil.getTile(worldIn, pos, TileLeaves.class); if (leaves != null) { if (tintIndex == 0) { - EntityPlayer thePlayer = Proxies.common.getPlayer(); + EntityPlayer thePlayer = Minecraft.getMinecraft().player; return leaves.getFoliageColour(thePlayer); } else { return leaves.getFruitColour(); diff --git a/src/main/java/forestry/arboriculture/blocks/BlockFruitPod.java b/src/main/java/forestry/arboriculture/blocks/BlockFruitPod.java index 11ac0454d..7b1db9345 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockFruitPod.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockFruitPod.java @@ -20,7 +20,6 @@ import forestry.api.core.IStateMapperRegister; import forestry.arboriculture.genetics.alleles.AlleleFruits; import forestry.arboriculture.render.FruitPodStateMapper; import forestry.arboriculture.tiles.TileFruitPod; -import forestry.core.proxy.Proxies; import forestry.core.tiles.TileUtil; import forestry.core.utils.BlockUtil; import forestry.core.utils.ItemStackUtil; @@ -35,6 +34,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -123,7 +123,7 @@ public class BlockFruitPod extends BlockCocoa implements IStateMapperRegister, I @SideOnly(Side.CLIENT) @Override public void registerStateMapper() { - Proxies.render.registerStateMapper(this, new FruitPodStateMapper()); + ModelLoader.setCustomStateMapper(this, new FruitPodStateMapper()); } /* IGrowable */ diff --git a/src/main/java/forestry/arboriculture/blocks/BlockSapling.java b/src/main/java/forestry/arboriculture/blocks/BlockSapling.java index e7060584a..3927b4def 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockSapling.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockSapling.java @@ -24,7 +24,6 @@ import forestry.api.core.IStateMapperRegister; import forestry.arboriculture.genetics.TreeDefinition; import forestry.arboriculture.render.SaplingStateMapper; import forestry.arboriculture.tiles.TileSapling; -import forestry.core.proxy.Proxies; import forestry.core.tiles.TileUtil; import forestry.core.utils.ItemStackUtil; import net.minecraft.block.Block; @@ -43,6 +42,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -116,7 +116,7 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat @Override @SideOnly(Side.CLIENT) public void registerStateMapper() { - Proxies.render.registerStateMapper(this, new SaplingStateMapper()); + ModelLoader.setCustomStateMapper(this, new SaplingStateMapper()); } /* MODELS */ diff --git a/src/main/java/forestry/arboriculture/blocks/BlockTypeArboricultureTesr.java b/src/main/java/forestry/arboriculture/blocks/BlockTypeArboricultureTesr.java index 62c2e0c8f..be8984a65 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockTypeArboricultureTesr.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockTypeArboricultureTesr.java @@ -10,32 +10,26 @@ ******************************************************************************/ package forestry.arboriculture.blocks; -import javax.annotation.Nullable; - import forestry.arboriculture.tiles.TileArboristChest; import forestry.core.blocks.IBlockTypeTesr; import forestry.core.blocks.IMachinePropertiesTesr; import forestry.core.blocks.MachinePropertiesTesr; import forestry.core.config.Constants; import forestry.core.proxy.Proxies; -import forestry.core.tiles.TileForestry; import forestry.core.tiles.TileNaturalistChest; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.util.math.AxisAlignedBB; public enum BlockTypeArboricultureTesr implements IBlockTypeTesr { - ARB_CHEST(TileArboristChest.class, "arb_chest", Proxies.render.getRenderChest("arbchest"), TileNaturalistChest.chestBoundingBox); + ARB_CHEST(TileArboristChest.class, "arb_chest", "arbchest", TileNaturalistChest.chestBoundingBox); public static final BlockTypeArboricultureTesr[] VALUES = values(); private final IMachinePropertiesTesr machineProperties; - BlockTypeArboricultureTesr(Class teClass, String name, @Nullable TileEntitySpecialRenderer renderer, @Nullable AxisAlignedBB boundingBox) { - if (boundingBox != null) { - this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0"); - } else { - this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, Constants.MOD_ID + ":blocks/" + name + ".0", false); - } + BlockTypeArboricultureTesr(Class teClass, String name, String renderName, AxisAlignedBB boundingBox) { + MachinePropertiesTesr machineProperties = new MachinePropertiesTesr<>(teClass, name, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0"); + Proxies.render.setRenderChest(machineProperties, renderName); + this.machineProperties = machineProperties; } @Override diff --git a/src/main/java/forestry/arboriculture/blocks/BlockWoodPile.java b/src/main/java/forestry/arboriculture/blocks/BlockWoodPile.java index 15c68bb9e..0ec0386d4 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockWoodPile.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockWoodPile.java @@ -9,7 +9,6 @@ import forestry.api.core.IModelManager; import forestry.api.core.IStateMapperRegister; import forestry.api.core.Tabs; import forestry.arboriculture.PluginArboriculture; -import forestry.core.proxy.Proxies; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; @@ -27,6 +26,7 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -215,7 +215,7 @@ public class BlockWoodPile extends Block implements IItemModelRegister, IStateMa @SideOnly(Side.CLIENT) @Override public void registerStateMapper() { - Proxies.render.registerStateMapper(this, new StateMap.Builder().ignore(AGE, IS_ACTIVE).build()); + ModelLoader.setCustomStateMapper(this, new StateMap.Builder().ignore(AGE, IS_ACTIVE).build()); } } diff --git a/src/main/java/forestry/arboriculture/genetics/Tree.java b/src/main/java/forestry/arboriculture/genetics/Tree.java index 4b6cc89d9..ffda172ec 100755 --- a/src/main/java/forestry/arboriculture/genetics/Tree.java +++ b/src/main/java/forestry/arboriculture/genetics/Tree.java @@ -51,6 +51,8 @@ import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.IPlantable; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class Tree extends Individual implements ITree, IPlantable { private final ITreeGenome genome; @@ -125,6 +127,7 @@ public class Tree extends Individual implements ITree, IPlantable { } @Override + @SideOnly(Side.CLIENT) public IEffectData[] doFX(IEffectData[] storedData, World world, BlockPos pos) { return storedData; } diff --git a/src/main/java/forestry/arboriculture/genetics/TreeAlyzerPlugin.java b/src/main/java/forestry/arboriculture/genetics/TreeAlyzerPlugin.java index 58d7fa4e6..f5845aa4e 100644 --- a/src/main/java/forestry/arboriculture/genetics/TreeAlyzerPlugin.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeAlyzerPlugin.java @@ -34,8 +34,8 @@ import forestry.core.gui.GuiAlyzer; import forestry.core.gui.TextLayoutHelper; import forestry.core.gui.widgets.ItemStackWidget; import forestry.core.gui.widgets.WidgetManager; -import forestry.core.proxy.Proxies; import forestry.core.utils.Translator; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -251,7 +251,7 @@ public class TreeAlyzerPlugin implements IAlyzerPlugin { x = GuiAlyzer.COLUMN_0; for (ItemStack stack : tree.getSpecialties().keySet()) { - Proxies.common.getClientInstance().getRenderItem().renderItemIntoGUI(stack, guiAlyzer.getGuiLeft() + x, guiAlyzer.getGuiTop() + textLayout.getLineY()); + Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(stack, guiAlyzer.getGuiLeft() + x, guiAlyzer.getGuiTop() + textLayout.getLineY()); x += 18; if (x > 148) { x = GuiAlyzer.COLUMN_0; diff --git a/src/main/java/forestry/arboriculture/genetics/TreeRoot.java b/src/main/java/forestry/arboriculture/genetics/TreeRoot.java index 9f50cda6f..f5c265527 100644 --- a/src/main/java/forestry/arboriculture/genetics/TreeRoot.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeRoot.java @@ -52,10 +52,10 @@ import forestry.arboriculture.tiles.TileSapling; import forestry.core.config.Config; import forestry.core.genetics.SpeciesRoot; import forestry.core.network.packets.PacketFXSignal; -import forestry.core.proxy.Proxies; import forestry.core.tiles.TileUtil; import forestry.core.utils.BlockUtil; import forestry.core.utils.GeneticsUtil; +import forestry.core.utils.NetworkUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.state.IBlockState; @@ -233,7 +233,7 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot { sapling.getOwnerHandler().setOwner(owner); PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, blockState); - Proxies.net.sendNetworkPacket(packet, pos, world); + NetworkUtil.sendNetworkPacket(packet, pos, world); return true; } diff --git a/src/main/java/forestry/arboriculture/genetics/WoodProvider.java b/src/main/java/forestry/arboriculture/genetics/WoodProvider.java index e8ce835da..f68898e4a 100644 --- a/src/main/java/forestry/arboriculture/genetics/WoodProvider.java +++ b/src/main/java/forestry/arboriculture/genetics/WoodProvider.java @@ -18,18 +18,22 @@ import forestry.api.arboriculture.TreeManager; import forestry.api.arboriculture.WoodBlockKind; import forestry.api.core.ITextureManager; import forestry.core.config.Constants; -import forestry.core.proxy.Proxies; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class WoodProvider implements IWoodProvider { private final String name; private final EnumForestryWoodType woodType; + @SideOnly(Side.CLIENT) private TextureAtlasSprite woodTop; + @SideOnly(Side.CLIENT) private TextureAtlasSprite woodBark; public WoodProvider(EnumForestryWoodType woodType) { @@ -38,13 +42,15 @@ public class WoodProvider implements IWoodProvider { } @Override + @SideOnly(Side.CLIENT) public void registerSprites(Item item, ITextureManager manager) { - TextureMap textureMap = Proxies.common.getClientInstance().getTextureMapBlocks(); + TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks(); woodTop = textureMap.registerSprite(new ResourceLocation(Constants.MOD_ID, "blocks/wood/heart." + name)); woodBark = textureMap.registerSprite(new ResourceLocation(Constants.MOD_ID, "blocks/wood/bark." + name)); } @Override + @SideOnly(Side.CLIENT) public TextureAtlasSprite getSprite(boolean isTop) { if (isTop) { return woodTop; diff --git a/src/main/java/forestry/arboriculture/genetics/WoodProviderVanilla.java b/src/main/java/forestry/arboriculture/genetics/WoodProviderVanilla.java index 847e657f5..869cd81ae 100644 --- a/src/main/java/forestry/arboriculture/genetics/WoodProviderVanilla.java +++ b/src/main/java/forestry/arboriculture/genetics/WoodProviderVanilla.java @@ -15,12 +15,14 @@ import forestry.api.arboriculture.IWoodProvider; import forestry.api.arboriculture.TreeManager; import forestry.api.arboriculture.WoodBlockKind; import forestry.api.core.ITextureManager; -import forestry.core.proxy.Proxies; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class WoodProviderVanilla implements IWoodProvider { @@ -33,6 +35,7 @@ public class WoodProviderVanilla implements IWoodProvider { } @Override + @SideOnly(Side.CLIENT) public void registerSprites(Item item, ITextureManager manager) { String name; switch (woodType) { @@ -58,12 +61,13 @@ public class WoodProviderVanilla implements IWoodProvider { return; } - TextureMap textureMap = Proxies.common.getClientInstance().getTextureMapBlocks(); + TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks(); woodTop = textureMap.registerSprite(new ResourceLocation("minecraft", "blocks/log_" + name + "_top")); woodBark = textureMap.registerSprite(new ResourceLocation("minecraft", "blocks/log_" + name)); } @Override + @SideOnly(Side.CLIENT) public TextureAtlasSprite getSprite(boolean isTop) { if (isTop) { return woodTop; diff --git a/src/main/java/forestry/arboriculture/items/ItemBlockDecorativeLeaves.java b/src/main/java/forestry/arboriculture/items/ItemBlockDecorativeLeaves.java index 1ff30036e..50d1fb74d 100644 --- a/src/main/java/forestry/arboriculture/items/ItemBlockDecorativeLeaves.java +++ b/src/main/java/forestry/arboriculture/items/ItemBlockDecorativeLeaves.java @@ -8,6 +8,8 @@ import forestry.core.items.IColoredItem; import forestry.core.items.ItemBlockForestry; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemBlockDecorativeLeaves extends ItemBlockForestry implements IColoredItem { public ItemBlockDecorativeLeaves(Block block) { @@ -25,6 +27,7 @@ public class ItemBlockDecorativeLeaves extends ItemBlockForestry implements IColoredItem { @@ -58,6 +60,7 @@ public class ItemBlockLeaves extends ItemBlockForestry impl } @Override + @SideOnly(Side.CLIENT) public int getColorFromItemstack(ItemStack itemStack, int renderPass) { if (itemStack.getTagCompound() == null) { return PluginArboriculture.proxy.getFoliageColorBasic(); @@ -67,7 +70,7 @@ public class ItemBlockLeaves extends ItemBlockForestry impl tileLeaves.readFromNBT(itemStack.getTagCompound()); if (renderPass == 0) { - EntityPlayer player = Proxies.common.getPlayer(); + EntityPlayer player = Minecraft.getMinecraft().player; return tileLeaves.getFoliageColour(player); } else { return tileLeaves.getFruitColour(); diff --git a/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java b/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java index 60b1cfa1f..814b672ae 100755 --- a/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java +++ b/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java @@ -30,8 +30,8 @@ import forestry.core.config.Config; import forestry.core.genetics.ItemGE; import forestry.core.items.IColoredItem; import forestry.core.network.packets.PacketFXSignal; -import forestry.core.proxy.Proxies; import forestry.core.utils.GeneticsUtil; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.Translator; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; @@ -168,7 +168,7 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable, ICol IBlockState blockState = worldIn.getBlockState(pos); PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState); - Proxies.net.sendNetworkPacket(packet, pos, worldIn); + NetworkUtil.sendNetworkPacket(packet, pos, worldIn); if (!playerIn.capabilities.isCreativeMode) { itemStackIn.shrink(1); diff --git a/src/main/java/forestry/arboriculture/items/ItemGrafter.java b/src/main/java/forestry/arboriculture/items/ItemGrafter.java index de18ba460..6c85cbb84 100755 --- a/src/main/java/forestry/arboriculture/items/ItemGrafter.java +++ b/src/main/java/forestry/arboriculture/items/ItemGrafter.java @@ -25,6 +25,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemGrafter extends ItemForestryTool implements IToolGrafter { public ItemGrafter(int maxDamage) { @@ -37,6 +39,7 @@ public class ItemGrafter extends ItemForestryTool implements IToolGrafter { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { super.addInformation(stack, playerIn, tooltip, advanced); if (!stack.isItemDamaged()) { diff --git a/src/main/java/forestry/arboriculture/models/ModelDecorativeLeaves.java b/src/main/java/forestry/arboriculture/models/ModelDecorativeLeaves.java index 62e3050b2..dd77e4951 100644 --- a/src/main/java/forestry/arboriculture/models/ModelDecorativeLeaves.java +++ b/src/main/java/forestry/arboriculture/models/ModelDecorativeLeaves.java @@ -22,12 +22,16 @@ import forestry.core.models.baker.ModelBaker; import forestry.core.proxy.Proxies; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class ModelDecorativeLeaves extends ModelBlockCached { public ModelDecorativeLeaves() { super(BlockDecorativeLeaves.class); @@ -51,7 +55,7 @@ public class ModelDecorativeLeaves extends ModelBlockCached { public static class Key { public final TextureAtlasSprite leafSprite; @@ -66,7 +70,7 @@ public class ModelLeaves extends ModelBlockCached bakedTextureGetter) { + Function bakedTextureGetter) { MultipartBakedModel.Builder builder = new MultipartBakedModel.Builder(); for (Selector selector : multipart.getSelectors()) { diff --git a/src/main/java/forestry/arboriculture/models/SimpleModel.java b/src/main/java/forestry/arboriculture/models/SimpleModel.java index bc6b7f7cb..c62cd311d 100644 --- a/src/main/java/forestry/arboriculture/models/SimpleModel.java +++ b/src/main/java/forestry/arboriculture/models/SimpleModel.java @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Set; -import org.apache.commons.lang3.tuple.Pair; import com.google.common.base.Function; import com.google.common.base.Throwables; @@ -22,7 +21,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; - import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.Variant; @@ -38,7 +36,11 @@ import net.minecraftforge.client.model.ModelProcessingHelper; import net.minecraftforge.client.model.MultiModelState; import net.minecraftforge.common.model.IModelState; import net.minecraftforge.common.model.TRSRTransformation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.apache.commons.lang3.tuple.Pair; +@SideOnly(Side.CLIENT) public class SimpleModel implements IRetexturableModel { private static final ModelResourceLocation MISSING = new ModelResourceLocation("builtin/missing", "missing"); @@ -50,7 +52,7 @@ public class SimpleModel implements IRetexturableModel { private final IModelState defaultState; public SimpleModel(List locations, List models, List variants, - IModelState defaultState) { + IModelState defaultState) { this.locations.addAll(locations); this.models.addAll(models); this.variants = variants; @@ -105,7 +107,7 @@ public class SimpleModel implements IRetexturableModel { @Override public IBakedModel bake(IModelState state, VertexFormat format, - Function bakedTextureGetter) { + Function bakedTextureGetter) { if (variants.size() == 1) { IModel model = models.get(0); return model.bake(MultiModelState.getPartState(state, model, 0), format, bakedTextureGetter); diff --git a/src/main/java/forestry/arboriculture/models/TextureLeaves.java b/src/main/java/forestry/arboriculture/models/TextureLeaves.java index 51d92f39d..19548acfb 100644 --- a/src/main/java/forestry/arboriculture/models/TextureLeaves.java +++ b/src/main/java/forestry/arboriculture/models/TextureLeaves.java @@ -16,9 +16,11 @@ import java.util.Map; import forestry.api.arboriculture.EnumLeafType; import forestry.core.config.Constants; -import forestry.core.proxy.Proxies; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TextureLeaves { private static final Map leafTextures = new EnumMap<>(EnumLeafType.class); @@ -33,6 +35,7 @@ public class TextureLeaves { return leafTextures.get(leafType); } + @SideOnly(Side.CLIENT) public static void registerAllSprites() { for (TextureLeaves leafTexture : leafTextures.values()) { leafTexture.registerSprites(); @@ -52,8 +55,9 @@ public class TextureLeaves { this.pollinatedFancy = new ResourceLocation(Constants.MOD_ID, "blocks/leaves/" + ident + ".changed"); } + @SideOnly(Side.CLIENT) private void registerSprites() { - TextureMap textureMapBlocks = Proxies.common.getClientInstance().getTextureMapBlocks(); + TextureMap textureMapBlocks = Minecraft.getMinecraft().getTextureMapBlocks(); textureMapBlocks.registerSprite(plain); textureMapBlocks.registerSprite(fancy); textureMapBlocks.registerSprite(pollinatedPlain); diff --git a/src/main/java/forestry/arboriculture/models/WoodModelLoader.java b/src/main/java/forestry/arboriculture/models/WoodModelLoader.java index c27095987..b803d76ab 100644 --- a/src/main/java/forestry/arboriculture/models/WoodModelLoader.java +++ b/src/main/java/forestry/arboriculture/models/WoodModelLoader.java @@ -12,6 +12,7 @@ package forestry.arboriculture.models; import java.util.ArrayList; import java.util.List; + import forestry.core.config.Constants; import forestry.core.utils.ModelUtil; import net.minecraft.client.renderer.block.model.ModelBlockDefinition; @@ -22,7 +23,10 @@ import net.minecraft.client.resources.IResourceManager; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ICustomModelLoader; import net.minecraftforge.client.model.IModel; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public enum WoodModelLoader implements ICustomModelLoader { INSTANCE; diff --git a/src/main/java/forestry/arboriculture/network/PacketRegistryArboriculture.java b/src/main/java/forestry/arboriculture/network/PacketRegistryArboriculture.java index bb0a2deb7..50f15f1c5 100644 --- a/src/main/java/forestry/arboriculture/network/PacketRegistryArboriculture.java +++ b/src/main/java/forestry/arboriculture/network/PacketRegistryArboriculture.java @@ -12,10 +12,18 @@ package forestry.arboriculture.network; import forestry.core.network.IPacketRegistry; import forestry.core.network.PacketIdClient; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketRegistryArboriculture implements IPacketRegistry { @Override - public void registerPackets() { + public void registerPacketsServer() { + + } + + @Override + @SideOnly(Side.CLIENT) + public void registerPacketsClient() { PacketIdClient.RIPENING_UPDATE.setPacketHandler(new PacketRipeningUpdate.Handler()); } } diff --git a/src/main/java/forestry/arboriculture/network/PacketRipeningUpdate.java b/src/main/java/forestry/arboriculture/network/PacketRipeningUpdate.java index dd654b516..ab5dc568c 100644 --- a/src/main/java/forestry/arboriculture/network/PacketRipeningUpdate.java +++ b/src/main/java/forestry/arboriculture/network/PacketRipeningUpdate.java @@ -21,6 +21,8 @@ import forestry.core.network.PacketIdClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketRipeningUpdate extends ForestryPacket implements IForestryPacketClient { private final BlockPos pos; @@ -42,6 +44,7 @@ public class PacketRipeningUpdate extends ForestryPacket implements IForestryPac data.writeVarInt(value); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/arboriculture/proxy/ProxyArboricultureClient.java b/src/main/java/forestry/arboriculture/proxy/ProxyArboricultureClient.java index 58cd489b0..da68493ce 100644 --- a/src/main/java/forestry/arboriculture/proxy/ProxyArboricultureClient.java +++ b/src/main/java/forestry/arboriculture/proxy/ProxyArboricultureClient.java @@ -16,7 +16,6 @@ import java.util.Set; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; - import forestry.api.arboriculture.IWoodItemMeshDefinition; import forestry.api.arboriculture.IWoodStateMapper; import forestry.api.arboriculture.IWoodType; @@ -34,7 +33,6 @@ import forestry.core.models.BlockModelEntry; import forestry.core.models.ModelManager; import forestry.core.models.SimpleRetexturedModel; import forestry.core.models.WoodModelEntry; -import forestry.core.proxy.Proxies; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.IBakedModel; @@ -46,9 +44,13 @@ import net.minecraft.util.registry.IRegistry; import net.minecraft.world.ColorizerFoliage; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.model.IModel; +import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class ProxyArboricultureClient extends ProxyArboriculture { private static final Set woodModelEntrys = new HashSet<>(); private static final Map stateMappers = Maps.newIdentityHashMap(); @@ -61,7 +63,7 @@ public class ProxyArboricultureClient extends ProxyArboriculture { ModelResourceLocation itemModelLocation = new ModelResourceLocation("forestry:leaves", "inventory"); BlockModelEntry blockModelIndex = new BlockModelEntry(blockModelLocation, itemModelLocation, new ModelLeaves(), PluginArboriculture.getBlocks().leaves); - Proxies.render.registerBlockModel(blockModelIndex); + ModelManager.getInstance().registerCustomBlockModel(blockModelIndex); } for (BlockDecorativeLeaves leaves : PluginArboriculture.getBlocks().leavesDecorative) { @@ -70,7 +72,7 @@ public class ProxyArboricultureClient extends ProxyArboriculture { ModelResourceLocation itemModeLocation = new ModelResourceLocation(resourceName, "inventory"); BlockModelEntry blockModelIndex = new BlockModelEntry(blockModelLocation, itemModeLocation, new ModelDecorativeLeaves(), leaves); - Proxies.render.registerBlockModel(blockModelIndex); + ModelManager.getInstance().registerCustomBlockModel(blockModelIndex); } ModelLoaderRegistry.registerLoader(WoodModelLoader.INSTANCE); @@ -90,7 +92,7 @@ public class ProxyArboricultureClient extends ProxyArboriculture { public static void registerWoodStateMapper(Block block, IWoodStateMapper stateMapper) { if (block instanceof IWoodTyped) { IWoodTyped woodTyped = (IWoodTyped) block; - Proxies.render.registerStateMapper(block, stateMapper); + ModelLoader.setCustomStateMapper(block, stateMapper); stateMappers.put(woodTyped, stateMapper); } } @@ -129,8 +131,8 @@ public class ProxyArboricultureClient extends ProxyArboriculture { } private void retextureItemModel(IRegistry registry, - ImmutableMap textures, IWoodType woodType, WoodBlockKind woodKind, ItemStack itemStack, - IWoodItemMeshDefinition woodDefinition) { + ImmutableMap textures, IWoodType woodType, WoodBlockKind woodKind, ItemStack itemStack, + IWoodItemMeshDefinition woodDefinition) { if (woodKind != WoodBlockKind.DOOR) { IModel basicItemModel = ModelLoaderRegistry .getModelOrMissing(woodDefinition.getDefaultModelLocation(itemStack)); @@ -142,8 +144,8 @@ public class ProxyArboricultureClient extends ProxyArboriculture { } private void retexturBlockModel(IRegistry registry, - ImmutableMap textures, IWoodType woodType, WoodBlockKind woodKind, IBlockState blockState, - IWoodStateMapper woodMapper) { + ImmutableMap textures, IWoodType woodType, WoodBlockKind woodKind, IBlockState blockState, + IWoodStateMapper woodMapper) { IModel basicModel = ModelLoaderRegistry .getModelOrMissing(woodMapper.getDefaultModelResourceLocation(blockState)); if (basicModel instanceof MultipartModel) { diff --git a/src/main/java/forestry/arboriculture/tiles/TileFruitPod.java b/src/main/java/forestry/arboriculture/tiles/TileFruitPod.java index 9c3c67236..1f57e8cc8 100644 --- a/src/main/java/forestry/arboriculture/tiles/TileFruitPod.java +++ b/src/main/java/forestry/arboriculture/tiles/TileFruitPod.java @@ -37,6 +37,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamable { @@ -134,12 +136,14 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl } @Override + @SideOnly(Side.CLIENT) public void handleUpdateTag(NBTTagCompound tag) { super.handleUpdateTag(tag); NBTUtilForestry.readStreamableFromNbt(this, tag); } @Override + @SideOnly(Side.CLIENT) public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); NBTTagCompound nbt = pkt.getNbtCompound(); diff --git a/src/main/java/forestry/arboriculture/tiles/TileLeaves.java b/src/main/java/forestry/arboriculture/tiles/TileLeaves.java index c9970ae20..f777a7bfc 100644 --- a/src/main/java/forestry/arboriculture/tiles/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/tiles/TileLeaves.java @@ -44,10 +44,10 @@ import forestry.arboriculture.network.IRipeningPacketReceiver; import forestry.arboriculture.network.PacketRipeningUpdate; import forestry.core.network.PacketBufferForestry; import forestry.core.network.packets.PacketTileStream; -import forestry.core.proxy.Proxies; import forestry.core.utils.ClimateUtil; import forestry.core.utils.ColourUtil; import forestry.core.utils.GeneticsUtil; +import forestry.core.utils.NetworkUtil; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -58,6 +58,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TileLeaves extends TileTreeContainer implements IPollinatable, IFruitBearer, IButterflyNursery, IRipeningPacketReceiver { @@ -199,6 +201,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru return tree != null && !isDestroyed(tree, damage) && tree.getMate() != null; } + @SideOnly(Side.CLIENT) public int getFoliageColour(EntityPlayer player) { final boolean showPollinated = isPollinatedState && GeneticsUtil.hasNaturalistEye(player); final int baseColor = getLeafSpriteProvider().getColor(showPollinated); @@ -230,13 +233,13 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru return fruit.getColour(genome, world, getPos(), getRipeningTime()); } - + @SideOnly(Side.CLIENT) public ResourceLocation getLeaveSprite(boolean fancy) { final ILeafSpriteProvider leafSpriteProvider = getLeafSpriteProvider(); return leafSpriteProvider.getSprite(isPollinatedState, fancy); } - + @SideOnly(Side.CLIENT) private ILeafSpriteProvider getLeafSpriteProvider() { if (species != null) { return species.getLeafSpriteProvider(); @@ -307,7 +310,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru /* NETWORK */ private void sendNetworkUpdate() { - Proxies.net.sendNetworkPacket(new PacketTileStream(this), pos, world); + NetworkUtil.sendNetworkPacket(new PacketTileStream(this), pos, world); } private void sendNetworkUpdateRipening() { @@ -318,7 +321,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru colourFruits = newColourFruits; PacketRipeningUpdate ripeningUpdate = new PacketRipeningUpdate(this); - Proxies.net.sendNetworkPacket(ripeningUpdate, pos, world); + NetworkUtil.sendNetworkPacket(ripeningUpdate, pos, world); } private static final short hasFruitFlag = 1; diff --git a/src/main/java/forestry/arboriculture/tiles/TileTreeContainer.java b/src/main/java/forestry/arboriculture/tiles/TileTreeContainer.java index 0bb19c75e..5b6d6f415 100644 --- a/src/main/java/forestry/arboriculture/tiles/TileTreeContainer.java +++ b/src/main/java/forestry/arboriculture/tiles/TileTreeContainer.java @@ -33,6 +33,8 @@ import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * This is the base TE class for any block that needs to contain tree genome information. @@ -135,6 +137,7 @@ public abstract class TileTreeContainer extends TileEntity implements IStreamabl } @Override + @SideOnly(Side.CLIENT) public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); NBTTagCompound nbt = pkt.getNbtCompound(); @@ -148,6 +151,7 @@ public abstract class TileTreeContainer extends TileEntity implements IStreamabl } @Override + @SideOnly(Side.CLIENT) public void handleUpdateTag(NBTTagCompound tag) { super.handleUpdateTag(tag); NBTUtilForestry.readStreamableFromNbt(this, tag); diff --git a/src/main/java/forestry/core/EventHandlerCore.java b/src/main/java/forestry/core/EventHandlerCore.java index b64eb5deb..8e64ca731 100755 --- a/src/main/java/forestry/core/EventHandlerCore.java +++ b/src/main/java/forestry/core/EventHandlerCore.java @@ -20,7 +20,7 @@ import forestry.core.config.Constants; import forestry.core.errors.ErrorStateRegistry; import forestry.core.loot.LootTableLoader; import forestry.core.models.ModelBlockCached; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import forestry.plugins.PluginManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; @@ -96,7 +96,7 @@ public class EventHandlerCore { @SideOnly(Side.CLIENT) public void handleTextureRemap(TextureStitchEvent.Pre event) { ErrorStateRegistry.initSprites(); - TextureManager.initDefaultSprites(); + TextureManagerForestry.initDefaultSprites(); ModelBlockCached.clear(); } diff --git a/src/main/java/forestry/core/PluginCore.java b/src/main/java/forestry/core/PluginCore.java index 22fcbb603..46cd49cc8 100644 --- a/src/main/java/forestry/core/PluginCore.java +++ b/src/main/java/forestry/core/PluginCore.java @@ -53,7 +53,7 @@ import forestry.core.owner.GameProfileDataSerializer; import forestry.core.proxy.Proxies; import forestry.core.recipes.RecipeUtil; import forestry.core.recipes.ShapedRecipeCustom; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import forestry.core.utils.ClimateUtil; import forestry.core.utils.ForestryModEnvWarningCallable; import forestry.core.utils.OreDictUtil; @@ -500,13 +500,14 @@ public class PluginCore extends BlankForestryPlugin { public void onBakeModels(ModelBakeEvent event) { ModelResourceLocation modelLocation = new ModelResourceLocation("forestry:camouflage_spray_can", "inventory"); ModelEntry blockModelIndex = new ModelEntry(modelLocation, new ModelCamouflageSprayCan()); - Proxies.render.registerModel(blockModelIndex); - ModelManager.getInstance().onBakeModels(event); + ModelManager modelManager = ModelManager.getInstance(); + modelManager.registerCustomModel(blockModelIndex); + modelManager.onBakeModels(event); } @SubscribeEvent @SideOnly(Side.CLIENT) public void registerSprites(TextureStitchEvent.Pre event) { - TextureManager.getInstance().registerSprites(); + TextureManagerForestry.getInstance().registerSprites(); } } diff --git a/src/main/java/forestry/core/TickHandlerCoreClient.java b/src/main/java/forestry/core/TickHandlerCoreClient.java index 4bd926ca4..3ed970777 100755 --- a/src/main/java/forestry/core/TickHandlerCoreClient.java +++ b/src/main/java/forestry/core/TickHandlerCoreClient.java @@ -17,7 +17,10 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class TickHandlerCoreClient { private boolean hasNaturalistEye; diff --git a/src/main/java/forestry/core/blocks/BlockBase.java b/src/main/java/forestry/core/blocks/BlockBase.java index e4082e1d2..b94ec95d4 100644 --- a/src/main/java/forestry/core/blocks/BlockBase.java +++ b/src/main/java/forestry/core/blocks/BlockBase.java @@ -18,7 +18,6 @@ import forestry.api.core.ISpriteRegister; import forestry.api.core.IStateMapperRegister; import forestry.api.core.ITextureManager; import forestry.core.circuits.ISocketable; -import forestry.core.proxy.Proxies; import forestry.core.render.MachineParticleCallback; import forestry.core.render.MachineStateMapper; import forestry.core.render.ParticleHelper; @@ -31,6 +30,7 @@ import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.client.particle.ParticleManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.EntityPlayer; @@ -52,6 +52,7 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fluids.FluidActionResult; import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; @@ -232,7 +233,7 @@ public class BlockBase

& IBlockType & IStringSerializable> ext @Override @SideOnly(Side.CLIENT) public void registerStateMapper() { - Proxies.render.registerStateMapper(this, new MachineStateMapper<>(blockType)); + ModelLoader.setCustomStateMapper(this, new MachineStateMapper<>(blockType)); } @Override @@ -302,7 +303,7 @@ public class BlockBase

& IBlockType & IStringSerializable> ext public void registerSprites(ITextureManager manager) { IMachineProperties machineProperties = blockType.getMachineProperties(); if (machineProperties instanceof IMachinePropertiesTesr) { - TextureMap textureMapBlocks = Proxies.common.getClientInstance().getTextureMapBlocks(); + TextureMap textureMapBlocks = Minecraft.getMinecraft().getTextureMapBlocks(); String particleTextureLocation = ((IMachinePropertiesTesr) machineProperties).getParticleTextureLocation(); textureMapBlocks.registerSprite(new ResourceLocation(particleTextureLocation)); } diff --git a/src/main/java/forestry/core/blocks/BlockTypeCoreTesr.java b/src/main/java/forestry/core/blocks/BlockTypeCoreTesr.java index d11c9e636..839f1921c 100644 --- a/src/main/java/forestry/core/blocks/BlockTypeCoreTesr.java +++ b/src/main/java/forestry/core/blocks/BlockTypeCoreTesr.java @@ -10,25 +10,33 @@ ******************************************************************************/ package forestry.core.blocks; -import javax.annotation.Nullable; - import forestry.core.config.Constants; import forestry.core.proxy.Proxies; import forestry.core.tiles.TileAnalyzer; import forestry.core.tiles.TileEscritoire; -import forestry.core.tiles.TileForestry; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; public enum BlockTypeCoreTesr implements IBlockTypeTesr { - ANALYZER(TileAnalyzer.class, "analyzer", Proxies.render.getRendererAnalyzer()), - ESCRITOIRE(TileEscritoire.class, "escritoire", Proxies.render.getRenderEscritoire()); + ANALYZER(createAnalyzerProperties(TileAnalyzer.class, "analyzer")), + ESCRITOIRE(createEscritoireProperties(TileEscritoire.class, "escritoire")); public static final BlockTypeCoreTesr[] VALUES = values(); private final IMachinePropertiesTesr machineProperties; - BlockTypeCoreTesr(Class teClass, String name, @Nullable TileEntitySpecialRenderer renderer) { - this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, Constants.MOD_ID + ":blocks/" + name + ".0"); + private static IMachinePropertiesTesr createAnalyzerProperties(Class teClass, String name) { + MachinePropertiesTesr machineProperties = new MachinePropertiesTesr<>(teClass, name, Constants.MOD_ID + ":blocks/" + name + ".0"); + Proxies.render.setRendererAnalyzer(machineProperties); + return machineProperties; + } + + private static IMachinePropertiesTesr createEscritoireProperties(Class teClass, String name) { + MachinePropertiesTesr machineProperties = new MachinePropertiesTesr<>(teClass, name, Constants.MOD_ID + ":blocks/" + name + ".0"); + Proxies.render.setRenderEscritoire(machineProperties); + return machineProperties; + } + + BlockTypeCoreTesr(IMachinePropertiesTesr machineProperties) { + this.machineProperties = machineProperties; } @Override diff --git a/src/main/java/forestry/core/blocks/IColoredBlock.java b/src/main/java/forestry/core/blocks/IColoredBlock.java index e1de53b34..2d823cca0 100644 --- a/src/main/java/forestry/core/blocks/IColoredBlock.java +++ b/src/main/java/forestry/core/blocks/IColoredBlock.java @@ -5,7 +5,10 @@ import javax.annotation.Nullable; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IColoredBlock { + @SideOnly(Side.CLIENT) int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex); } diff --git a/src/main/java/forestry/core/blocks/IMachineProperties.java b/src/main/java/forestry/core/blocks/IMachineProperties.java index 79b77e9d1..11bfcb2dd 100644 --- a/src/main/java/forestry/core/blocks/IMachineProperties.java +++ b/src/main/java/forestry/core/blocks/IMachineProperties.java @@ -24,10 +24,10 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IMachineProperties extends IStringSerializable { - String getTeIdent(); - Class getTeClass(); /** @@ -35,6 +35,7 @@ public interface IMachineProperties extends IStringSeria */ void registerTileEntity(); + @SideOnly(Side.CLIENT) void registerModel(Item item, IModelManager manager); TileEntity createTileEntity(); diff --git a/src/main/java/forestry/core/blocks/IMachinePropertiesTesr.java b/src/main/java/forestry/core/blocks/IMachinePropertiesTesr.java index 6dbe0a436..93a03a059 100644 --- a/src/main/java/forestry/core/blocks/IMachinePropertiesTesr.java +++ b/src/main/java/forestry/core/blocks/IMachinePropertiesTesr.java @@ -10,18 +10,8 @@ ******************************************************************************/ package forestry.core.blocks; -import javax.annotation.Nullable; - import forestry.core.tiles.TileForestry; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; public interface IMachinePropertiesTesr extends IMachineProperties { - - /** - * @return The renderer from the machine - */ - @Nullable - TileEntitySpecialRenderer getRenderer(); - String getParticleTextureLocation(); } diff --git a/src/main/java/forestry/core/blocks/MachineProperties.java b/src/main/java/forestry/core/blocks/MachineProperties.java index 5aa0bd566..0897fb990 100644 --- a/src/main/java/forestry/core/blocks/MachineProperties.java +++ b/src/main/java/forestry/core/blocks/MachineProperties.java @@ -18,6 +18,8 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class MachineProperties implements IMachineProperties { private final String name; @@ -70,6 +72,7 @@ public class MachineProperties implements IMachineProper } @Override + @SideOnly(Side.CLIENT) public void registerModel(Item item, IModelManager manager) { ResourceLocation itemNameFromRegistry = ItemStackUtil.getItemNameFromRegistry(item); Preconditions.checkNotNull(itemNameFromRegistry, "No registry name for item"); @@ -86,11 +89,6 @@ public class MachineProperties implements IMachineProper } } - @Override - public String getTeIdent() { - return teIdent; - } - @Override public Class getTeClass() { return teClass; diff --git a/src/main/java/forestry/core/blocks/MachinePropertiesTesr.java b/src/main/java/forestry/core/blocks/MachinePropertiesTesr.java index b4d54b7a4..2d44d0fcc 100644 --- a/src/main/java/forestry/core/blocks/MachinePropertiesTesr.java +++ b/src/main/java/forestry/core/blocks/MachinePropertiesTesr.java @@ -13,40 +13,39 @@ import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class MachinePropertiesTesr extends MachineProperties implements IMachinePropertiesTesr { @Nullable - private final TileEntitySpecialRenderer renderer; + @SideOnly(Side.CLIENT) + private TileEntitySpecialRenderer renderer; private final String particleTextureLocation; private final boolean isFullCube; - public MachinePropertiesTesr(Class teClass, String name, @Nullable TileEntitySpecialRenderer renderer, String particleTextureLocation) { - this(teClass, name, renderer, particleTextureLocation, true); + public MachinePropertiesTesr(Class teClass, String name, String particleTextureLocation) { + this(teClass, name, particleTextureLocation, true); } - public MachinePropertiesTesr(Class teClass, String name, @Nullable TileEntitySpecialRenderer renderer, AxisAlignedBB boundingBox, String particleTextureLocation) { - this(teClass, name, renderer, boundingBox, particleTextureLocation, true); + public MachinePropertiesTesr(Class teClass, String name, AxisAlignedBB boundingBox, String particleTextureLocation) { + this(teClass, name, boundingBox, particleTextureLocation, true); } - public MachinePropertiesTesr(Class teClass, String name, @Nullable TileEntitySpecialRenderer renderer, String particleTextureLocation, boolean isFullCube) { + public MachinePropertiesTesr(Class teClass, String name, String particleTextureLocation, boolean isFullCube) { super(teClass, name); - this.renderer = renderer; this.particleTextureLocation = particleTextureLocation; this.isFullCube = isFullCube; } - public MachinePropertiesTesr(Class teClass, String name, @Nullable TileEntitySpecialRenderer renderer, AxisAlignedBB boundingBox, String particleTextureLocation, boolean isFullCube) { + public MachinePropertiesTesr(Class teClass, String name, AxisAlignedBB boundingBox, String particleTextureLocation, boolean isFullCube) { super(teClass, name, boundingBox); - this.renderer = renderer; this.particleTextureLocation = particleTextureLocation; this.isFullCube = isFullCube; } - @Nullable - @Override - public TileEntitySpecialRenderer getRenderer() { - return renderer; + @SideOnly(Side.CLIENT) + public void setRenderer(TileEntitySpecialRenderer renderer) { + this.renderer = renderer; } @Override diff --git a/src/main/java/forestry/core/circuits/CircuitBoard.java b/src/main/java/forestry/core/circuits/CircuitBoard.java index d5411dfe9..9d60fb058 100755 --- a/src/main/java/forestry/core/circuits/CircuitBoard.java +++ b/src/main/java/forestry/core/circuits/CircuitBoard.java @@ -20,10 +20,12 @@ import forestry.api.circuits.ICircuit; import forestry.api.circuits.ICircuitBoard; import forestry.api.circuits.ICircuitLayout; import forestry.api.circuits.ICircuitSocketType; -import forestry.core.proxy.Proxies; import forestry.core.utils.Translator; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class CircuitBoard implements ICircuitBoard { @@ -65,16 +67,19 @@ public class CircuitBoard implements ICircuitBoard { } @Override + @SideOnly(Side.CLIENT) public int getPrimaryColor() { return type.getPrimaryColor(); } @Override + @SideOnly(Side.CLIENT) public int getSecondaryColor() { return type.getSecondaryColor(); } @Override + @SideOnly(Side.CLIENT) public void addTooltip(List list) { if (layout != null) { list.add(TextFormatting.GOLD + layout.getUsage() + ":"); @@ -85,7 +90,7 @@ public class CircuitBoard implements ICircuitBoard { } } - if (Proxies.common.isShiftDown() || extendedTooltip.size() <= 4) { + if (GuiScreen.isShiftKeyDown() || extendedTooltip.size() <= 4) { list.addAll(extendedTooltip); } else { list.add(TextFormatting.ITALIC + "<" + Translator.translateToLocal("for.gui.tooltip.tmi") + ">"); diff --git a/src/main/java/forestry/core/circuits/ContainerSolderingIron.java b/src/main/java/forestry/core/circuits/ContainerSolderingIron.java index 3eb2e998e..6e91a1f45 100755 --- a/src/main/java/forestry/core/circuits/ContainerSolderingIron.java +++ b/src/main/java/forestry/core/circuits/ContainerSolderingIron.java @@ -20,9 +20,11 @@ import forestry.core.network.IForestryPacketClient; import forestry.core.network.IForestryPacketServer; import forestry.core.network.packets.PacketGuiLayoutSelect; import forestry.core.network.packets.PacketGuiSelectRequest; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ContainerSolderingIron extends ContainerItemInventory implements IGuiSelectable { @@ -46,17 +48,20 @@ public class ContainerSolderingIron extends ContainerItemInventory list, boolean flag) { super.addInformation(itemstack, player, list, flag); ICircuitBoard circuitboard = ChipsetManager.circuitRegistry.getCircuitBoard(itemstack); diff --git a/src/main/java/forestry/core/errors/EnumErrorCode.java b/src/main/java/forestry/core/errors/EnumErrorCode.java index c2c2b2154..9d9fa4482 100644 --- a/src/main/java/forestry/core/errors/EnumErrorCode.java +++ b/src/main/java/forestry/core/errors/EnumErrorCode.java @@ -8,7 +8,7 @@ package forestry.core.errors; import forestry.api.core.ForestryAPI; import forestry.api.core.IErrorState; import forestry.core.config.Constants; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; @@ -111,7 +111,7 @@ public enum EnumErrorCode implements IErrorState { @Override public void registerSprite() { ResourceLocation location = new ResourceLocation(Constants.MOD_ID, "gui/errors/" + iconName); - texture = TextureManager.getInstance().registerGuiSprite(location); + texture = TextureManagerForestry.getInstance().registerGuiSprite(location); } @SideOnly(Side.CLIENT) diff --git a/src/main/java/forestry/core/fluids/FakeTankManager.java b/src/main/java/forestry/core/fluids/FakeTankManager.java index b6c776510..b9187b86b 100644 --- a/src/main/java/forestry/core/fluids/FakeTankManager.java +++ b/src/main/java/forestry/core/fluids/FakeTankManager.java @@ -32,7 +32,7 @@ public class FakeTankManager extends EmptyFluidHandler implements ITankManager { } @Override - public void updateGuiData(Container container, List crafters) { + public void sendTankUpdate(Container container, List crafters) { } diff --git a/src/main/java/forestry/core/fluids/FilteredTank.java b/src/main/java/forestry/core/fluids/FilteredTank.java index 160c33742..73711d674 100644 --- a/src/main/java/forestry/core/fluids/FilteredTank.java +++ b/src/main/java/forestry/core/fluids/FilteredTank.java @@ -15,13 +15,16 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; -import forestry.core.proxy.Proxies; +import forestry.core.gui.tooltips.ToolTip; import forestry.core.utils.Translator; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.EnumRarity; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * @author CovertJaguar @@ -66,14 +69,16 @@ public class FilteredTank extends StandardTank { } @Override + @SideOnly(Side.CLIENT) protected void refreshTooltip() { if (hasFluid()) { super.refreshTooltip(); return; } + ToolTip toolTip = getToolTip(); toolTip.clear(); - if (Proxies.common.isShiftDown() || filters.size() < 5) { + if (GuiScreen.isShiftKeyDown() || filters.size() < 5) { for (String filterName : filters) { Fluid fluidFilter = FluidRegistry.getFluid(filterName); EnumRarity rarity = fluidFilter.getRarity(); diff --git a/src/main/java/forestry/core/fluids/Fluids.java b/src/main/java/forestry/core/fluids/Fluids.java index 71bfd99ef..1ab000f96 100644 --- a/src/main/java/forestry/core/fluids/Fluids.java +++ b/src/main/java/forestry/core/fluids/Fluids.java @@ -20,7 +20,6 @@ import java.util.Locale; import java.util.Map; import forestry.core.items.DrinkProperties; -import forestry.core.proxy.Proxies; import forestry.core.render.ForestryResource; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; @@ -230,12 +229,12 @@ public enum Fluids { } public boolean flowTextureExists() { - if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { + if (FMLCommonHandler.instance().getSide() == Side.SERVER) { return true; } try { ResourceLocation resourceLocation = new ForestryResource("blocks/liquid/" + getTag() + "_flow"); - Minecraft minecraft = Proxies.common.getClientInstance(); + Minecraft minecraft = Minecraft.getMinecraft(); if (minecraft != null) { IResourceManager resourceManager = minecraft.getResourceManager(); return resourceManager.getResource(resourceLocation) != null; diff --git a/src/main/java/forestry/core/fluids/ITankManager.java b/src/main/java/forestry/core/fluids/ITankManager.java index af9465b7a..0271a9dbe 100644 --- a/src/main/java/forestry/core/fluids/ITankManager.java +++ b/src/main/java/forestry/core/fluids/ITankManager.java @@ -18,11 +18,13 @@ import net.minecraft.inventory.IContainerListener; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface ITankManager extends IFluidHandler { void containerAdded(Container container, IContainerListener crafter); - void updateGuiData(Container container, List crafters); + void sendTankUpdate(Container container, List crafters); void containerRemoved(Container container); @@ -35,5 +37,6 @@ public interface ITankManager extends IFluidHandler { /** * For updating tanks on the client */ + @SideOnly(Side.CLIENT) void processTankUpdate(int tankIndex, @Nullable FluidStack contents); } diff --git a/src/main/java/forestry/core/fluids/StandardTank.java b/src/main/java/forestry/core/fluids/StandardTank.java index 49ecf2ec1..94c929ba7 100644 --- a/src/main/java/forestry/core/fluids/StandardTank.java +++ b/src/main/java/forestry/core/fluids/StandardTank.java @@ -21,6 +21,8 @@ import net.minecraft.item.EnumRarity; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * @author CovertJaguar @@ -31,6 +33,10 @@ public class StandardTank extends FluidTank implements IStreamable { private ITankUpdateHandler tankUpdateHandler = FakeTankUpdateHandler.instance; private int tankIndex; + @SideOnly(Side.CLIENT) + @Nullable + protected ToolTip toolTip; + public StandardTank(int capacity, boolean canFill, boolean canDrain) { super(capacity); setCanFill(canFill); @@ -102,16 +108,32 @@ public class StandardTank extends FluidTank implements IStreamable { return String.format("Tank: %s, %d/%d", fluid != null && fluid.getFluid() != null ? fluid.getFluid().getName() : "Empty", getFluidAmount(), getCapacity()); } - public ToolTip getToolTip() { - return toolTip; - } - protected boolean hasFluid() { FluidStack fluid = getFluid(); return fluid != null && fluid.amount > 0 && fluid.getFluid() != null; } + @Override + public void writeData(PacketBufferForestry data) { + data.writeFluidStack(fluid); + } + + @Override + public void readData(PacketBufferForestry data) throws IOException { + fluid = data.readFluidStack(); + } + + @SideOnly(Side.CLIENT) + public ToolTip getToolTip() { + if (toolTip == null) { + toolTip = new TankToolTip(this); + } + return toolTip; + } + + @SideOnly(Side.CLIENT) protected void refreshTooltip() { + ToolTip toolTip = getToolTip(); toolTip.clear(); int amount = 0; FluidStack fluidStack = getFluid(); @@ -128,20 +150,17 @@ public class StandardTank extends FluidTank implements IStreamable { toolTip.add(liquidAmount); } - protected final ToolTip toolTip = new ToolTip() { + @SideOnly(Side.CLIENT) + private static class TankToolTip extends ToolTip { + private final StandardTank standardTank; + + public TankToolTip(StandardTank standardTank) { + this.standardTank = standardTank; + } + @Override public void refresh() { - refreshTooltip(); + standardTank.refreshTooltip(); } - }; - - @Override - public void writeData(PacketBufferForestry data) { - data.writeFluidStack(fluid); - } - - @Override - public void readData(PacketBufferForestry data) throws IOException { - fluid = data.readFluidStack(); } } diff --git a/src/main/java/forestry/core/fluids/TankManager.java b/src/main/java/forestry/core/fluids/TankManager.java index 7171a9bce..f2f46a6e0 100644 --- a/src/main/java/forestry/core/fluids/TankManager.java +++ b/src/main/java/forestry/core/fluids/TankManager.java @@ -26,12 +26,12 @@ import forestry.core.network.IForestryPacketClient; import forestry.core.network.IStreamable; import forestry.core.network.PacketBufferForestry; import forestry.core.network.packets.PacketTankLevelUpdate; -import forestry.core.proxy.Proxies; import forestry.core.render.EnumTankLevel; import forestry.core.tiles.ILiquidTankTile; import forestry.core.tiles.IRenderableTile; import forestry.core.utils.NBTUtilForestry; import forestry.core.utils.NBTUtilForestry.NBTList; +import forestry.core.utils.NetworkUtil; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.inventory.IContainerListener; @@ -137,7 +137,7 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl List crafters = Collections.singletonList(player); for (StandardTank tank : tanks) { - sendTankUpdate(container, tank, crafters); + sendTankUpdate(container, crafters, tank); } } @@ -149,13 +149,13 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl } @Override - public void updateGuiData(Container container, List crafters) { + public void sendTankUpdate(Container container, List crafters) { for (StandardTank tank : tanks) { - updateGuiData(container, crafters, tank.getTankIndex()); + sendTankUpdate(container, crafters, tank.getTankIndex()); } } - private void updateGuiData(Container container, List crafters, int tankIndex) { + private void sendTankUpdate(Container container, List crafters, int tankIndex) { StandardTank tank = tanks.get(tankIndex); if (tank == null) { return; @@ -167,17 +167,17 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl return; } - sendTankUpdate(container, tank, crafters); + sendTankUpdate(container, crafters, tank); } - private void sendTankUpdate(Container container, StandardTank tank, Iterable crafters) { + private void sendTankUpdate(Container container, Iterable crafters, StandardTank tank) { if (tile != null) { int tankIndex = tank.getTankIndex(); FluidStack fluid = tank.getFluid(); IForestryPacketClient packet = new PacketTankLevelUpdate(tile, tankIndex, fluid); for (IContainerListener crafter : crafters) { if (crafter instanceof EntityPlayerMP) { - Proxies.net.sendToPlayer(packet, (EntityPlayerMP) crafter); + NetworkUtil.sendToPlayer(packet, (EntityPlayerMP) crafter); } } @@ -243,7 +243,7 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl tankLevels.set(tankIndex, tankLevel); if (sendUpdate) { PacketTankLevelUpdate tankLevelUpdate = new PacketTankLevelUpdate(tile, tankIndex, tank.getFluid()); - Proxies.net.sendNetworkPacket(tankLevelUpdate, tile.getCoordinates(), tile.getWorldObj()); + NetworkUtil.sendNetworkPacket(tankLevelUpdate, tile.getCoordinates(), tile.getWorldObj()); } } } diff --git a/src/main/java/forestry/core/genetics/BreedingTracker.java b/src/main/java/forestry/core/genetics/BreedingTracker.java index 2a462e280..90a79005a 100755 --- a/src/main/java/forestry/core/genetics/BreedingTracker.java +++ b/src/main/java/forestry/core/genetics/BreedingTracker.java @@ -26,7 +26,7 @@ import forestry.api.genetics.IIndividual; import forestry.api.genetics.IMutation; import forestry.api.genetics.ISpeciesRoot; import forestry.core.network.packets.PacketGenomeTrackerSync; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; @@ -106,7 +106,7 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin NBTTagCompound nbttagcompound = new NBTTagCompound(); encodeToNBT(nbttagcompound); PacketGenomeTrackerSync packet = new PacketGenomeTrackerSync(nbttagcompound); - Proxies.net.sendToPlayer(packet, player); + NetworkUtil.sendToPlayer(packet, player); } } @@ -121,7 +121,7 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin NBTTagCompound nbtTagCompound = new NBTTagCompound(); writeToNBT(nbtTagCompound, discoveredSpecies, discoveredMutations, researchedMutations); PacketGenomeTrackerSync packet = new PacketGenomeTrackerSync(nbtTagCompound); - Proxies.net.sendToPlayer(packet, player); + NetworkUtil.sendToPlayer(packet, player); } } } diff --git a/src/main/java/forestry/core/genetics/ItemGE.java b/src/main/java/forestry/core/genetics/ItemGE.java index 3e9bf0ab0..ce7b03a79 100755 --- a/src/main/java/forestry/core/genetics/ItemGE.java +++ b/src/main/java/forestry/core/genetics/ItemGE.java @@ -16,12 +16,14 @@ import java.util.List; import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IIndividual; import forestry.core.items.ItemForestry; -import forestry.core.proxy.Proxies; import forestry.core.utils.Translator; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public abstract class ItemGE extends ItemForestry { protected ItemGE(CreativeTabs creativeTab) { @@ -59,6 +61,7 @@ public abstract class ItemGE extends ItemForestry { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { if (itemstack.getTagCompound() == null) { return; @@ -67,7 +70,7 @@ public abstract class ItemGE extends ItemForestry { IIndividual individual = getIndividual(itemstack); if (individual != null && individual.isAnalyzed()) { - if (Proxies.common.isShiftDown()) { + if (GuiScreen.isShiftKeyDown()) { individual.addTooltip(list); } else { list.add(TextFormatting.ITALIC + "<" + Translator.translateToLocal("for.gui.tooltip.tmi") + ">"); diff --git a/src/main/java/forestry/core/genetics/ItemResearchNote.java b/src/main/java/forestry/core/genetics/ItemResearchNote.java index 66601479a..6a1c20034 100755 --- a/src/main/java/forestry/core/genetics/ItemResearchNote.java +++ b/src/main/java/forestry/core/genetics/ItemResearchNote.java @@ -24,7 +24,7 @@ import forestry.api.genetics.IMutation; import forestry.api.genetics.ISpeciesRoot; import forestry.core.genetics.mutations.EnumMutateChance; import forestry.core.items.ItemForestry; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.PlayerUtil; import forestry.core.utils.Translator; import net.minecraft.entity.player.EntityPlayer; @@ -37,6 +37,8 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemResearchNote extends ItemForestry { @@ -276,6 +278,7 @@ public class ItemResearchNote extends ItemForestry { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { super.addInformation(itemstack, player, list, flag); ResearchNote note = new ResearchNote(itemstack.getTagCompound()); @@ -293,7 +296,7 @@ public class ItemResearchNote extends ItemForestry { if (note.registerResults(worldIn, playerIn)) { playerIn.inventory.decrStackSize(playerIn.inventory.currentItem, 1); // Notify player that his inventory has changed. - Proxies.net.inventoryChangeNotify(playerIn); + NetworkUtil.inventoryChangeNotify(playerIn); } return ActionResult.newResult(EnumActionResult.SUCCESS, heldItem); diff --git a/src/main/java/forestry/core/gui/ContainerForestry.java b/src/main/java/forestry/core/gui/ContainerForestry.java index a1298412c..dac040072 100644 --- a/src/main/java/forestry/core/gui/ContainerForestry.java +++ b/src/main/java/forestry/core/gui/ContainerForestry.java @@ -19,7 +19,7 @@ import forestry.core.gui.slots.SlotFilteredInventory; import forestry.core.gui.slots.SlotForestry; import forestry.core.gui.slots.SlotLocked; import forestry.core.network.IForestryPacketClient; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.SlotUtil; import invtweaks.api.container.ContainerSection; import invtweaks.api.container.ContainerSectionCallback; @@ -95,7 +95,7 @@ public abstract class ContainerForestry extends Container { protected final void sendPacketToListeners(IForestryPacketClient packet) { for (IContainerListener listener : listeners) { if (listener instanceof EntityPlayer) { - Proxies.net.sendToPlayer(packet, (EntityPlayer) listener); + NetworkUtil.sendToPlayer(packet, (EntityPlayer) listener); } } } diff --git a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java index 9806fe828..411dda3d3 100755 --- a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java +++ b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java @@ -17,6 +17,8 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IContainerListener; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.IFluidTank; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public abstract class ContainerLiquidTanks extends ContainerTile implements IContainerLiquidTanks { @@ -28,6 +30,7 @@ public abstract class ContainerLiquidTanks implements IContainerLiquidTanks { @@ -35,10 +37,11 @@ public class ContainerLiquidTanksHelper } @Override + @SideOnly(Side.CLIENT) public void handlePipetteClickClient(int slot, EntityPlayer player) { ItemStack itemstack = player.inventory.getItemStack(); if (itemstack.getItem() instanceof IToolPipette) { - Proxies.net.sendToServer(new PacketPipetteClick(slot)); + NetworkUtil.sendToServer(new PacketPipetteClick(slot)); } } diff --git a/src/main/java/forestry/core/gui/ContainerLiquidTanksSocketed.java b/src/main/java/forestry/core/gui/ContainerLiquidTanksSocketed.java index f9585720b..0948307a7 100644 --- a/src/main/java/forestry/core/gui/ContainerLiquidTanksSocketed.java +++ b/src/main/java/forestry/core/gui/ContainerLiquidTanksSocketed.java @@ -19,6 +19,8 @@ import net.minecraft.inventory.IContainerListener; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.IFluidTank; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public abstract class ContainerLiquidTanksSocketed extends ContainerTile implements IContainerSocketed, IContainerLiquidTanks { @@ -33,6 +35,7 @@ public abstract class ContainerLiquidTanksSocketed extends ContainerTile implements IContainerSocketed { @@ -26,6 +28,7 @@ public abstract class ContainerSocketed exte } @Override + @SideOnly(Side.CLIENT) public void handleChipsetClick(int slot) { helper.handleChipsetClick(slot); } @@ -36,6 +39,7 @@ public abstract class ContainerSocketed exte } @Override + @SideOnly(Side.CLIENT) public void handleSolderingIronClick(int slot) { helper.handleSolderingIronClick(slot); } diff --git a/src/main/java/forestry/core/gui/ContainerSocketedHelper.java b/src/main/java/forestry/core/gui/ContainerSocketedHelper.java index b5bfc5e6f..b1cfd6c10 100644 --- a/src/main/java/forestry/core/gui/ContainerSocketedHelper.java +++ b/src/main/java/forestry/core/gui/ContainerSocketedHelper.java @@ -16,11 +16,13 @@ import forestry.core.circuits.ISocketable; import forestry.core.network.packets.PacketChipsetClick; import forestry.core.network.packets.PacketSocketUpdate; import forestry.core.network.packets.PacketSolderingIronClick; -import forestry.core.proxy.Proxies; import forestry.core.utils.InventoryUtil; +import forestry.core.utils.NetworkUtil; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ContainerSocketedHelper implements IContainerSocketed { @@ -31,8 +33,9 @@ public class ContainerSocketedHelper impleme } @Override + @SideOnly(Side.CLIENT) public void handleChipsetClick(int slot) { - Proxies.net.sendToServer(new PacketChipsetClick(slot)); + NetworkUtil.sendToServer(new PacketChipsetClick(slot)); } @Override @@ -63,12 +66,13 @@ public class ContainerSocketedHelper impleme player.updateHeldItem(); PacketSocketUpdate packet = new PacketSocketUpdate(tile); - Proxies.net.sendToPlayer(packet, player); + NetworkUtil.sendToPlayer(packet, player); } @Override + @SideOnly(Side.CLIENT) public void handleSolderingIronClick(int slot) { - Proxies.net.sendToServer(new PacketSolderingIronClick(slot)); + NetworkUtil.sendToServer(new PacketSolderingIronClick(slot)); } @Override @@ -89,6 +93,6 @@ public class ContainerSocketedHelper impleme player.updateHeldItem(); PacketSocketUpdate packet = new PacketSocketUpdate(tile); - Proxies.net.sendToPlayer(packet, player); + NetworkUtil.sendToPlayer(packet, player); } } diff --git a/src/main/java/forestry/core/gui/ContainerTile.java b/src/main/java/forestry/core/gui/ContainerTile.java index f499d091b..13410c05f 100644 --- a/src/main/java/forestry/core/gui/ContainerTile.java +++ b/src/main/java/forestry/core/gui/ContainerTile.java @@ -25,6 +25,8 @@ import forestry.energy.EnergyManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public abstract class ContainerTile extends ContainerForestry { protected final T tile; @@ -105,6 +107,7 @@ public abstract class ContainerTile extends ContainerFores } } + @SideOnly(Side.CLIENT) public void onGuiEnergy(int energyStored) { if (tile instanceof IPowerHandler) { EnergyManager energyManager = ((IPowerHandler) tile).getEnergyManager(); diff --git a/src/main/java/forestry/core/gui/GuiAlyzer.java b/src/main/java/forestry/core/gui/GuiAlyzer.java index 7011a2442..cbcda6e7b 100755 --- a/src/main/java/forestry/core/gui/GuiAlyzer.java +++ b/src/main/java/forestry/core/gui/GuiAlyzer.java @@ -37,9 +37,9 @@ import forestry.core.genetics.mutations.EnumMutateChance; import forestry.core.gui.widgets.ItemStackWidget; import forestry.core.gui.widgets.WidgetManager; import forestry.core.inventory.ItemInventoryAlyzer; -import forestry.core.proxy.Proxies; import forestry.core.render.ColourProperties; import forestry.core.utils.Translator; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.EntityPlayer; @@ -307,7 +307,7 @@ public class GuiAlyzer extends GuiForestry { int columnWidth = 50; int x = 0; - EntityPlayer player = Proxies.common.getPlayer(); + EntityPlayer player = Minecraft.getMinecraft().player; IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.world, player.getGameProfile()); for (IMutation mutation : speciesRoot.getCombinations(species)) { @@ -356,7 +356,7 @@ public class GuiAlyzer extends GuiForestry { } private void drawQuestionMark(int x, int y) { - Proxies.render.bindTexture(textureFile); + bindTexture(textureFile); drawTexturedModalRect(x, y, 78, 240, 16, 16); } @@ -387,7 +387,7 @@ public class GuiAlyzer extends GuiForestry { } // Probability arrow - Proxies.render.bindTexture(textureFile); + bindTexture(textureFile); drawTexturedModalRect(x, y, column, line, 15, 9); boolean researched = breedingTracker.isResearched(combination); @@ -438,22 +438,22 @@ public class GuiAlyzer extends GuiForestry { } private void drawDownSymbol(int x, int y) { - Proxies.render.bindTexture(textureFile); + bindTexture(textureFile); drawTexturedModalRect(guiLeft + x, guiTop + y, 0, 247, 15, 9); } private void drawUpSymbol(int x, int y) { - Proxies.render.bindTexture(textureFile); + bindTexture(textureFile); drawTexturedModalRect(guiLeft + x, guiTop + y, 15, 247, 15, 9); } private void drawBothSymbol(int x, int y) { - Proxies.render.bindTexture(textureFile); + bindTexture(textureFile); drawTexturedModalRect(guiLeft + x, guiTop + y, 30, 247, 15, 9); } private void drawNoneSymbol(int x, int y) { - Proxies.render.bindTexture(textureFile); + bindTexture(textureFile); drawTexturedModalRect(guiLeft + x, guiTop + y, 45, 247, 15, 9); } @@ -465,7 +465,7 @@ public class GuiAlyzer extends GuiForestry { int stringWidth = fontRendererObj.getStringWidth(fertilityString); - Proxies.render.bindTexture(textureFile); + bindTexture(textureFile); drawTexturedModalRect(guiLeft + x + stringWidth + 2, guiTop + textLayout.getLineY() - 1, 60, 240 + texOffset, 12, 8); textLayout.drawLine(fertilityString, x, textColor); diff --git a/src/main/java/forestry/core/gui/GuiForestry.java b/src/main/java/forestry/core/gui/GuiForestry.java index 414709775..3a43292ed 100755 --- a/src/main/java/forestry/core/gui/GuiForestry.java +++ b/src/main/java/forestry/core/gui/GuiForestry.java @@ -27,15 +27,16 @@ import forestry.core.gui.widgets.TankWidget; import forestry.core.gui.widgets.Widget; import forestry.core.gui.widgets.WidgetManager; import forestry.core.owner.IOwnedTile; -import forestry.core.proxy.Proxies; import forestry.core.render.ColourProperties; import forestry.core.render.ForestryResource; import forestry.core.tiles.IClimatised; import forestry.energy.EnergyManager; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; @@ -232,7 +233,8 @@ public abstract class GuiForestry extends GuiContainer { protected void bindTexture(ResourceLocation texturePath) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - Proxies.render.bindTexture(texturePath); + TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); + textureManager.bindTexture(texturePath); } public void setZLevel(float level) { diff --git a/src/main/java/forestry/core/gui/GuiHandler.java b/src/main/java/forestry/core/gui/GuiHandler.java index 8531fce7c..b630f2312 100644 --- a/src/main/java/forestry/core/gui/GuiHandler.java +++ b/src/main/java/forestry/core/gui/GuiHandler.java @@ -22,6 +22,8 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class GuiHandler implements IGuiHandler { public static void openGui(EntityPlayer entityplayer, IGuiHandlerEntity guiHandler) { @@ -69,6 +71,7 @@ public class GuiHandler implements IGuiHandler { @Override @Nullable + @SideOnly(Side.CLIENT) public Object getClientGuiElement(int guiData, EntityPlayer player, World world, int x, int y, int z) { GuiId guiId = decodeGuiID(guiData); if (guiId == null) { diff --git a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java index cb8ab609b..f871f07c1 100755 --- a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java +++ b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java @@ -26,8 +26,8 @@ import forestry.core.genetics.mutations.EnumMutateChance; import forestry.core.gui.buttons.GuiBetterButton; import forestry.core.gui.buttons.StandardButtonTextureSets; import forestry.core.network.packets.PacketGuiSelectRequest; -import forestry.core.proxy.Proxies; import forestry.core.render.ColourProperties; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.Translator; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.renderer.RenderHelper; @@ -93,7 +93,7 @@ public class GuiNaturalistInventory extends GuiForestry { } private static void flipPage(int page) { - Proxies.net.sendToServer(new PacketGuiSelectRequest(page, 0)); + NetworkUtil.sendToServer(new PacketGuiSelectRequest(page, 0)); } @Override @@ -216,7 +216,7 @@ public class GuiNaturalistInventory extends GuiForestry { column = 196; } - Proxies.render.bindTexture(textureFile); + bindTexture(textureFile); drawTexturedModalRect(guiLeft + x, guiTop + textLayout.getLineY(), column, line, 16, 16); } @@ -247,7 +247,7 @@ public class GuiNaturalistInventory extends GuiForestry { column = 196; } - Proxies.render.bindTexture(textureFile); + bindTexture(textureFile); drawTexturedModalRect(guiLeft + x, guiTop + textLayout.getLineY(), column, line, 16, 16); } diff --git a/src/main/java/forestry/core/gui/GuiUtil.java b/src/main/java/forestry/core/gui/GuiUtil.java index 86ef38873..246941cd9 100644 --- a/src/main/java/forestry/core/gui/GuiUtil.java +++ b/src/main/java/forestry/core/gui/GuiUtil.java @@ -15,14 +15,17 @@ import java.util.List; import forestry.core.gui.tooltips.IToolTipProvider; import forestry.core.gui.tooltips.ToolTip; -import forestry.core.proxy.Proxies; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderItem; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.client.config.GuiUtils; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class GuiUtil { public static void drawItemStack(GuiForestry gui, ItemStack stack, int xPos, int yPos) { FontRenderer font = null; @@ -33,7 +36,7 @@ public class GuiUtil { font = gui.getFontRenderer(); } - RenderItem itemRender = Proxies.common.getClientInstance().getRenderItem(); + RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); itemRender.renderItemAndEffectIntoGUI(stack, xPos, yPos); itemRender.renderItemOverlayIntoGUI(font, stack, xPos, yPos, null); } diff --git a/src/main/java/forestry/core/gui/IContainerLiquidTanks.java b/src/main/java/forestry/core/gui/IContainerLiquidTanks.java index 90c84e5d2..a6ad2ee79 100644 --- a/src/main/java/forestry/core/gui/IContainerLiquidTanks.java +++ b/src/main/java/forestry/core/gui/IContainerLiquidTanks.java @@ -13,8 +13,11 @@ package forestry.core.gui; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.fluids.IFluidTank; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IContainerLiquidTanks { + @SideOnly(Side.CLIENT) void handlePipetteClickClient(int slot, EntityPlayer player); void handlePipetteClick(int slot, EntityPlayerMP player); diff --git a/src/main/java/forestry/core/gui/IContainerSocketed.java b/src/main/java/forestry/core/gui/IContainerSocketed.java index 46cb6ae5b..7f31e6ccb 100644 --- a/src/main/java/forestry/core/gui/IContainerSocketed.java +++ b/src/main/java/forestry/core/gui/IContainerSocketed.java @@ -12,12 +12,16 @@ package forestry.core.gui; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IContainerSocketed { + @SideOnly(Side.CLIENT) void handleChipsetClick(int slot); void handleChipsetClickServer(int slot, EntityPlayerMP player, ItemStack itemstack); + @SideOnly(Side.CLIENT) void handleSolderingIronClick(int slot); void handleSolderingIronClickServer(int slot, EntityPlayerMP player, ItemStack itemstack); diff --git a/src/main/java/forestry/core/gui/IGuiHandlerEntity.java b/src/main/java/forestry/core/gui/IGuiHandlerEntity.java index a44f4639d..c05081f07 100644 --- a/src/main/java/forestry/core/gui/IGuiHandlerEntity.java +++ b/src/main/java/forestry/core/gui/IGuiHandlerEntity.java @@ -10,12 +10,17 @@ ******************************************************************************/ package forestry.core.gui; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IGuiHandlerEntity extends IGuiHandlerForestry { - Object getGui(EntityPlayer player, int data); + @SideOnly(Side.CLIENT) + GuiContainer getGui(EntityPlayer player, int data); - Object getContainer(EntityPlayer player, int data); + Container getContainer(EntityPlayer player, int data); // can't be named getEntityId() for obfuscation reasons int getIdOfEntity(); diff --git a/src/main/java/forestry/core/gui/IGuiHandlerItem.java b/src/main/java/forestry/core/gui/IGuiHandlerItem.java index 2fc2df134..ecb15ef98 100644 --- a/src/main/java/forestry/core/gui/IGuiHandlerItem.java +++ b/src/main/java/forestry/core/gui/IGuiHandlerItem.java @@ -12,13 +12,18 @@ package forestry.core.gui; import javax.annotation.Nullable; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IGuiHandlerItem extends IGuiHandlerForestry { @Nullable - Object getGui(EntityPlayer player, ItemStack heldItem, int data); + @SideOnly(Side.CLIENT) + GuiContainer getGui(EntityPlayer player, ItemStack heldItem, int data); @Nullable - Object getContainer(EntityPlayer player, ItemStack heldItem, int data); + Container getContainer(EntityPlayer player, ItemStack heldItem, int data); } diff --git a/src/main/java/forestry/core/gui/IGuiHandlerTile.java b/src/main/java/forestry/core/gui/IGuiHandlerTile.java index a79819d5b..0e58218e4 100644 --- a/src/main/java/forestry/core/gui/IGuiHandlerTile.java +++ b/src/main/java/forestry/core/gui/IGuiHandlerTile.java @@ -13,12 +13,17 @@ package forestry.core.gui; import javax.annotation.Nullable; import forestry.api.core.ILocatable; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IGuiHandlerTile extends IGuiHandlerForestry, ILocatable { @Nullable - Object getGui(EntityPlayer player, int data); + @SideOnly(Side.CLIENT) + GuiContainer getGui(EntityPlayer player, int data); @Nullable - Object getContainer(EntityPlayer player, int data); + Container getContainer(EntityPlayer player, int data); } diff --git a/src/main/java/forestry/core/gui/TextLayoutHelper.java b/src/main/java/forestry/core/gui/TextLayoutHelper.java index 2e490e7bd..4ff73ee60 100644 --- a/src/main/java/forestry/core/gui/TextLayoutHelper.java +++ b/src/main/java/forestry/core/gui/TextLayoutHelper.java @@ -12,7 +12,10 @@ package forestry.core.gui; import forestry.core.render.ColourProperties; import net.minecraft.client.renderer.GlStateManager; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class TextLayoutHelper { private static final int LINE_HEIGHT = 12; diff --git a/src/main/java/forestry/core/gui/buttons/GuiBetterButton.java b/src/main/java/forestry/core/gui/buttons/GuiBetterButton.java index 676d4c8e9..b4a8a296f 100755 --- a/src/main/java/forestry/core/gui/buttons/GuiBetterButton.java +++ b/src/main/java/forestry/core/gui/buttons/GuiBetterButton.java @@ -84,17 +84,13 @@ public class GuiBetterButton extends GuiButton implements IToolTipProvider { return mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + getWidth() && mouseY < yPosition + getHeight(); } - protected static void bindButtonTextures(Minecraft minecraft) { - minecraft.renderEngine.bindTexture(TEXTURE); - } - @Override public void drawButton(Minecraft minecraft, int mouseX, int mouseY) { if (!visible) { return; } FontRenderer fontrenderer = minecraft.fontRendererObj; - bindButtonTextures(minecraft); + minecraft.getTextureManager().bindTexture(TEXTURE); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); int xOffset = texture.getX(); int yOffset = texture.getY(); diff --git a/src/main/java/forestry/core/gui/ledgers/HintLedger.java b/src/main/java/forestry/core/gui/ledgers/HintLedger.java index 26ab3ccf3..7fa6346c0 100644 --- a/src/main/java/forestry/core/gui/ledgers/HintLedger.java +++ b/src/main/java/forestry/core/gui/ledgers/HintLedger.java @@ -13,8 +13,7 @@ package forestry.core.gui.ledgers; import java.util.List; import java.util.Random; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import forestry.core.utils.Translator; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -32,7 +31,7 @@ public class HintLedger extends Ledger { hintString = Translator.translateToLocal("for.hints." + hint + ".desc"); hintTooltip = Translator.translateToLocal("for.hints." + hint + ".tag"); - Minecraft minecraft = Proxies.common.getClientInstance(); + Minecraft minecraft = Minecraft.getMinecraft(); FontRenderer fontRenderer = minecraft.fontRendererObj; int lineCount = fontRenderer.listFormattedStringToWidth(hintString, maxTextWidth).size(); maxHeight = (lineCount + 1) * fontRenderer.FONT_HEIGHT + 20; @@ -45,7 +44,7 @@ public class HintLedger extends Ledger { drawBackground(x, y); // Draw icon - drawSprite(TextureManager.getInstance().getDefault("misc/hint"), x + 3, y + 4); + drawSprite(TextureManagerForestry.getInstance().getDefault("misc/hint"), x + 3, y + 4); if (!isFullyOpened()) { return; diff --git a/src/main/java/forestry/core/gui/ledgers/Ledger.java b/src/main/java/forestry/core/gui/ledgers/Ledger.java index 9a0c8103e..6f60da758 100644 --- a/src/main/java/forestry/core/gui/ledgers/Ledger.java +++ b/src/main/java/forestry/core/gui/ledgers/Ledger.java @@ -17,17 +17,19 @@ import forestry.core.config.Config; import forestry.core.config.Constants; import forestry.core.config.SessionVars; import forestry.core.gui.GuiForestry; -import forestry.core.proxy.Proxies; import forestry.core.render.ForestryResource; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * Side ledger for guis */ +@SideOnly(Side.CLIENT) public abstract class Ledger { protected static final int minWidth = 24; @@ -142,10 +144,12 @@ public abstract class Ledger { this.y = y; } + @SideOnly(Side.CLIENT) public final void draw() { draw(x, y); } + @SideOnly(Side.CLIENT) public abstract void draw(int x, int y); public abstract String getTooltip(); @@ -198,7 +202,7 @@ public abstract class Ledger { GlStateManager.color(colorR, colorG, colorB, 1.0F); - Proxies.render.bindTexture(texture); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); int height = getHeight(); int width = getWidth(); @@ -213,12 +217,12 @@ public abstract class Ledger { } protected void drawSprite(TextureAtlasSprite sprite, int x, int y) { - drawSprite(TextureManager.getInstance().getGuiTextureMap(), sprite, x, y); + drawSprite(TextureManagerForestry.getInstance().getGuiTextureMap(), sprite, x, y); } protected void drawSprite(ResourceLocation textureMap, TextureAtlasSprite sprite, int x, int y) { GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0F); - Proxies.render.bindTexture(textureMap); + Minecraft.getMinecraft().getTextureManager().bindTexture(textureMap); manager.gui.drawTexturedModalRect(x, y, sprite, 16, 16); } @@ -240,7 +244,7 @@ public abstract class Ledger { protected int drawSplitText(String string, int x, int y, int width, int color, boolean shadow) { int originalY = y; - Minecraft minecraft = Proxies.common.getClientInstance(); + Minecraft minecraft = Minecraft.getMinecraft(); List strings = minecraft.fontRendererObj.listFormattedStringToWidth(string, width); for (Object obj : strings) { if (obj instanceof String) { @@ -252,7 +256,7 @@ public abstract class Ledger { } protected int drawText(String string, int x, int y) { - Minecraft minecraft = Proxies.common.getClientInstance(); + Minecraft minecraft = Minecraft.getMinecraft(); minecraft.fontRendererObj.drawString(string, x, y, fontColorText); return minecraft.fontRendererObj.FONT_HEIGHT; } diff --git a/src/main/java/forestry/core/gui/ledgers/LedgerManager.java b/src/main/java/forestry/core/gui/ledgers/LedgerManager.java index 673331e0f..034a0a8bc 100644 --- a/src/main/java/forestry/core/gui/ledgers/LedgerManager.java +++ b/src/main/java/forestry/core/gui/ledgers/LedgerManager.java @@ -23,7 +23,10 @@ import forestry.core.gui.GuiForestry; import forestry.core.gui.GuiUtil; import forestry.core.gui.tooltips.ToolTip; import net.minecraft.client.renderer.GlStateManager; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class LedgerManager { private final List ledgers = new ArrayList<>(); private final List errorLedgers = new ArrayList<>(); @@ -49,7 +52,7 @@ public class LedgerManager { errorLedgers.add(new ErrorLedger(this)); } } - + public void clear(){ this.ledgers.clear(); } diff --git a/src/main/java/forestry/core/gui/ledgers/OwnerLedger.java b/src/main/java/forestry/core/gui/ledgers/OwnerLedger.java index f5b12a116..7d9ccb715 100644 --- a/src/main/java/forestry/core/gui/ledgers/OwnerLedger.java +++ b/src/main/java/forestry/core/gui/ledgers/OwnerLedger.java @@ -14,7 +14,7 @@ import javax.annotation.Nullable; import com.mojang.authlib.GameProfile; import forestry.core.owner.IOwnedTile; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import forestry.core.utils.PlayerUtil; import forestry.core.utils.Translator; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -44,7 +44,7 @@ public class OwnerLedger extends Ledger { drawBackground(x, y); // Draw icon - TextureAtlasSprite accessIcon = TextureManager.getInstance().getDefault("misc/access.shared"); + TextureAtlasSprite accessIcon = TextureManagerForestry.getInstance().getDefault("misc/access.shared"); drawSprite(accessIcon, x + 3, y + 4); // Draw description diff --git a/src/main/java/forestry/core/gui/ledgers/PowerLedger.java b/src/main/java/forestry/core/gui/ledgers/PowerLedger.java index 3d152f7ad..db48a9dbb 100644 --- a/src/main/java/forestry/core/gui/ledgers/PowerLedger.java +++ b/src/main/java/forestry/core/gui/ledgers/PowerLedger.java @@ -10,7 +10,7 @@ ******************************************************************************/ package forestry.core.gui.ledgers; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import forestry.core.utils.Translator; import forestry.energy.EnergyManager; @@ -29,7 +29,7 @@ public class PowerLedger extends Ledger { drawBackground(x, y); // Draw icon - drawSprite(TextureManager.getInstance().getDefault("misc/energy"), x + 3, y + 4); + drawSprite(TextureManagerForestry.getInstance().getDefault("misc/energy"), x + 3, y + 4); if (!isFullyOpened()) { return; diff --git a/src/main/java/forestry/core/gui/slots/SlotFiltered.java b/src/main/java/forestry/core/gui/slots/SlotFiltered.java index 41a4ec674..b46bb3eba 100644 --- a/src/main/java/forestry/core/gui/slots/SlotFiltered.java +++ b/src/main/java/forestry/core/gui/slots/SlotFiltered.java @@ -12,7 +12,7 @@ package forestry.core.gui.slots; import javax.annotation.Nullable; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import forestry.core.tiles.IFilterSlotDelegate; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.inventory.IInventory; @@ -57,9 +57,9 @@ public class SlotFiltered extends SlotWatched { public TextureAtlasSprite getBackgroundSprite() { ItemStack stack = getStack(); if (!isItemValid(stack)) { - return TextureManager.getInstance().getDefault(blockedTexture); + return TextureManagerForestry.getInstance().getDefault(blockedTexture); } else if (backgroundTexture != null) { - return TextureManager.getInstance().getDefault(backgroundTexture); + return TextureManagerForestry.getInstance().getDefault(backgroundTexture); } else { return null; } diff --git a/src/main/java/forestry/core/gui/slots/SlotForestry.java b/src/main/java/forestry/core/gui/slots/SlotForestry.java index 3c168bb60..212602073 100755 --- a/src/main/java/forestry/core/gui/slots/SlotForestry.java +++ b/src/main/java/forestry/core/gui/slots/SlotForestry.java @@ -14,7 +14,7 @@ import javax.annotation.Nullable; import forestry.core.gui.tooltips.IToolTipProvider; import forestry.core.gui.tooltips.ToolTip; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; @@ -33,8 +33,8 @@ public class SlotForestry extends Slot implements IToolTipProvider { public SlotForestry(IInventory inventory, int slotIndex, int xPos, int yPos) { super(inventory, slotIndex, xPos, yPos); - if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { - setBackgroundLocation(TextureManager.getInstance().getGuiTextureMap()); + if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { + setBackgroundLocation(TextureManagerForestry.getInstance().getGuiTextureMap()); } this.stackLimit = -1; } diff --git a/src/main/java/forestry/core/gui/tooltips/IToolTipProvider.java b/src/main/java/forestry/core/gui/tooltips/IToolTipProvider.java index 22c2e14fa..323049c28 100755 --- a/src/main/java/forestry/core/gui/tooltips/IToolTipProvider.java +++ b/src/main/java/forestry/core/gui/tooltips/IToolTipProvider.java @@ -12,14 +12,20 @@ package forestry.core.gui.tooltips; import javax.annotation.Nullable; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + /** * @author CovertJaguar */ public interface IToolTipProvider { @Nullable + @SideOnly(Side.CLIENT) ToolTip getToolTip(int mouseX, int mouseY); + @SideOnly(Side.CLIENT) boolean isToolTipVisible(); + @SideOnly(Side.CLIENT) boolean isMouseOver(int mouseX, int mouseY); } diff --git a/src/main/java/forestry/core/gui/tooltips/ToolTip.java b/src/main/java/forestry/core/gui/tooltips/ToolTip.java index da4cc6600..cde5d5bc7 100755 --- a/src/main/java/forestry/core/gui/tooltips/ToolTip.java +++ b/src/main/java/forestry/core/gui/tooltips/ToolTip.java @@ -16,10 +16,13 @@ import java.util.Collections; import java.util.List; import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * @author CovertJaguar */ +@SideOnly(Side.CLIENT) public class ToolTip { private final List lines = new ArrayList<>(); diff --git a/src/main/java/forestry/core/gui/widgets/GameTokenWidget.java b/src/main/java/forestry/core/gui/widgets/GameTokenWidget.java index 718d1c60b..70e00481f 100644 --- a/src/main/java/forestry/core/gui/widgets/GameTokenWidget.java +++ b/src/main/java/forestry/core/gui/widgets/GameTokenWidget.java @@ -15,14 +15,19 @@ import javax.annotation.Nullable; import forestry.core.gui.GuiUtil; import forestry.core.gui.tooltips.ToolTip; import forestry.core.network.packets.PacketGuiSelectRequest; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import forestry.core.tiles.EscritoireGame; import forestry.core.tiles.EscritoireGameToken; +import forestry.core.utils.NetworkUtil; +import forestry.core.utils.SoundUtil; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class GameTokenWidget extends Widget { private final ItemStack HIDDEN_TOKEN = new ItemStack(Items.BOOK); @@ -42,6 +47,7 @@ public class GameTokenWidget extends Widget { } @Override + @SideOnly(Side.CLIENT) public void draw(int startX, int startY) { EscritoireGameToken token = getToken(); @@ -55,7 +61,8 @@ public class GameTokenWidget extends Widget { float colorG = (tokenColour >> 8 & 255) / 255.0F; float colorB = (tokenColour & 255) / 255.0F; - Proxies.render.bindTexture(manager.gui.textureFile); + TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); + textureManager.bindTexture(manager.gui.textureFile); GlStateManager.enableDepth(); GlStateManager.color(colorR, colorG, colorB); @@ -70,10 +77,9 @@ public class GameTokenWidget extends Widget { GuiUtil.drawItemStack(manager.gui, tokenStack, startX + xPos + 3, startY + yPos + 3); GlStateManager.disableDepth(); + TextureManagerForestry.getInstance().bindGuiTextureMap(); for (String ident : getToken().getOverlayIcons()) { - TextureManager textureManager = TextureManager.getInstance(); - Proxies.render.bindTexture(textureManager.getGuiTextureMap()); - TextureAtlasSprite icon = textureManager.getDefault(ident); + TextureAtlasSprite icon = TextureManagerForestry.getInstance().getDefault(ident); manager.gui.drawTexturedModalRect(startX + xPos + 3, startY + yPos + 3, icon, 16, 16); } GlStateManager.enableDepth(); @@ -94,7 +100,7 @@ public class GameTokenWidget extends Widget { @Override public void handleMouseClick(int mouseX, int mouseY, int mouseButton) { game.choose(index); - Proxies.net.sendToServer(new PacketGuiSelectRequest(index, 0)); - Proxies.common.playButtonClick(); + NetworkUtil.sendToServer(new PacketGuiSelectRequest(index, 0)); + SoundUtil.playButtonClick(); } } diff --git a/src/main/java/forestry/core/gui/widgets/ItemStackWidgetBase.java b/src/main/java/forestry/core/gui/widgets/ItemStackWidgetBase.java index 845b29ea8..699fe175b 100644 --- a/src/main/java/forestry/core/gui/widgets/ItemStackWidgetBase.java +++ b/src/main/java/forestry/core/gui/widgets/ItemStackWidgetBase.java @@ -12,7 +12,6 @@ package forestry.core.gui.widgets; import forestry.core.gui.GuiUtil; import forestry.core.gui.tooltips.ToolTip; -import forestry.core.proxy.Proxies; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -37,7 +36,7 @@ public abstract class ItemStackWidgetBase extends Widget { @SideOnly(Side.CLIENT) @Override public ToolTip getToolTip(int mouseX, int mouseY) { - Minecraft minecraft = Proxies.common.getClientInstance(); + Minecraft minecraft = Minecraft.getMinecraft(); EntityPlayer player = minecraft.player; ItemStack itemStack = getItemStack(); ToolTip tip = new ToolTip(); diff --git a/src/main/java/forestry/core/gui/widgets/ProbeButton.java b/src/main/java/forestry/core/gui/widgets/ProbeButton.java index f0cdcd0d3..a043fbe93 100644 --- a/src/main/java/forestry/core/gui/widgets/ProbeButton.java +++ b/src/main/java/forestry/core/gui/widgets/ProbeButton.java @@ -13,9 +13,12 @@ package forestry.core.gui.widgets; import forestry.core.gui.GuiEscritoire; import forestry.core.gui.tooltips.ToolTip; import forestry.core.network.packets.PacketGuiSelectRequest; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; +import forestry.core.utils.SoundUtil; import forestry.core.utils.Translator; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.texture.TextureManager; public class ProbeButton extends Widget { @@ -32,7 +35,8 @@ public class ProbeButton extends Widget { @Override public void draw(int startX, int startY) { GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0F); - Proxies.render.bindTexture(manager.gui.textureFile); + TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); + textureManager.bindTexture(manager.gui.textureFile); manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, 228, pressed ? 47 : 22, width, height); } @@ -46,8 +50,8 @@ public class ProbeButton extends Widget { @Override public void handleMouseClick(int mouseX, int mouseY, int mouseButton) { pressed = true; - Proxies.net.sendToServer(new PacketGuiSelectRequest(-1, 0)); - Proxies.common.playButtonClick(); + NetworkUtil.sendToServer(new PacketGuiSelectRequest(-1, 0)); + SoundUtil.playButtonClick(); } @Override diff --git a/src/main/java/forestry/core/gui/widgets/SocketWidget.java b/src/main/java/forestry/core/gui/widgets/SocketWidget.java index d95351260..adfb2cea3 100755 --- a/src/main/java/forestry/core/gui/widgets/SocketWidget.java +++ b/src/main/java/forestry/core/gui/widgets/SocketWidget.java @@ -15,7 +15,6 @@ import forestry.core.circuits.ISolderingIron; import forestry.core.circuits.ItemCircuitBoard; import forestry.core.gui.IContainerSocketed; import forestry.core.gui.tooltips.ToolTip; -import forestry.core.proxy.Proxies; import forestry.core.utils.Translator; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; @@ -41,7 +40,7 @@ public class SocketWidget extends Widget { public void draw(int startX, int startY) { ItemStack socketStack = tile.getSocket(slot); if (!socketStack.isEmpty()) { - Proxies.common.getClientInstance().getRenderItem().renderItemIntoGUI(socketStack, startX + xPos, startY + yPos); + Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(socketStack, startX + xPos, startY + yPos); } } @@ -58,7 +57,7 @@ public class SocketWidget extends Widget { toolTip.clear(); ItemStack stack = tile.getSocket(slot); if (!stack.isEmpty()) { - Minecraft minecraft = Proxies.common.getClientInstance(); + Minecraft minecraft = Minecraft.getMinecraft(); EntityPlayer player = minecraft.player; toolTip.add(stack.getTooltip(player, minecraft.gameSettings.advancedItemTooltips)); toolTip.add(TextFormatting.ITALIC + Translator.translateToLocal("for.gui.socket.remove")); diff --git a/src/main/java/forestry/core/gui/widgets/TankWidget.java b/src/main/java/forestry/core/gui/widgets/TankWidget.java index 275f31232..6567c7631 100755 --- a/src/main/java/forestry/core/gui/widgets/TankWidget.java +++ b/src/main/java/forestry/core/gui/widgets/TankWidget.java @@ -16,7 +16,6 @@ import forestry.api.core.IToolPipette; import forestry.core.fluids.StandardTank; import forestry.core.gui.IContainerLiquidTanks; import forestry.core.gui.tooltips.ToolTip; -import forestry.core.proxy.Proxies; import forestry.farming.gui.ContainerFarm; import forestry.greenhouse.gui.ContainerGreenhouse; import net.minecraft.client.Minecraft; @@ -24,6 +23,7 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.player.EntityPlayer; @@ -34,10 +34,13 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidTank; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * Slot for liquid tanks */ +@SideOnly(Side.CLIENT) public class TankWidget extends Widget { private int overlayTexX = 176; @@ -79,10 +82,12 @@ public class TankWidget extends Widget { } FluidStack contents = tank.getFluid(); + Minecraft minecraft = Minecraft.getMinecraft(); + TextureManager textureManager = minecraft.getTextureManager(); if (contents != null && contents.amount > 0 && contents.getFluid() != null) { Fluid fluid = contents.getFluid(); if (fluid != null) { - TextureMap textureMapBlocks = Minecraft.getMinecraft().getTextureMapBlocks(); + TextureMap textureMapBlocks = minecraft.getTextureMapBlocks(); ResourceLocation fluidStill = fluid.getStill(); TextureAtlasSprite fluidStillSprite = null; if (fluidStill != null) { @@ -102,7 +107,7 @@ public class TankWidget extends Widget { scaledAmount = height; } - Proxies.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); setGLColorFromInt(fluidColor); final int xTileCount = width / 16; @@ -131,7 +136,7 @@ public class TankWidget extends Widget { if (drawOverlay) { GlStateManager.disableDepth(); - Proxies.render.bindTexture(manager.gui.textureFile); + textureManager.bindTexture(manager.gui.textureFile); manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, overlayTexX, overlayTexY, 16, 60); GlStateManager.enableDepth(); } @@ -145,7 +150,8 @@ public class TankWidget extends Widget { if (!(tank instanceof StandardTank)) { return null; } - return ((StandardTank) tank).getToolTip(); + StandardTank standardTank = (StandardTank) tank; + return standardTank.getToolTip(); } private static void setGLColorFromInt(int color) { @@ -156,7 +162,6 @@ public class TankWidget extends Widget { GlStateManager.color(red, green, blue, 1.0F); } - private static void drawFluidTexture(double xCoord, double yCoord, TextureAtlasSprite textureSprite, int maskTop, int maskRight, double zLevel) { double uMin = textureSprite.getMinU(); double uMax = textureSprite.getMaxU(); diff --git a/src/main/java/forestry/core/gui/widgets/Widget.java b/src/main/java/forestry/core/gui/widgets/Widget.java index 4ab8091ae..5ac569c69 100755 --- a/src/main/java/forestry/core/gui/widgets/Widget.java +++ b/src/main/java/forestry/core/gui/widgets/Widget.java @@ -14,10 +14,13 @@ import javax.annotation.Nullable; import forestry.core.gui.tooltips.IToolTipProvider; import forestry.core.gui.tooltips.ToolTip; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * Basic non-ItemStack slot */ +@SideOnly(Side.CLIENT) public abstract class Widget implements IToolTipProvider { protected final WidgetManager manager; protected final int xPos; diff --git a/src/main/java/forestry/core/gui/widgets/WidgetCamouflageSlot.java b/src/main/java/forestry/core/gui/widgets/WidgetCamouflageSlot.java index f337f74fc..cc85e42c9 100644 --- a/src/main/java/forestry/core/gui/widgets/WidgetCamouflageSlot.java +++ b/src/main/java/forestry/core/gui/widgets/WidgetCamouflageSlot.java @@ -15,11 +15,11 @@ import forestry.api.core.ICamouflageHandler; import forestry.api.core.ICamouflageItemHandler; import forestry.api.multiblock.IMultiblockController; import forestry.core.gui.tooltips.ToolTip; -import forestry.core.proxy.Proxies; import forestry.core.utils.Translator; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.RenderItem; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -39,11 +39,14 @@ public class WidgetCamouflageSlot extends Widget { } @Override + @SideOnly(Side.CLIENT) public void draw(int startX, int startY) { ItemStack camouflageBlock = camouflageHandler.getCamouflageBlock(type); if (!camouflageBlock.isEmpty()) { - Proxies.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - RenderItem renderItem = Proxies.common.getClientInstance().getRenderItem(); + Minecraft minecraft = Minecraft.getMinecraft(); + TextureManager textureManager = minecraft.getTextureManager(); + textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + RenderItem renderItem = minecraft.getRenderItem(); renderItem.renderItemIntoGUI(camouflageBlock, startX + xPos, startY + yPos); } } @@ -92,7 +95,7 @@ public class WidgetCamouflageSlot extends Widget { if (camouflageBlock.isEmpty()) { toolTip.add(TextFormatting.ITALIC.toString() + Translator.translateToLocal("for.gui.empty")); } else { - Minecraft minecraft = Proxies.common.getClientInstance(); + Minecraft minecraft = Minecraft.getMinecraft(); toolTip.add(TextFormatting.ITALIC.toString() + camouflageBlock.getTooltip(minecraft.player, minecraft.gameSettings.advancedItemTooltips)); } } diff --git a/src/main/java/forestry/core/gui/widgets/WidgetManager.java b/src/main/java/forestry/core/gui/widgets/WidgetManager.java index 3a72525c2..29fe24cd2 100644 --- a/src/main/java/forestry/core/gui/widgets/WidgetManager.java +++ b/src/main/java/forestry/core/gui/widgets/WidgetManager.java @@ -15,9 +15,11 @@ import java.util.ArrayList; import java.util.List; import forestry.core.gui.GuiForestry; -import forestry.core.proxy.Proxies; import net.minecraft.client.Minecraft; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class WidgetManager { public final GuiForestry gui; @@ -26,7 +28,7 @@ public class WidgetManager { public WidgetManager(GuiForestry gui) { this.gui = gui; - this.minecraft = Proxies.common.getClientInstance(); + this.minecraft = Minecraft.getMinecraft(); } public void add(Widget slot) { diff --git a/src/main/java/forestry/core/inventory/ItemInventoryCamouflageSprayCan.java b/src/main/java/forestry/core/inventory/ItemInventoryCamouflageSprayCan.java index f150ba250..ed0655ff7 100644 --- a/src/main/java/forestry/core/inventory/ItemInventoryCamouflageSprayCan.java +++ b/src/main/java/forestry/core/inventory/ItemInventoryCamouflageSprayCan.java @@ -3,8 +3,8 @@ package forestry.core.inventory; import forestry.api.core.ICamouflageHandler; import forestry.core.network.packets.CamouflageSelectionType; import forestry.core.network.packets.PacketCamouflageSelectServer; -import forestry.core.proxy.Proxies; import forestry.core.utils.ItemStackUtil; +import forestry.core.utils.NetworkUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -38,7 +38,7 @@ public class ItemInventoryCamouflageSprayCan extends ItemInventory implements IC World world = player.world; if (sendClientUpdate && world != null && world.isRemote) { - Proxies.net.sendToServer(new PacketCamouflageSelectServer(this, type, CamouflageSelectionType.ITEM)); + NetworkUtil.sendToServer(new PacketCamouflageSelectServer(this, type, CamouflageSelectionType.ITEM)); } return true; } diff --git a/src/main/java/forestry/core/items/IColoredItem.java b/src/main/java/forestry/core/items/IColoredItem.java index 0661f2e9f..2a4ff712f 100644 --- a/src/main/java/forestry/core/items/IColoredItem.java +++ b/src/main/java/forestry/core/items/IColoredItem.java @@ -1,7 +1,10 @@ package forestry.core.items; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IColoredItem { + @SideOnly(Side.CLIENT) int getColorFromItemstack(ItemStack stack, int tintIndex); } diff --git a/src/main/java/forestry/core/items/ItemAlyzer.java b/src/main/java/forestry/core/items/ItemAlyzer.java index c1e6a0833..425154821 100644 --- a/src/main/java/forestry/core/items/ItemAlyzer.java +++ b/src/main/java/forestry/core/items/ItemAlyzer.java @@ -14,8 +14,12 @@ import forestry.api.core.Tabs; import forestry.core.gui.ContainerAlyzer; import forestry.core.gui.GuiAlyzer; import forestry.core.inventory.ItemInventoryAlyzer; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemAlyzer extends ItemWithGui { public ItemAlyzer() { @@ -28,12 +32,13 @@ public class ItemAlyzer extends ItemWithGui { } @Override - public Object getGui(EntityPlayer player, ItemStack heldItem, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, ItemStack heldItem, int data) { return new GuiAlyzer(player, new ItemInventoryAlyzer(player, heldItem)); } @Override - public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) { + public Container getContainer(EntityPlayer player, ItemStack heldItem, int data) { return new ContainerAlyzer(new ItemInventoryAlyzer(player, heldItem), player); } } diff --git a/src/main/java/forestry/core/items/ItemArmorNaturalist.java b/src/main/java/forestry/core/items/ItemArmorNaturalist.java index d9335652c..93ef9c56f 100755 --- a/src/main/java/forestry/core/items/ItemArmorNaturalist.java +++ b/src/main/java/forestry/core/items/ItemArmorNaturalist.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.core.items; -import java.util.List; - import javax.annotation.Nullable; +import java.util.List; import forestry.api.arboriculture.ArboricultureCapabilities; import forestry.api.core.IItemModelRegister; @@ -58,6 +57,7 @@ public class ItemArmorNaturalist extends ItemArmor implements IItemModelRegister } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { ItemTooltipUtil.addInformation(stack, playerIn, tooltip, advanced); } diff --git a/src/main/java/forestry/core/items/ItemBlockForestry.java b/src/main/java/forestry/core/items/ItemBlockForestry.java index d8f7fc2db..c7de3e3b5 100644 --- a/src/main/java/forestry/core/items/ItemBlockForestry.java +++ b/src/main/java/forestry/core/items/ItemBlockForestry.java @@ -25,6 +25,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemBlockForestry extends ItemBlock { @@ -57,6 +59,7 @@ public class ItemBlockForestry extends ItemBlock { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { super.addInformation(stack, playerIn, tooltip, advanced); ItemTooltipUtil.addInformation(stack, playerIn, tooltip, advanced); diff --git a/src/main/java/forestry/core/items/ItemBlockNBT.java b/src/main/java/forestry/core/items/ItemBlockNBT.java index 0c8500a05..01596d970 100644 --- a/src/main/java/forestry/core/items/ItemBlockNBT.java +++ b/src/main/java/forestry/core/items/ItemBlockNBT.java @@ -15,6 +15,8 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemBlockNBT extends ItemBlockForestry { @@ -23,6 +25,7 @@ public class ItemBlockNBT extends ItemBlockForestry { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer player, List info, boolean advanced) { super.addInformation(itemstack, player, info, advanced); diff --git a/src/main/java/forestry/core/items/ItemCamouflageSprayCan.java b/src/main/java/forestry/core/items/ItemCamouflageSprayCan.java index 96e5cc6a9..f4b282766 100644 --- a/src/main/java/forestry/core/items/ItemCamouflageSprayCan.java +++ b/src/main/java/forestry/core/items/ItemCamouflageSprayCan.java @@ -6,8 +6,10 @@ import forestry.api.core.IModelManager; import forestry.core.gui.ContainerCamouflageSprayCan; import forestry.core.gui.GuiCamouflageSprayCan; import forestry.core.inventory.ItemInventoryCamouflageSprayCan; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -18,20 +20,24 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemCamouflageSprayCan extends ItemWithGui { @Override - public Object getGui(EntityPlayer player, ItemStack heldItem, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, ItemStack heldItem, int data) { return new GuiCamouflageSprayCan(player, new ItemInventoryCamouflageSprayCan(player, heldItem)); } @Override - public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) { + public Container getContainer(EntityPlayer player, ItemStack heldItem, int data) { return new ContainerCamouflageSprayCan(new ItemInventoryCamouflageSprayCan(player, heldItem), player.inventory); } @Override + @SideOnly(Side.CLIENT) public void registerModel(Item item, IModelManager manager) { super.registerModel(item, manager); ModelBakery.registerItemVariants(item, new ResourceLocation("forestry:camouflage_spray_can_filled")); diff --git a/src/main/java/forestry/core/items/ItemCrated.java b/src/main/java/forestry/core/items/ItemCrated.java index 6915e692a..5c8059dc6 100755 --- a/src/main/java/forestry/core/items/ItemCrated.java +++ b/src/main/java/forestry/core/items/ItemCrated.java @@ -13,9 +13,9 @@ package forestry.core.items; import javax.annotation.Nullable; import forestry.api.core.IModelManager; -import forestry.core.proxy.Proxies; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Translator; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.color.ItemColors; @@ -71,7 +71,7 @@ public class ItemCrated extends ItemForestry implements IColoredItem { if (contained.isEmpty()) { return Translator.translateToLocal("item.for.crate.name"); } else { - String containedName = Proxies.common.getDisplayName(contained); + String containedName = contained.getDisplayName(); return Translator.translateToLocalFormatted("for.item.crated.grammar", containedName); } } @@ -90,8 +90,9 @@ public class ItemCrated extends ItemForestry implements IColoredItem { } @Override + @SideOnly(Side.CLIENT) public int getColorFromItemstack(ItemStack stack, int renderPass) { - ItemColors colors = Proxies.common.getClientInstance().getItemColors(); + ItemColors colors = Minecraft.getMinecraft().getItemColors(); if (contained.isEmpty() || renderPass == 100) { return -1; } diff --git a/src/main/java/forestry/core/items/ItemElectronTube.java b/src/main/java/forestry/core/items/ItemElectronTube.java index 92ef9e75b..6fe39719f 100644 --- a/src/main/java/forestry/core/items/ItemElectronTube.java +++ b/src/main/java/forestry/core/items/ItemElectronTube.java @@ -21,14 +21,16 @@ import forestry.api.circuits.ICircuitLayout; import forestry.core.CreativeTabForestry; import forestry.core.circuits.SolderManager; import forestry.core.config.Config; -import forestry.core.proxy.Proxies; import forestry.core.utils.Translator; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemElectronTube extends ItemOverlay { @@ -37,11 +39,12 @@ public class ItemElectronTube extends ItemOverlay { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { super.addInformation(itemstack, player, list, flag); Multimap circuits = getCircuits(itemstack); if (!circuits.isEmpty()) { - if (Proxies.common.isShiftDown()) { + if (GuiScreen.isShiftKeyDown()) { for (ICircuitLayout circuitLayout : circuits.keys()) { String circuitLayoutName = circuitLayout.getUsage(); list.add(TextFormatting.WHITE.toString() + TextFormatting.UNDERLINE + circuitLayoutName); diff --git a/src/main/java/forestry/core/items/ItemForestry.java b/src/main/java/forestry/core/items/ItemForestry.java index 66511bce0..06fa37eec 100755 --- a/src/main/java/forestry/core/items/ItemForestry.java +++ b/src/main/java/forestry/core/items/ItemForestry.java @@ -52,6 +52,7 @@ public class ItemForestry extends Item implements IItemModelRegister { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { super.addInformation(stack, playerIn, tooltip, advanced); ItemTooltipUtil.addInformation(stack, playerIn, tooltip, advanced); diff --git a/src/main/java/forestry/core/items/ItemFruit.java b/src/main/java/forestry/core/items/ItemFruit.java index e872b4ae5..db8043de7 100755 --- a/src/main/java/forestry/core/items/ItemFruit.java +++ b/src/main/java/forestry/core/items/ItemFruit.java @@ -41,6 +41,7 @@ public class ItemFruit extends ItemForestryFood { this.oreDict = oreDict; } + @SideOnly(Side.CLIENT) public static void registerModel(Item item, IModelManager manager) { for (int i = 0; i < VALUES.length; i++) { EnumFruit fruit = VALUES[i]; diff --git a/src/main/java/forestry/core/items/ItemPipette.java b/src/main/java/forestry/core/items/ItemPipette.java index b40f9f21b..1e4beb133 100755 --- a/src/main/java/forestry/core/items/ItemPipette.java +++ b/src/main/java/forestry/core/items/ItemPipette.java @@ -47,6 +47,7 @@ public class ItemPipette extends ItemForestry implements IToolPipette { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { super.addInformation(itemstack, player, list, flag); @@ -69,6 +70,7 @@ public class ItemPipette extends ItemForestry implements IToolPipette { manager.registerItemModel(item, new PipetteMeshDefinition()); } + @SideOnly(Side.CLIENT) public class PipetteMeshDefinition implements ItemMeshDefinition { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { diff --git a/src/main/java/forestry/core/items/ItemSolderingIron.java b/src/main/java/forestry/core/items/ItemSolderingIron.java index f8244ddc2..a8983dbbd 100644 --- a/src/main/java/forestry/core/items/ItemSolderingIron.java +++ b/src/main/java/forestry/core/items/ItemSolderingIron.java @@ -14,17 +14,22 @@ import forestry.core.circuits.ContainerSolderingIron; import forestry.core.circuits.GuiSolderingIron; import forestry.core.circuits.ISolderingIron; import forestry.core.inventory.ItemInventorySolderingIron; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemSolderingIron extends ItemWithGui implements ISolderingIron { @Override - public Object getGui(EntityPlayer player, ItemStack heldItem, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, ItemStack heldItem, int data) { return new GuiSolderingIron(player, new ItemInventorySolderingIron(player, heldItem)); } @Override - public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) { + public Container getContainer(EntityPlayer player, ItemStack heldItem, int data) { return new ContainerSolderingIron(player, new ItemInventorySolderingIron(player, heldItem)); } } diff --git a/src/main/java/forestry/core/models/ModelBlockCached.java b/src/main/java/forestry/core/models/ModelBlockCached.java index ce4576322..d97ca2779 100644 --- a/src/main/java/forestry/core/models/ModelBlockCached.java +++ b/src/main/java/forestry/core/models/ModelBlockCached.java @@ -11,7 +11,10 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public abstract class ModelBlockCached extends ModelBlockDefault { private static final Set CACHE_PROVIDERS = new HashSet<>(); diff --git a/src/main/java/forestry/core/models/ModelBlockDefault.java b/src/main/java/forestry/core/models/ModelBlockDefault.java index 86ef4057e..dc373d392 100644 --- a/src/main/java/forestry/core/models/ModelBlockDefault.java +++ b/src/main/java/forestry/core/models/ModelBlockDefault.java @@ -20,7 +20,6 @@ import forestry.api.core.IModelBakerModel; import forestry.core.blocks.properties.UnlistedBlockAccess; import forestry.core.blocks.properties.UnlistedBlockPos; import forestry.core.models.baker.ModelBaker; -import forestry.core.proxy.Proxies; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -36,7 +35,10 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.property.IExtendedBlockState; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public abstract class ModelBlockDefault implements IBakedModel { @Nullable private ItemOverrideList overrideList; @@ -161,7 +163,7 @@ public abstract class ModelBlockDefault implements IBakedMod @Override public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) { if (world == null) { - world = Proxies.common.getRenderWorld(); + world = Minecraft.getMinecraft().world; } return getModel(stack, world); } diff --git a/src/main/java/forestry/core/models/ModelEscritoire.java b/src/main/java/forestry/core/models/ModelEscritoire.java index a145e70b3..7a9dbeb84 100644 --- a/src/main/java/forestry/core/models/ModelEscritoire.java +++ b/src/main/java/forestry/core/models/ModelEscritoire.java @@ -15,7 +15,10 @@ import javax.annotation.Nullable; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class ModelEscritoire extends ModelBase { //fields diff --git a/src/main/java/forestry/core/models/ModelManager.java b/src/main/java/forestry/core/models/ModelManager.java index 7884d2c7e..d20e11ac6 100644 --- a/src/main/java/forestry/core/models/ModelManager.java +++ b/src/main/java/forestry/core/models/ModelManager.java @@ -30,6 +30,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.statemap.StateMapperBase; import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.renderer.color.IItemColor; @@ -181,6 +182,10 @@ public class ModelManager implements IModelManager { public void registerCustomBlockModel(BlockModelEntry index) { customBlockModels.add(index); + if (index.addStateMapper) { + StateMapperBase ignoreState = new BlockModeStateMapper(index); + ModelLoader.setCustomStateMapper(index.block, ignoreState); + } } public void registerCustomModel(ModelEntry index) { @@ -242,4 +247,16 @@ public class ModelManager implements IModelManager { } } + private static class BlockModeStateMapper extends StateMapperBase { + private final BlockModelEntry index; + + public BlockModeStateMapper(BlockModelEntry index) { + this.index = index; + } + + @Override + protected ModelResourceLocation getModelResourceLocation(IBlockState iBlockState) { + return index.blockModelLocation; + } + } } diff --git a/src/main/java/forestry/core/models/TRSRBakedModel.java b/src/main/java/forestry/core/models/TRSRBakedModel.java index edf9f4b42..8541a9c44 100644 --- a/src/main/java/forestry/core/models/TRSRBakedModel.java +++ b/src/main/java/forestry/core/models/TRSRBakedModel.java @@ -35,8 +35,11 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad; import net.minecraftforge.client.model.pipeline.VertexTransformer; import net.minecraftforge.common.model.TRSRTransformation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; // for those wondering TRSR stands for Translation Rotation Scale Rotation +@SideOnly(Side.CLIENT) public class TRSRBakedModel implements IBakedModel { protected final ImmutableList general; diff --git a/src/main/java/forestry/core/models/baker/ModelBaker.java b/src/main/java/forestry/core/models/baker/ModelBaker.java index 6b4ed0b71..ff79a0f5d 100644 --- a/src/main/java/forestry/core/models/baker/ModelBaker.java +++ b/src/main/java/forestry/core/models/baker/ModelBaker.java @@ -17,7 +17,6 @@ import java.util.List; import forestry.api.core.IModelBaker; import forestry.api.core.IModelBakerModel; import forestry.core.models.ModelManager; -import forestry.core.proxy.Proxies; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.BakedQuad; @@ -78,7 +77,7 @@ public final class ModelBaker implements IModelBaker { setColorIndex(colorIndex); if (pos != null) { - World world = Proxies.common.getRenderWorld(); + World world = Minecraft.getMinecraft().world; IBlockState state = world.getBlockState(pos); for (EnumFacing facing : EnumFacing.VALUES) { if (state.shouldSideBeRendered(world, pos, facing)) { diff --git a/src/main/java/forestry/core/multiblock/MultiblockClientTickHandler.java b/src/main/java/forestry/core/multiblock/MultiblockClientTickHandler.java index e34cea371..f9c97c093 100644 --- a/src/main/java/forestry/core/multiblock/MultiblockClientTickHandler.java +++ b/src/main/java/forestry/core/multiblock/MultiblockClientTickHandler.java @@ -3,7 +3,10 @@ package forestry.core.multiblock; import net.minecraft.client.Minecraft; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class MultiblockClientTickHandler { @SubscribeEvent diff --git a/src/main/java/forestry/core/multiblock/MultiblockControllerBase.java b/src/main/java/forestry/core/multiblock/MultiblockControllerBase.java index 210aef68d..6248b8ed6 100644 --- a/src/main/java/forestry/core/multiblock/MultiblockControllerBase.java +++ b/src/main/java/forestry/core/multiblock/MultiblockControllerBase.java @@ -19,6 +19,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.IChunkProvider; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * This class contains the base logic for "multiblock controllers". Conceptually, they are @@ -476,6 +478,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI * Client-side update loop. Generally, this shouldn't do anything, but if you want * to do some interpolation or something, do it here. */ + @SideOnly(Side.CLIENT) protected abstract void updateClient(int tickCount); protected final boolean updateOnInterval(int tickInterval) { diff --git a/src/main/java/forestry/core/network/IForestryPacketHandlerClient.java b/src/main/java/forestry/core/network/IForestryPacketHandlerClient.java index d14240d28..b586ba158 100644 --- a/src/main/java/forestry/core/network/IForestryPacketHandlerClient.java +++ b/src/main/java/forestry/core/network/IForestryPacketHandlerClient.java @@ -3,7 +3,10 @@ package forestry.core.network; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public interface IForestryPacketHandlerClient extends IForestryPacketHandler { void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException; } diff --git a/src/main/java/forestry/core/network/IPacketRegistry.java b/src/main/java/forestry/core/network/IPacketRegistry.java index ba9673329..a743623ca 100644 --- a/src/main/java/forestry/core/network/IPacketRegistry.java +++ b/src/main/java/forestry/core/network/IPacketRegistry.java @@ -10,6 +10,12 @@ ******************************************************************************/ package forestry.core.network; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + public interface IPacketRegistry { - void registerPackets(); + void registerPacketsServer(); + + @SideOnly(Side.CLIENT) + void registerPacketsClient(); } diff --git a/src/main/java/forestry/core/network/IStreamable.java b/src/main/java/forestry/core/network/IStreamable.java index 029266a4a..3a4250c51 100644 --- a/src/main/java/forestry/core/network/IStreamable.java +++ b/src/main/java/forestry/core/network/IStreamable.java @@ -12,8 +12,12 @@ package forestry.core.network; import java.io.IOException; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + public interface IStreamable { void writeData(PacketBufferForestry data); + @SideOnly(Side.CLIENT) void readData(PacketBufferForestry data) throws IOException; } diff --git a/src/main/java/forestry/core/network/IStreamableGui.java b/src/main/java/forestry/core/network/IStreamableGui.java index 882c6f196..148558c96 100644 --- a/src/main/java/forestry/core/network/IStreamableGui.java +++ b/src/main/java/forestry/core/network/IStreamableGui.java @@ -12,8 +12,12 @@ package forestry.core.network; import java.io.IOException; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + public interface IStreamableGui { void writeGuiData(PacketBufferForestry data); + @SideOnly(Side.CLIENT) void readGuiData(PacketBufferForestry data) throws IOException; } diff --git a/src/main/java/forestry/core/network/PacketHandler.java b/src/main/java/forestry/core/network/PacketHandler.java index 4921bc18a..2277425f7 100644 --- a/src/main/java/forestry/core/network/PacketHandler.java +++ b/src/main/java/forestry/core/network/PacketHandler.java @@ -13,7 +13,6 @@ package forestry.core.network; import java.io.IOException; import com.google.common.base.Preconditions; -import forestry.core.proxy.Proxies; import forestry.core.utils.Log; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; @@ -26,6 +25,8 @@ import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketE import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketHandler { public static final String channelId = "FOR"; @@ -48,6 +49,7 @@ public class PacketHandler { } @SubscribeEvent + @SideOnly(Side.CLIENT) public void onPacket(ClientCustomPacketEvent event) { PacketBufferForestry data = new PacketBufferForestry(event.getPacket().payload()); @@ -61,11 +63,12 @@ public class PacketHandler { channel.sendTo(packet, player); } + @SideOnly(Side.CLIENT) private static void checkThreadAndEnqueue(final IForestryPacketHandlerClient packet, final PacketBufferForestry data, IThreadListener threadListener) { if (!threadListener.isCallingFromMinecraftThread()) { threadListener.addScheduledTask(() -> { try { - EntityPlayer player = Proxies.common.getPlayer(); + EntityPlayer player = Minecraft.getMinecraft().player; Preconditions.checkNotNull(player, "Tried to send data to client before the player exists."); packet.onPacketData(data, player); } catch (IOException e) { diff --git a/src/main/java/forestry/core/network/PacketIdClient.java b/src/main/java/forestry/core/network/PacketIdClient.java index 4677e1808..2e6e1638e 100644 --- a/src/main/java/forestry/core/network/PacketIdClient.java +++ b/src/main/java/forestry/core/network/PacketIdClient.java @@ -11,7 +11,11 @@ package forestry.core.network; +import javax.annotation.Nullable; + import forestry.core.network.packets.PacketHandlerDummyClient; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * Packets sent to the client from the server @@ -64,17 +68,20 @@ public enum PacketIdClient implements IPacketId { public static final PacketIdClient[] VALUES = values(); + @SideOnly(Side.CLIENT) + @Nullable private IForestryPacketHandlerClient packetHandler; - PacketIdClient() { - this.packetHandler = PacketHandlerDummyClient.instance; - } - + @SideOnly(Side.CLIENT) public void setPacketHandler(IForestryPacketHandlerClient packetHandler) { this.packetHandler = packetHandler; } + @SideOnly(Side.CLIENT) public IForestryPacketHandlerClient getPacketHandler() { + if (packetHandler == null) { + return PacketHandlerDummyClient.INSTANCE; + } return packetHandler; } } diff --git a/src/main/java/forestry/core/network/PacketRegistryCore.java b/src/main/java/forestry/core/network/PacketRegistryCore.java index bf910c6d4..46248e368 100644 --- a/src/main/java/forestry/core/network/PacketRegistryCore.java +++ b/src/main/java/forestry/core/network/PacketRegistryCore.java @@ -29,10 +29,23 @@ import forestry.core.network.packets.PacketSolderingIronClick; import forestry.core.network.packets.PacketTankLevelUpdate; import forestry.core.network.packets.PacketTileStream; import forestry.core.network.packets.PacketUpdateClimateControl; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketRegistryCore implements IPacketRegistry { @Override - public void registerPackets() { + public void registerPacketsServer() { + PacketIdServer.GUI_SELECTION_REQUEST.setPacketHandler(new PacketGuiSelectRequest.Handler()); + PacketIdServer.PIPETTE_CLICK.setPacketHandler(new PacketPipetteClick.Handler()); + PacketIdServer.CHIPSET_CLICK.setPacketHandler(new PacketChipsetClick.Handler()); + PacketIdServer.SOLDERING_IRON_CLICK.setPacketHandler(new PacketSolderingIronClick.Handler()); + PacketIdServer.CAMOUFLAGE_SELECTION.setPacketHandler(new PacketCamouflageSelectServer.Handler()); + PacketIdServer.CLIMATE_CONTROL_UPDATE.setPacketHandler(new PacketUpdateClimateControl.Handler()); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerPacketsClient() { PacketIdClient.ERROR_UPDATE.setPacketHandler(new PacketErrorUpdate.Handler()); PacketIdClient.ERROR_UPDATE_ENTITY.setPacketHandler(new PacketErrorUpdateEntity.Handler()); PacketIdClient.GUI_UPDATE.setPacketHandler(new PacketGuiUpdate.Handler()); @@ -46,12 +59,5 @@ public class PacketRegistryCore implements IPacketRegistry { PacketIdClient.TANK_LEVEL_UPDATE.setPacketHandler(new PacketTankLevelUpdate.Handler()); PacketIdClient.GENOME_TRACKER_UPDATE.setPacketHandler(new PacketGenomeTrackerSync.Handler()); PacketIdClient.CAMOUFLAGE_SELECTION.setPacketHandler(new PacketCamouflageSelectClient.Handler()); - - PacketIdServer.GUI_SELECTION_REQUEST.setPacketHandler(new PacketGuiSelectRequest.Handler()); - PacketIdServer.PIPETTE_CLICK.setPacketHandler(new PacketPipetteClick.Handler()); - PacketIdServer.CHIPSET_CLICK.setPacketHandler(new PacketChipsetClick.Handler()); - PacketIdServer.SOLDERING_IRON_CLICK.setPacketHandler(new PacketSolderingIronClick.Handler()); - PacketIdServer.CAMOUFLAGE_SELECTION.setPacketHandler(new PacketCamouflageSelectServer.Handler()); - PacketIdServer.CLIMATE_CONTROL_UPDATE.setPacketHandler(new PacketUpdateClimateControl.Handler()); } } diff --git a/src/main/java/forestry/core/network/packets/PacketCamouflageSelectClient.java b/src/main/java/forestry/core/network/packets/PacketCamouflageSelectClient.java index caeb5939b..63f8fdbe0 100644 --- a/src/main/java/forestry/core/network/packets/PacketCamouflageSelectClient.java +++ b/src/main/java/forestry/core/network/packets/PacketCamouflageSelectClient.java @@ -25,6 +25,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketCamouflageSelectClient extends ForestryPacket implements IForestryPacketClient { private final BlockPos pos; @@ -52,6 +54,7 @@ public class PacketCamouflageSelectClient extends ForestryPacket implements IFor data.writeItemStack(camouflageStack); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override diff --git a/src/main/java/forestry/core/network/packets/PacketCamouflageSelectServer.java b/src/main/java/forestry/core/network/packets/PacketCamouflageSelectServer.java index 1f98d77b1..6488fde1e 100644 --- a/src/main/java/forestry/core/network/packets/PacketCamouflageSelectServer.java +++ b/src/main/java/forestry/core/network/packets/PacketCamouflageSelectServer.java @@ -22,7 +22,7 @@ import forestry.core.network.IForestryPacketHandlerServer; import forestry.core.network.IForestryPacketServer; import forestry.core.network.PacketBufferForestry; import forestry.core.network.PacketIdServer; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -90,7 +90,7 @@ public class PacketCamouflageSelectServer extends ForestryPacket implements IFor if (handler != null) { if (handler.setCamouflageBlock(camouflageType, camouflageStack, true) && selectionType != CamouflageSelectionType.ITEM) { - Proxies.net.sendNetworkPacket(new PacketCamouflageSelectClient(handler, camouflageType, selectionType), pos, player.world); + NetworkUtil.sendNetworkPacket(new PacketCamouflageSelectClient(handler, camouflageType, selectionType), pos, player.world); } } } diff --git a/src/main/java/forestry/core/network/packets/PacketErrorUpdate.java b/src/main/java/forestry/core/network/packets/PacketErrorUpdate.java index dac1df45b..c840111dc 100644 --- a/src/main/java/forestry/core/network/packets/PacketErrorUpdate.java +++ b/src/main/java/forestry/core/network/packets/PacketErrorUpdate.java @@ -22,6 +22,8 @@ import forestry.core.network.PacketIdClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketErrorUpdate extends ForestryPacket implements IForestryPacketClient { private final BlockPos pos; @@ -43,6 +45,7 @@ public class PacketErrorUpdate extends ForestryPacket implements IForestryPacket return PacketIdClient.ERROR_UPDATE; } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/core/network/packets/PacketErrorUpdateEntity.java b/src/main/java/forestry/core/network/packets/PacketErrorUpdateEntity.java index bd2d06fc4..4ca9c30b2 100644 --- a/src/main/java/forestry/core/network/packets/PacketErrorUpdateEntity.java +++ b/src/main/java/forestry/core/network/packets/PacketErrorUpdateEntity.java @@ -21,6 +21,8 @@ import forestry.core.network.PacketBufferForestry; import forestry.core.network.PacketIdClient; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketErrorUpdateEntity extends ForestryPacket implements IForestryPacketClient { private final Entity entity; @@ -42,6 +44,7 @@ public class PacketErrorUpdateEntity extends ForestryPacket implements IForestry errorLogic.writeData(data); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/core/network/packets/PacketFXSignal.java b/src/main/java/forestry/core/network/packets/PacketFXSignal.java index 4b81c04e8..d8d081741 100644 --- a/src/main/java/forestry/core/network/packets/PacketFXSignal.java +++ b/src/main/java/forestry/core/network/packets/PacketFXSignal.java @@ -17,14 +17,16 @@ import forestry.core.network.IForestryPacketClient; import forestry.core.network.IForestryPacketHandlerClient; import forestry.core.network.PacketBufferForestry; import forestry.core.network.PacketIdClient; -import forestry.core.proxy.Proxies; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketFXSignal extends ForestryPacket implements IForestryPacketClient { @@ -71,6 +73,7 @@ public class PacketFXSignal extends ForestryPacket implements IForestryPacketCli return PacketIdClient.FX_SIGNAL; } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { @@ -83,7 +86,7 @@ public class PacketFXSignal extends ForestryPacket implements IForestryPacketCli World world = player.world; if (visualFX == VisualFXType.BLOCK_BREAK) { - Proxies.common.addBlockDestroyEffects(world, pos, blockState); + Minecraft.getMinecraft().effectRenderer.addBlockDestroyEffects(pos, blockState); } if (soundFX != SoundFXType.NONE) { diff --git a/src/main/java/forestry/core/network/packets/PacketGenomeTrackerSync.java b/src/main/java/forestry/core/network/packets/PacketGenomeTrackerSync.java index 051181eea..062d0c4ef 100644 --- a/src/main/java/forestry/core/network/packets/PacketGenomeTrackerSync.java +++ b/src/main/java/forestry/core/network/packets/PacketGenomeTrackerSync.java @@ -25,6 +25,8 @@ import forestry.core.network.PacketIdClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketGenomeTrackerSync extends ForestryPacket implements IForestryPacketClient { private final NBTTagCompound nbt; @@ -43,6 +45,7 @@ public class PacketGenomeTrackerSync extends ForestryPacket implements IForestry data.writeCompoundTag(nbt); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/core/network/packets/PacketGuiEnergy.java b/src/main/java/forestry/core/network/packets/PacketGuiEnergy.java index 9cccb30e6..ba015ba36 100644 --- a/src/main/java/forestry/core/network/packets/PacketGuiEnergy.java +++ b/src/main/java/forestry/core/network/packets/PacketGuiEnergy.java @@ -19,6 +19,8 @@ import forestry.core.network.IForestryPacketHandlerClient; import forestry.core.network.PacketBufferForestry; import forestry.core.network.PacketIdClient; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketGuiEnergy extends ForestryPacket implements IForestryPacketClient { private final int windowId; @@ -40,6 +42,7 @@ public class PacketGuiEnergy extends ForestryPacket implements IForestryPacketCl data.writeVarInt(value); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/core/network/packets/PacketGuiLayoutSelect.java b/src/main/java/forestry/core/network/packets/PacketGuiLayoutSelect.java index d13f11c8e..a045706fd 100644 --- a/src/main/java/forestry/core/network/packets/PacketGuiLayoutSelect.java +++ b/src/main/java/forestry/core/network/packets/PacketGuiLayoutSelect.java @@ -22,6 +22,8 @@ import forestry.core.network.PacketBufferForestry; import forestry.core.network.PacketIdClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketGuiLayoutSelect extends ForestryPacket implements IForestryPacketClient { private final String layoutUid; @@ -40,6 +42,7 @@ public class PacketGuiLayoutSelect extends ForestryPacket implements IForestryPa data.writeString(layoutUid); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/core/network/packets/PacketGuiUpdate.java b/src/main/java/forestry/core/network/packets/PacketGuiUpdate.java index 6c4311b15..8d4e7adc1 100644 --- a/src/main/java/forestry/core/network/packets/PacketGuiUpdate.java +++ b/src/main/java/forestry/core/network/packets/PacketGuiUpdate.java @@ -22,6 +22,8 @@ import forestry.core.network.PacketIdClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketGuiUpdate extends ForestryPacket implements IForestryPacketClient { private final BlockPos pos; @@ -43,6 +45,7 @@ public class PacketGuiUpdate extends ForestryPacket implements IForestryPacketCl return PacketIdClient.GUI_UPDATE; } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/core/network/packets/PacketGuiUpdateEntity.java b/src/main/java/forestry/core/network/packets/PacketGuiUpdateEntity.java index 7722b8eed..43a67ed67 100644 --- a/src/main/java/forestry/core/network/packets/PacketGuiUpdateEntity.java +++ b/src/main/java/forestry/core/network/packets/PacketGuiUpdateEntity.java @@ -20,6 +20,8 @@ import forestry.core.network.PacketBufferForestry; import forestry.core.network.PacketIdClient; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketGuiUpdateEntity extends ForestryPacket implements IForestryPacketClient { private final Entity entity; @@ -41,6 +43,7 @@ public class PacketGuiUpdateEntity extends ForestryPacket implements IForestryPa streamableGui.writeGuiData(data); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/core/network/packets/PacketHandlerDummyClient.java b/src/main/java/forestry/core/network/packets/PacketHandlerDummyClient.java index 15197f517..1fdce8f21 100644 --- a/src/main/java/forestry/core/network/packets/PacketHandlerDummyClient.java +++ b/src/main/java/forestry/core/network/packets/PacketHandlerDummyClient.java @@ -13,9 +13,12 @@ package forestry.core.network.packets; import forestry.core.network.IForestryPacketHandlerClient; import forestry.core.network.PacketBufferForestry; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class PacketHandlerDummyClient extends PacketHandlerDummy implements IForestryPacketHandlerClient { - public static final PacketHandlerDummyClient instance = new PacketHandlerDummyClient(); + public static final PacketHandlerDummyClient INSTANCE = new PacketHandlerDummyClient(); private PacketHandlerDummyClient() { diff --git a/src/main/java/forestry/core/network/packets/PacketItemStackDisplay.java b/src/main/java/forestry/core/network/packets/PacketItemStackDisplay.java index fadcb9d4b..39a263078 100644 --- a/src/main/java/forestry/core/network/packets/PacketItemStackDisplay.java +++ b/src/main/java/forestry/core/network/packets/PacketItemStackDisplay.java @@ -23,6 +23,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketItemStackDisplay extends ForestryPacket implements IForestryPacketClient { private final BlockPos pos; @@ -44,6 +46,7 @@ public class PacketItemStackDisplay extends ForestryPacket implements IForestryP return PacketIdClient.ITEMSTACK_DISPLAY; } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/core/network/packets/PacketSocketUpdate.java b/src/main/java/forestry/core/network/packets/PacketSocketUpdate.java index f72eb7702..1c5ef3a71 100644 --- a/src/main/java/forestry/core/network/packets/PacketSocketUpdate.java +++ b/src/main/java/forestry/core/network/packets/PacketSocketUpdate.java @@ -23,6 +23,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketSocketUpdate extends ForestryPacket implements IForestryPacketClient { private final BlockPos pos; @@ -48,6 +50,7 @@ public class PacketSocketUpdate extends ForestryPacket implements IForestryPacke data.writeItemStacks(itemStacks); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/core/network/packets/PacketTankLevelUpdate.java b/src/main/java/forestry/core/network/packets/PacketTankLevelUpdate.java index 5e8bb92e9..6a8b8499a 100644 --- a/src/main/java/forestry/core/network/packets/PacketTankLevelUpdate.java +++ b/src/main/java/forestry/core/network/packets/PacketTankLevelUpdate.java @@ -24,6 +24,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketTankLevelUpdate extends ForestryPacket implements IForestryPacketClient { private final BlockPos pos; @@ -49,6 +51,7 @@ public class PacketTankLevelUpdate extends ForestryPacket implements IForestryPa data.writeFluidStack(contents); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override diff --git a/src/main/java/forestry/core/network/packets/PacketTileStream.java b/src/main/java/forestry/core/network/packets/PacketTileStream.java index ab2e6cdec..8179da905 100644 --- a/src/main/java/forestry/core/network/packets/PacketTileStream.java +++ b/src/main/java/forestry/core/network/packets/PacketTileStream.java @@ -21,6 +21,8 @@ import forestry.core.network.PacketIdClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketTileStream extends ForestryPacket implements IForestryPacketClient { private final BlockPos pos; @@ -42,6 +44,7 @@ public class PacketTileStream extends ForestryPacket implements IForestryPacketC streamable.writeData(data); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/core/proxy/Proxies.java b/src/main/java/forestry/core/proxy/Proxies.java index 5a7cd10fc..f94b68835 100755 --- a/src/main/java/forestry/core/proxy/Proxies.java +++ b/src/main/java/forestry/core/proxy/Proxies.java @@ -17,10 +17,6 @@ public class Proxies { @SidedProxy(clientSide = "forestry.core.proxy.ProxyClient", serverSide = "forestry.core.proxy.ProxyCommon") public static ProxyCommon common; - @SuppressWarnings("NullableProblems") - @SidedProxy(clientSide = "forestry.core.proxy.ProxyNetworkClient", serverSide = "forestry.core.proxy.ProxyNetwork") - public static ProxyNetwork net; - @SuppressWarnings("NullableProblems") @SidedProxy(clientSide = "forestry.core.proxy.ProxyRenderClient", serverSide = "forestry.core.proxy.ProxyRender") public static ProxyRender render; diff --git a/src/main/java/forestry/core/proxy/ProxyClient.java b/src/main/java/forestry/core/proxy/ProxyClient.java index fba85924f..f3c873789 100644 --- a/src/main/java/forestry/core/proxy/ProxyClient.java +++ b/src/main/java/forestry/core/proxy/ProxyClient.java @@ -16,30 +16,23 @@ import forestry.core.TickHandlerCoreClient; import forestry.core.models.ModelManager; import forestry.core.multiblock.MultiblockClientTickHandler; import forestry.core.multiblock.MultiblockEventHandlerClient; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import forestry.core.worldgen.WorldGenerator; import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.audio.SoundHandler; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import org.lwjgl.input.Keyboard; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SuppressWarnings("unused") +@SideOnly(Side.CLIENT) public class ProxyClient extends ProxyCommon { @Override public void registerTickHandlers(WorldGenerator worldGenerator) { - super.registerTickHandlers(worldGenerator); - MinecraftForge.EVENT_BUS.register(new TickHandlerCoreClient()); MinecraftForge.EVENT_BUS.register(new MultiblockClientTickHandler()); } @@ -52,13 +45,13 @@ public class ProxyClient extends ProxyCommon { @Override public void registerBlock(Block block) { ModelManager.getInstance().registerBlockClient(block); - TextureManager.getInstance().registerBlock(block); + TextureManagerForestry.getInstance().registerBlock(block); } @Override public void registerItem(Item item) { ModelManager.getInstance().registerItemClient(item); - TextureManager.getInstance().registerItem(item); + TextureManagerForestry.getInstance().registerItem(item); } @Override @@ -66,44 +59,13 @@ public class ProxyClient extends ProxyCommon { return Minecraft.getMinecraft().mcDataDir; } - @Override - public World getRenderWorld() { - return getClientInstance().world; - } - @Override public double getBlockReachDistance(EntityPlayer entityplayer) { if (entityplayer instanceof EntityPlayerSP) { - return getClientInstance().playerController.getBlockReachDistance(); + return Minecraft.getMinecraft().playerController.getBlockReachDistance(); } else { return 4f; } } - @Override - public boolean isShiftDown() { - return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); - } - - @Override - public String getDisplayName(ItemStack itemstack) { - return itemstack.getItem().getItemStackDisplayName(itemstack); - } - - @Override - public void addBlockDestroyEffects(World world, BlockPos pos, IBlockState blockState) { - Minecraft.getMinecraft().effectRenderer.addBlockDestroyEffects(pos, blockState); - } - - @Override - public EntityPlayer getPlayer() { - return Minecraft.getMinecraft().player; - } - - @Override - public void playButtonClick() { - Minecraft minecraft = getClientInstance(); - SoundHandler soundHandler = minecraft.getSoundHandler(); - soundHandler.playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - } } diff --git a/src/main/java/forestry/core/proxy/ProxyCommon.java b/src/main/java/forestry/core/proxy/ProxyCommon.java index 365e5600a..311062a2c 100755 --- a/src/main/java/forestry/core/proxy/ProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ProxyCommon.java @@ -16,23 +16,11 @@ import forestry.core.TickHandlerCoreServer; import forestry.core.multiblock.MultiblockServerTickHandler; import forestry.core.worldgen.WorldGenerator; import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.client.FMLClientHandler; -import net.minecraftforge.fml.common.Loader; public class ProxyCommon { - - public String getMinecraftVersion() { - return Loader.instance().getMinecraftModContainer().getVersion(); - } - public void registerItem(Item item) { } @@ -53,10 +41,6 @@ public class ProxyCommon { } - public String getDisplayName(ItemStack itemstack) { - return null; - } - public File getForestryRoot() { return new File("."); } @@ -65,28 +49,4 @@ public class ProxyCommon { return 4f; } - public boolean isShiftDown() { - return false; - } - - public void addBlockDestroyEffects(World world, BlockPos pos, IBlockState blockState) { - - } - - public World getRenderWorld() { - throw new IllegalStateException("Cannot get render world on server"); - } - - public Minecraft getClientInstance() { - return FMLClientHandler.instance().getClient(); - } - - public EntityPlayer getPlayer() { - throw new IllegalStateException("Can't call getPlayer on the server"); - } - - public void playButtonClick() { - - } - } diff --git a/src/main/java/forestry/core/proxy/ProxyNetworkClient.java b/src/main/java/forestry/core/proxy/ProxyNetworkClient.java deleted file mode 100644 index 3b9919990..000000000 --- a/src/main/java/forestry/core/proxy/ProxyNetworkClient.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.proxy; - -import com.google.common.base.Preconditions; -import forestry.core.network.IForestryPacketServer; -import net.minecraft.client.network.NetHandlerPlayClient; - -@SuppressWarnings("unused") -public class ProxyNetworkClient extends ProxyNetwork { - - @Override - public void sendToServer(IForestryPacketServer packet) { - NetHandlerPlayClient netHandler = Proxies.common.getClientInstance().getConnection(); - Preconditions.checkNotNull(netHandler, "Tried to send packet before netHandler (client world) exists."); - netHandler.sendPacket(packet.getPacket()); - } -} diff --git a/src/main/java/forestry/core/proxy/ProxyRender.java b/src/main/java/forestry/core/proxy/ProxyRender.java index 129c1c4c9..0c3f31945 100644 --- a/src/main/java/forestry/core/proxy/ProxyRender.java +++ b/src/main/java/forestry/core/proxy/ProxyRender.java @@ -10,30 +10,14 @@ ******************************************************************************/ package forestry.core.proxy; -import javax.annotation.Nullable; -import java.util.List; - -import com.google.common.collect.ImmutableMap; -import forestry.api.apiculture.IBeeGenome; -import forestry.api.apiculture.IBeeHousing; +import forestry.core.blocks.MachinePropertiesTesr; import forestry.core.fluids.Fluids; -import forestry.core.models.BlockModelEntry; -import forestry.core.models.ModelEntry; import forestry.core.tiles.TileAnalyzer; import forestry.core.tiles.TileBase; import forestry.core.tiles.TileEscritoire; import forestry.core.tiles.TileMill; import forestry.core.tiles.TileNaturalistChest; import net.minecraft.block.Block; -import net.minecraft.client.renderer.block.statemap.IStateMapper; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.entity.Entity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.animation.ITimeValue; -import net.minecraftforge.common.model.animation.IAnimationStateMachine; public class ProxyRender { @@ -41,64 +25,25 @@ public class ProxyRender { return false; } - public boolean hasRendering() { - return false; - } - public void initRendering() { - } - @Nullable - public TileEntitySpecialRenderer getRenderDefaultMachine(String gfxBase) { - return null; + public void setRenderDefaultMachine(MachinePropertiesTesr machineProperties, String gfxBase) { } - @Nullable - public TileEntitySpecialRenderer getRenderMill(String gfxBase) { - return null; + public void setRenderMill(MachinePropertiesTesr machineProperties, String gfxBase) { } - @Nullable - public TileEntitySpecialRenderer getRenderMill(String gfxBase, byte charges) { - return null; + public void setRenderMill(MachinePropertiesTesr machineProperties, String gfxBase, byte charges) { } - @Nullable - public TileEntitySpecialRenderer getRenderEscritoire() { - return null; + public void setRenderEscritoire(MachinePropertiesTesr machineProperties) { } - @Nullable - public TileEntitySpecialRenderer getRendererAnalyzer() { - return null; + public void setRendererAnalyzer(MachinePropertiesTesr machineProperties) { } - @Nullable - public TileEntitySpecialRenderer getRenderChest(String textureName) { - return null; - } - - public void registerBlockModel(BlockModelEntry index) { - } - - public void registerModel(ModelEntry index) { - } - - public void registerStateMapper(Block block, IStateMapper mapper) { - } - - public void registerFluidStateMapper(Block block, Fluids fluid) { - } - - public void setHabitatLocatorTexture(@Nullable Entity player, @Nullable BlockPos pos) { - } - - public IResourceManager getSelectedTexturePack() { - return null; - } - - public void bindTexture(ResourceLocation location) { + public void setRenderChest(MachinePropertiesTesr machineProperties, String textureName) { } public void registerModels() { @@ -107,30 +52,7 @@ public class ProxyRender { public void registerItemAndBlockColors() { } - public IAnimationStateMachine loadAnimationState(ResourceLocation location, ImmutableMap parameters) { - return null; + public void registerFluidStateMapper(Block block, Fluids fluid) { } - /* FX */ - - public void addBeeHiveFX(IBeeHousing housing, IBeeGenome genome, List flowerPositions) { - } - - public void addEntityHoneyDustFX(World world, double x, double y, double z) { - } - - public void addEntityExplodeFX(World world, double x, double y, double z) { - } - - public void addEntitySnowFX(World world, double x, double y, double z) { - } - - public void addEntityIgnitionFX(World world, double x, double y, double z) { - } - - public void addEntitySmokeFX(World world, double x, double y, double z) { - } - - public void addEntityPotionFX(World world, double x, double y, double z, int color) { - } } diff --git a/src/main/java/forestry/core/proxy/ProxyRenderClient.java b/src/main/java/forestry/core/proxy/ProxyRenderClient.java index 0db14d08d..e447360ac 100644 --- a/src/main/java/forestry/core/proxy/ProxyRenderClient.java +++ b/src/main/java/forestry/core/proxy/ProxyRenderClient.java @@ -10,69 +10,37 @@ ******************************************************************************/ package forestry.core.proxy; -import javax.annotation.Nullable; -import java.util.List; - -import com.google.common.collect.ImmutableMap; -import forestry.api.apiculture.IBeeGenome; -import forestry.api.apiculture.IBeeHousing; -import forestry.api.apiculture.IHiveTile; -import forestry.apiculture.entities.ParticleBeeExplore; -import forestry.apiculture.entities.ParticleBeeRoundTrip; -import forestry.apiculture.entities.ParticleBeeTargetEntity; -import forestry.apiculture.genetics.alleles.AlleleEffect; -import forestry.apiculture.render.TextureHabitatLocator; -import forestry.core.config.Config; +import forestry.core.blocks.MachinePropertiesTesr; import forestry.core.config.Constants; -import forestry.core.entities.ParticleHoneydust; -import forestry.core.entities.ParticleIgnition; -import forestry.core.entities.ParticleSmoke; -import forestry.core.entities.ParticleSnow; import forestry.core.fluids.Fluids; -import forestry.core.models.BlockModelEntry; -import forestry.core.models.ModelEntry; import forestry.core.models.ModelManager; import forestry.core.render.RenderAnalyzer; import forestry.core.render.RenderEscritoire; import forestry.core.render.RenderMachine; import forestry.core.render.RenderMill; import forestry.core.render.RenderNaturalistChest; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import forestry.core.render.TextureMapForestry; import forestry.core.tiles.TileAnalyzer; import forestry.core.tiles.TileBase; import forestry.core.tiles.TileEscritoire; import forestry.core.tiles.TileMill; import forestry.core.tiles.TileNaturalistChest; -import forestry.core.utils.VectUtil; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.Particle; -import net.minecraft.client.particle.ParticleManager; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelResourceLocation; -import net.minecraft.client.renderer.block.statemap.IStateMapper; import net.minecraft.client.renderer.block.statemap.StateMapperBase; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.Vec3i; -import net.minecraft.world.World; import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.client.model.ModelLoaderRegistry; -import net.minecraftforge.common.animation.ITimeValue; -import net.minecraftforge.common.model.animation.IAnimationStateMachine; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SuppressWarnings("unused") +@SideOnly(Side.CLIENT) public class ProxyRenderClient extends ProxyRender { @Override @@ -80,92 +48,40 @@ public class ProxyRenderClient extends ProxyRender { return Minecraft.getMinecraft().gameSettings.fancyGraphics; } - @Override - public boolean hasRendering() { - return true; - } - @Override public void initRendering() { - TextureManager textureManager = TextureManager.getInstance(); - TextureMapForestry textureMap = textureManager.getTextureMap(); + TextureManagerForestry textureManagerForestry = TextureManagerForestry.getInstance(); + TextureMapForestry textureMap = textureManagerForestry.getTextureMap(); Minecraft minecraft = Minecraft.getMinecraft(); - minecraft.renderEngine.loadTickableTexture(TextureManager.getInstance().getGuiTextureMap(), textureMap); + minecraft.renderEngine.loadTickableTexture(TextureManagerForestry.getInstance().getGuiTextureMap(), textureMap); } @Override - public TileEntitySpecialRenderer getRenderDefaultMachine(String gfxBase) { - return new RenderMachine(gfxBase); + public void setRenderDefaultMachine(MachinePropertiesTesr machineProperties, String gfxBase) { + machineProperties.setRenderer(new RenderMachine(gfxBase)); + } + + public void setRenderMill(MachinePropertiesTesr machineProperties, String gfxBase) { + machineProperties.setRenderer(new RenderMill(gfxBase)); + } + + public void setRenderMill(MachinePropertiesTesr machineProperties, String gfxBase, byte charges) { + machineProperties.setRenderer(new RenderMill(gfxBase, charges)); + } + + public void setRenderEscritoire(MachinePropertiesTesr machineProperties) { + machineProperties.setRenderer(new RenderEscritoire()); + } + + public void setRendererAnalyzer(MachinePropertiesTesr machineProperties) { + RenderAnalyzer renderAnalyzer = new RenderAnalyzer(Constants.TEXTURE_PATH_BLOCKS + "/analyzer_"); + machineProperties.setRenderer(renderAnalyzer); } @Override - public TileEntitySpecialRenderer getRenderMill(String gfxBase) { - return new RenderMill(gfxBase); - } - - @Override - public TileEntitySpecialRenderer getRenderMill(String gfxBase, byte charges) { - return new RenderMill(gfxBase, charges); - } - - @Override - public TileEntitySpecialRenderer getRenderEscritoire() { - return new RenderEscritoire(); - } - - @Override - public TileEntitySpecialRenderer getRendererAnalyzer() { - return new RenderAnalyzer(Constants.TEXTURE_PATH_BLOCKS + "/analyzer_"); - } - - @Override - public TileEntitySpecialRenderer getRenderChest(String textureName) { - return new RenderNaturalistChest(textureName); - } - - @Override - public void setHabitatLocatorTexture(@Nullable Entity player, @Nullable BlockPos pos) { - TextureHabitatLocator.getInstance().setTargetCoordinates(pos); - } - - @Override - public IResourceManager getSelectedTexturePack() { - return Minecraft.getMinecraft().getResourceManager(); - } - - @Override - public void bindTexture(ResourceLocation location) { - Minecraft.getMinecraft().getTextureManager().bindTexture(location); - } - - @Override - public void registerBlockModel(final BlockModelEntry index) { - ModelManager.getInstance().registerCustomBlockModel(index); - if (index.addStateMapper) { - StateMapperBase ignoreState = new BlockModeStateMapper(index); - registerStateMapper(index.block, ignoreState); - } - } - - @Override - public void registerModel(ModelEntry index) { - ModelManager.getInstance().registerCustomModel(index); - } - - @Override - public void registerFluidStateMapper(Block block, final Fluids forestryFluid) { - final ModelResourceLocation fluidLocation = new ModelResourceLocation("forestry:blockforestryfluid", - forestryFluid.getTag()); - StateMapperBase ignoreState = new FluidStateMapper(fluidLocation); - registerStateMapper(block, ignoreState); - ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(block), new FluidItemMeshDefinition(fluidLocation)); - ModelBakery.registerItemVariants(Item.getItemFromBlock(block), fluidLocation); - } - - @Override - public void registerStateMapper(Block block, IStateMapper mapper) { - ModelLoader.setCustomStateMapper(block, mapper); + public void setRenderChest(MachinePropertiesTesr machineProperties, String textureName) { + machineProperties.setRenderer(new RenderNaturalistChest(textureName)); } @Override @@ -178,163 +94,12 @@ public class ProxyRenderClient extends ProxyRender { ModelManager.getInstance().registerItemAndBlockColors(); } - @Override - public IAnimationStateMachine loadAnimationState(ResourceLocation location, ImmutableMap parameters) { - return ModelLoaderRegistry.loadASM(location, parameters); - } - - private static boolean shouldSpawnParticle(World world) { - if (!Config.enableParticleFX) { - return false; - } - - Minecraft mc = Minecraft.getMinecraft(); - int particleSetting = mc.gameSettings.particleSetting; - - // minimal - if (particleSetting == 2) { - return world.rand.nextInt(10) == 0; - } - - // decreased - if (particleSetting == 1) { - return world.rand.nextInt(3) != 0; - } - - // all - return true; - } - - @Override - public void addBeeHiveFX(IBeeHousing housing, IBeeGenome genome, List flowerPositions) { - World world = housing.getWorldObj(); - if (!shouldSpawnParticle(world)) { - return; - } - - ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; - - Vec3d particleStart = housing.getBeeFXCoordinates(); - - // Avoid rendering bee particles that are too far away, they're very small. - // At 32+ distance, have no bee particles. Make more particles up close. - BlockPos playerPosition = Proxies.common.getPlayer().getPosition(); - double playerDistanceSq = playerPosition.distanceSqToCenter(particleStart.xCoord, particleStart.yCoord, particleStart.zCoord); - if (world.rand.nextInt(1024) < playerDistanceSq) { - return; - } - - int color = genome.getPrimary().getSpriteColour(0); - - if (!flowerPositions.isEmpty()) { - int randomInt = world.rand.nextInt(100); - - if (housing instanceof IHiveTile) { - if (((IHiveTile) housing).isAngry() || randomInt >= 85) { - List entitiesInRange = AlleleEffect.getEntitiesInRange(genome, housing, EntityLivingBase.class); - if (!entitiesInRange.isEmpty()) { - EntityLivingBase entity = entitiesInRange.get(world.rand.nextInt(entitiesInRange.size())); - Particle particle = new ParticleBeeTargetEntity(world, particleStart, entity, color); - effectRenderer.addEffect(particle); - return; - } - } - } - - if (randomInt < 75) { - BlockPos destination = flowerPositions.get(world.rand.nextInt(flowerPositions.size())); - Particle particle = new ParticleBeeRoundTrip(world, particleStart, destination, color); - effectRenderer.addEffect(particle); - } else { - Vec3i area = AlleleEffect.getModifiedArea(genome, housing); - Vec3i offset = housing.getCoordinates().add(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2); - BlockPos destination = VectUtil.getRandomPositionInArea(world.rand, area).add(offset); - Particle particle = new ParticleBeeExplore(world, particleStart, destination, color); - effectRenderer.addEffect(particle); - } - } - } - - @Override - public void addEntityHoneyDustFX(World world, double x, double y, double z) { - if (!shouldSpawnParticle(world)) { - return; - } - - ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; - effectRenderer.addEffect(new ParticleHoneydust(world, x, y, z, 0, 0, 0)); - } - - @Override - public void addEntityExplodeFX(World world, double x, double y, double z) { - if (!shouldSpawnParticle(world)) { - return; - } - - ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; - Particle Particle = effectRenderer.spawnEffectParticle(EnumParticleTypes.EXPLOSION_NORMAL.getParticleID(), x, y, z, 0, 0, 0); - effectRenderer.addEffect(Particle); - } - - @Override - public void addEntitySnowFX(World world, double x, double y, double z) { - if (!shouldSpawnParticle(world)) { - return; - } - - ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; - effectRenderer.addEffect(new ParticleSnow(world, x + world.rand.nextGaussian(), y, z + world.rand.nextGaussian())); - } - - @Override - public void addEntityIgnitionFX(World world, double x, double y, double z) { - if (!shouldSpawnParticle(world)) { - return; - } - - ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; - effectRenderer.addEffect(new ParticleIgnition(world, x, y, z)); - } - - @Override - public void addEntitySmokeFX(World world, double x, double y, double z) { - if (!shouldSpawnParticle(world)) { - return; - } - - ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; - effectRenderer.addEffect(new ParticleSmoke(world, x, y, z)); - } - - @Override - public void addEntityPotionFX(World world, double x, double y, double z, int color) { - if (!shouldSpawnParticle(world)) { - return; - } - - float red = (color >> 16 & 255) / 255.0F; - float green = (color >> 8 & 255) / 255.0F; - float blue = (color & 255) / 255.0F; - - ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; - Particle particle = effectRenderer.spawnEffectParticle(EnumParticleTypes.SPELL.getParticleID(), x, y, z, 0, 0, 0); - if (particle != null) { - particle.setRBGColorF(red, green, blue); - effectRenderer.addEffect(particle); - } - } - - private static class BlockModeStateMapper extends StateMapperBase { - private final BlockModelEntry index; - - public BlockModeStateMapper(BlockModelEntry index) { - this.index = index; - } - - @Override - protected ModelResourceLocation getModelResourceLocation(IBlockState iBlockState) { - return index.blockModelLocation; - } + public void registerFluidStateMapper(Block block, Fluids fluid) { + final ModelResourceLocation fluidLocation = new ModelResourceLocation("forestry:blockforestryfluid", fluid.getTag()); + StateMapperBase ignoreState = new FluidStateMapper(fluidLocation); + ModelLoader.setCustomStateMapper(block, ignoreState); + ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(block), new FluidItemMeshDefinition(fluidLocation)); + ModelBakery.registerItemVariants(Item.getItemFromBlock(block), fluidLocation); } private static class FluidStateMapper extends StateMapperBase { diff --git a/src/main/java/forestry/core/render/ColourProperties.java b/src/main/java/forestry/core/render/ColourProperties.java index a78f6730f..c6a5287e8 100644 --- a/src/main/java/forestry/core/render/ColourProperties.java +++ b/src/main/java/forestry/core/render/ColourProperties.java @@ -19,7 +19,10 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.resources.IReloadableResourceManager; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManagerReloadListener; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class ColourProperties implements IResourceManagerReloadListener { public static final ColourProperties INSTANCE; diff --git a/src/main/java/forestry/core/render/MachineParticleCallback.java b/src/main/java/forestry/core/render/MachineParticleCallback.java index e8860d75a..ee1b83278 100644 --- a/src/main/java/forestry/core/render/MachineParticleCallback.java +++ b/src/main/java/forestry/core/render/MachineParticleCallback.java @@ -14,7 +14,6 @@ import forestry.core.blocks.BlockBase; import forestry.core.blocks.IBlockType; import forestry.core.blocks.IMachineProperties; import forestry.core.blocks.IMachinePropertiesTesr; -import forestry.core.proxy.Proxies; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.ParticleDigging; @@ -23,6 +22,8 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.IStringSerializable; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class MachineParticleCallback

& IBlockType & IStringSerializable> extends ParticleHelper.DefaultCallback { @@ -34,10 +35,11 @@ public class MachineParticleCallback

& IBlockType & IStringSer } @Override + @SideOnly(Side.CLIENT) protected void setTexture(ParticleDigging fx, World world, BlockPos pos, IBlockState state) { IMachineProperties machineProperties = blockType.getMachineProperties(); if (machineProperties instanceof IMachinePropertiesTesr) { - Minecraft minecraft = Proxies.common.getClientInstance(); + Minecraft minecraft = Minecraft.getMinecraft(); TextureMap textureMapBlocks = minecraft.getTextureMapBlocks(); IMachinePropertiesTesr machinePropertiesTesr = (IMachinePropertiesTesr) machineProperties; String particleTextureLocation = machinePropertiesTesr.getParticleTextureLocation(); diff --git a/src/main/java/forestry/core/render/ParticleHelper.java b/src/main/java/forestry/core/render/ParticleHelper.java index 68ed0d56c..dae1214b2 100644 --- a/src/main/java/forestry/core/render/ParticleHelper.java +++ b/src/main/java/forestry/core/render/ParticleHelper.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.core.render; -import forestry.core.proxy.Proxies; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -143,7 +142,7 @@ public class ParticleHelper { @SideOnly(Side.CLIENT) protected void setTexture(ParticleDigging fx, World world, BlockPos pos, IBlockState state) { - Minecraft minecraft = Proxies.common.getClientInstance(); + Minecraft minecraft = Minecraft.getMinecraft(); BlockRendererDispatcher blockRendererDispatcher = minecraft.getBlockRendererDispatcher(); BlockModelShapes blockModelShapes = blockRendererDispatcher.getBlockModelShapes(); TextureAtlasSprite texture = blockModelShapes.getTexture(state); diff --git a/src/main/java/forestry/core/render/ParticleRender.java b/src/main/java/forestry/core/render/ParticleRender.java new file mode 100644 index 000000000..b18cca375 --- /dev/null +++ b/src/main/java/forestry/core/render/ParticleRender.java @@ -0,0 +1,160 @@ +package forestry.core.render; + +import java.util.List; + +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.apiculture.IHiveTile; +import forestry.apiculture.entities.ParticleBeeExplore; +import forestry.apiculture.entities.ParticleBeeRoundTrip; +import forestry.apiculture.entities.ParticleBeeTargetEntity; +import forestry.apiculture.genetics.alleles.AlleleEffect; +import forestry.core.config.Config; +import forestry.core.entities.ParticleHoneydust; +import forestry.core.entities.ParticleIgnition; +import forestry.core.entities.ParticleSmoke; +import forestry.core.entities.ParticleSnow; +import forestry.core.utils.VectUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.Particle; +import net.minecraft.client.particle.ParticleManager; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.Vec3i; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ParticleRender { + public static boolean shouldSpawnParticle(World world) { + if (!Config.enableParticleFX) { + return false; + } + + Minecraft mc = Minecraft.getMinecraft(); + int particleSetting = mc.gameSettings.particleSetting; + + if (particleSetting == 2) { // minimal + return world.rand.nextInt(10) == 0; + } else if (particleSetting == 1) { // decreased + return world.rand.nextInt(3) != 0; + } else { // all + return true; + } + } + + public static void addBeeHiveFX(IBeeHousing housing, IBeeGenome genome, List flowerPositions) { + World world = housing.getWorldObj(); + if (!shouldSpawnParticle(world)) { + return; + } + + ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; + + Vec3d particleStart = housing.getBeeFXCoordinates(); + + // Avoid rendering bee particles that are too far away, they're very small. + // At 32+ distance, have no bee particles. Make more particles up close. + BlockPos playerPosition = Minecraft.getMinecraft().player.getPosition(); + double playerDistanceSq = playerPosition.distanceSqToCenter(particleStart.xCoord, particleStart.yCoord, particleStart.zCoord); + if (world.rand.nextInt(1024) < playerDistanceSq) { + return; + } + + int color = genome.getPrimary().getSpriteColour(0); + + if (!flowerPositions.isEmpty()) { + int randomInt = world.rand.nextInt(100); + + if (housing instanceof IHiveTile) { + if (((IHiveTile) housing).isAngry() || randomInt >= 85) { + List entitiesInRange = AlleleEffect.getEntitiesInRange(genome, housing, EntityLivingBase.class); + if (!entitiesInRange.isEmpty()) { + EntityLivingBase entity = entitiesInRange.get(world.rand.nextInt(entitiesInRange.size())); + Particle particle = new ParticleBeeTargetEntity(world, particleStart, entity, color); + effectRenderer.addEffect(particle); + return; + } + } + } + + if (randomInt < 75) { + BlockPos destination = flowerPositions.get(world.rand.nextInt(flowerPositions.size())); + Particle particle = new ParticleBeeRoundTrip(world, particleStart, destination, color); + effectRenderer.addEffect(particle); + } else { + Vec3i area = AlleleEffect.getModifiedArea(genome, housing); + Vec3i offset = housing.getCoordinates().add(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2); + BlockPos destination = VectUtil.getRandomPositionInArea(world.rand, area).add(offset); + Particle particle = new ParticleBeeExplore(world, particleStart, destination, color); + effectRenderer.addEffect(particle); + } + } + } + + public static void addEntityHoneyDustFX(World world, double x, double y, double z) { + if (!shouldSpawnParticle(world)) { + return; + } + + ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; + effectRenderer.addEffect(new ParticleHoneydust(world, x, y, z, 0, 0, 0)); + } + + public static void addEntityExplodeFX(World world, double x, double y, double z) { + if (!shouldSpawnParticle(world)) { + return; + } + + ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; + Particle Particle = effectRenderer.spawnEffectParticle(EnumParticleTypes.EXPLOSION_NORMAL.getParticleID(), x, y, z, 0, 0, 0); + effectRenderer.addEffect(Particle); + } + + public static void addEntitySnowFX(World world, double x, double y, double z) { + if (!shouldSpawnParticle(world)) { + return; + } + + ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; + effectRenderer.addEffect(new ParticleSnow(world, x + world.rand.nextGaussian(), y, z + world.rand.nextGaussian())); + } + + public static void addEntityIgnitionFX(World world, double x, double y, double z) { + if (!shouldSpawnParticle(world)) { + return; + } + + ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; + effectRenderer.addEffect(new ParticleIgnition(world, x, y, z)); + } + + public static void addEntitySmokeFX(World world, double x, double y, double z) { + if (!shouldSpawnParticle(world)) { + return; + } + + ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; + effectRenderer.addEffect(new ParticleSmoke(world, x, y, z)); + } + + public static void addEntityPotionFX(World world, double x, double y, double z, int color) { + if (!shouldSpawnParticle(world)) { + return; + } + + float red = (color >> 16 & 255) / 255.0F; + float green = (color >> 8 & 255) / 255.0F; + float blue = (color & 255) / 255.0F; + + ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; + Particle particle = effectRenderer.spawnEffectParticle(EnumParticleTypes.SPELL.getParticleID(), x, y, z, 0, 0, 0); + if (particle != null) { + particle.setRBGColorF(red, green, blue); + effectRenderer.addEffect(particle); + } + } +} diff --git a/src/main/java/forestry/core/render/RenderAnalyzer.java b/src/main/java/forestry/core/render/RenderAnalyzer.java index 274a6b78c..1f414a9b9 100755 --- a/src/main/java/forestry/core/render/RenderAnalyzer.java +++ b/src/main/java/forestry/core/render/RenderAnalyzer.java @@ -14,9 +14,9 @@ import javax.annotation.Nullable; import forestry.apiculture.render.ModelAnalyzer; import forestry.core.blocks.BlockBase; -import forestry.core.proxy.Proxies; import forestry.core.tiles.TileAnalyzer; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; @@ -74,7 +74,7 @@ public class RenderAnalyzer extends TileEntitySpecialRenderer { lastTick = world.getTotalWorldTime(); dummyEntityItem.onUpdate(); } - RenderManager rendermanager = Proxies.common.getClientInstance().getRenderManager(); + RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager(); rendermanager.doRenderEntity(dummyEntityItem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F, false); GlStateManager.popMatrix(); diff --git a/src/main/java/forestry/core/render/RenderEscritoire.java b/src/main/java/forestry/core/render/RenderEscritoire.java index 4e62f16f5..207e90787 100755 --- a/src/main/java/forestry/core/render/RenderEscritoire.java +++ b/src/main/java/forestry/core/render/RenderEscritoire.java @@ -15,11 +15,12 @@ import javax.annotation.Nullable; import forestry.core.blocks.BlockBase; import forestry.core.config.Constants; import forestry.core.models.ModelEscritoire; -import forestry.core.proxy.Proxies; import forestry.core.tiles.TileEscritoire; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; @@ -56,6 +57,7 @@ public class RenderEscritoire extends TileEntitySpecialRenderer private void render(ItemStack itemstack, @Nullable World world, EnumFacing orientation, double x, double y, double z) { float factor = (float) (1.0 / 16.0); + Minecraft minecraft = Minecraft.getMinecraft(); GlStateManager.pushMatrix(); { GlStateManager.translate((float) x + 0.5f, (float) y + 0.875f, (float) z + 0.5f); @@ -77,7 +79,8 @@ public class RenderEscritoire extends TileEntitySpecialRenderer break; } - Proxies.render.bindTexture(texture); + TextureManager textureManager = minecraft.getTextureManager(); + textureManager.bindTexture(texture); modelEscritoire.render(null, angle[0], angle[1], angle[2], 0f, 0f, factor); } GlStateManager.popMatrix(); @@ -98,7 +101,7 @@ public class RenderEscritoire extends TileEntitySpecialRenderer dummyEntityItem.onUpdate(); } - RenderManager rendermanager = Proxies.common.getClientInstance().getRenderManager(); + RenderManager rendermanager = minecraft.getRenderManager(); rendermanager.doRenderEntity(dummyEntityItem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F, false); } GlStateManager.popMatrix(); diff --git a/src/main/java/forestry/core/render/RenderMachine.java b/src/main/java/forestry/core/render/RenderMachine.java index 129f35acf..2fec399be 100755 --- a/src/main/java/forestry/core/render/RenderMachine.java +++ b/src/main/java/forestry/core/render/RenderMachine.java @@ -16,13 +16,14 @@ import java.util.Locale; import forestry.core.blocks.BlockBase; import forestry.core.fluids.Fluids; -import forestry.core.proxy.Proxies; import forestry.core.tiles.IRenderableTile; import forestry.core.tiles.TileBase; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; @@ -148,7 +149,8 @@ public class RenderMachine extends TileEntitySpecialRenderer { float factor = (float) (1.0 / 16.0); - Proxies.render.bindTexture(textureBase); + TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); + textureManager.bindTexture(textureBase); basefront.render(factor); baseback.render(factor); @@ -161,7 +163,8 @@ public class RenderMachine extends TileEntitySpecialRenderer { } private void renderTank(ModelRenderer tankModel, ResourceLocation textureBase, TankRenderInfo renderInfo, float factor) { - Proxies.render.bindTexture(textureBase); + TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); + textureManager.bindTexture(textureBase); tankModel.render(factor); ResourceLocation textureResourceTankLevel = texturesTankLevels.get(renderInfo.getLevel()); @@ -176,7 +179,7 @@ public class RenderMachine extends TileEntitySpecialRenderer { primaryTankColor.getRGBColorComponents(colors); GlStateManager.color(colors[0], colors[1], colors[2], 1.0f); - Proxies.render.bindTexture(textureResourceTankLevel); + textureManager.bindTexture(textureResourceTankLevel); tankModel.render(factor); GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); diff --git a/src/main/java/forestry/core/render/RenderMill.java b/src/main/java/forestry/core/render/RenderMill.java index 12ccd6bfd..866c1b42b 100755 --- a/src/main/java/forestry/core/render/RenderMill.java +++ b/src/main/java/forestry/core/render/RenderMill.java @@ -10,11 +10,12 @@ ******************************************************************************/ package forestry.core.render; -import forestry.core.proxy.Proxies; import forestry.core.tiles.TileMill; +import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; @@ -159,23 +160,24 @@ public class RenderMill extends TileEntitySpecialRenderer { float factor = (float) (1.0 / 16.0); - Proxies.render.bindTexture(textures[Textures.PEDESTAL.ordinal()]); + TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); + textureManager.bindTexture(textures[Textures.PEDESTAL.ordinal()]); pedestal.render(factor); - Proxies.render.bindTexture(textures[Textures.CHARGE.ordinal() + charge]); + textureManager.bindTexture(textures[Textures.CHARGE.ordinal() + charge]); column.render(factor); - Proxies.render.bindTexture(textures[Textures.EXTENSION.ordinal()]); + textureManager.bindTexture(textures[Textures.EXTENSION.ordinal()]); extension.render(factor); - Proxies.render.bindTexture(textures[Textures.BLADE_1.ordinal()]); + textureManager.bindTexture(textures[Textures.BLADE_1.ordinal()]); GlStateManager.translate(translate[0] * tfactor, translate[1] * tfactor, translate[2] * tfactor); blade1.render(factor); // Reset GlStateManager.translate(-translate[0] * tfactor, -translate[1] * tfactor, -translate[2] * tfactor); - Proxies.render.bindTexture(textures[Textures.BLADE_2.ordinal()]); + textureManager.bindTexture(textures[Textures.BLADE_2.ordinal()]); GlStateManager.translate(-translate[0] * tfactor, translate[1] * tfactor, -translate[2] * tfactor); blade2.render(factor); diff --git a/src/main/java/forestry/core/render/TextureManager.java b/src/main/java/forestry/core/render/TextureManagerForestry.java old mode 100755 new mode 100644 similarity index 85% rename from src/main/java/forestry/core/render/TextureManager.java rename to src/main/java/forestry/core/render/TextureManagerForestry.java index 431d12f22..3525e5a86 --- a/src/main/java/forestry/core/render/TextureManager.java +++ b/src/main/java/forestry/core/render/TextureManagerForestry.java @@ -17,9 +17,10 @@ import forestry.api.core.ForestryAPI; import forestry.api.core.ISpriteRegister; import forestry.api.core.ITextureManager; import forestry.core.config.Constants; -import forestry.core.proxy.Proxies; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; @@ -27,9 +28,9 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class TextureManager implements ITextureManager { +public class TextureManagerForestry implements ITextureManager { public static final ResourceLocation LOCATION_FORESTRY_TEXTURE = new ResourceLocation(Constants.MOD_ID, "textures/atlas/gui"); - private static final TextureManager INSTANCE = new TextureManager(); + private static final TextureManagerForestry INSTANCE = new TextureManagerForestry(); private final List spriteRegisters = new ArrayList<>(); private final TextureMapForestry textureMap; @@ -37,11 +38,11 @@ public class TextureManager implements ITextureManager { ForestryAPI.textureManager = INSTANCE; } - public static TextureManager getInstance() { + public static TextureManagerForestry getInstance() { return INSTANCE; } - private TextureManager() { + private TextureManagerForestry() { this.textureMap = new TextureMapForestry("textures"); } @@ -70,7 +71,7 @@ public class TextureManager implements ITextureManager { } public static TextureAtlasSprite registerSprite(ResourceLocation location) { - TextureMap textureMap = Proxies.common.getClientInstance().getTextureMapBlocks(); + TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks(); return textureMap.registerSprite(location); } @@ -85,6 +86,12 @@ public class TextureManager implements ITextureManager { return LOCATION_FORESTRY_TEXTURE; } + public void bindGuiTextureMap() { + TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); + ResourceLocation guiTextureMap = getGuiTextureMap(); + textureManager.bindTexture(guiTextureMap); + } + @Override public TextureAtlasSprite registerGuiSprite(ResourceLocation location) { return getTextureMap().registerSprite(location); diff --git a/src/main/java/forestry/core/tiles/IItemStackDisplay.java b/src/main/java/forestry/core/tiles/IItemStackDisplay.java index a4f515d42..6e2e876ba 100644 --- a/src/main/java/forestry/core/tiles/IItemStackDisplay.java +++ b/src/main/java/forestry/core/tiles/IItemStackDisplay.java @@ -11,7 +11,10 @@ package forestry.core.tiles; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IItemStackDisplay { + @SideOnly(Side.CLIENT) void handleItemStackForDisplay(ItemStack itemStack); } diff --git a/src/main/java/forestry/core/tiles/TileAnalyzer.java b/src/main/java/forestry/core/tiles/TileAnalyzer.java index 3dad1a8a0..8b970c57f 100644 --- a/src/main/java/forestry/core/tiles/TileAnalyzer.java +++ b/src/main/java/forestry/core/tiles/TileAnalyzer.java @@ -29,11 +29,13 @@ import forestry.core.inventory.InventoryAnalyzer; import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.network.PacketBufferForestry; import forestry.core.network.packets.PacketItemStackDisplay; -import forestry.core.proxy.Proxies; import forestry.core.utils.GeneticsUtil; import forestry.core.utils.InventoryUtil; +import forestry.core.utils.NetworkUtil; import forestry.plugins.ForestryPluginUids; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -42,6 +44,8 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiquidTankTile, IItemStackDisplay { private static final int TIME_TO_ANALYZE = 125; @@ -126,7 +130,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui setInventorySlotContents(InventoryAnalyzer.SLOT_ANALYZE, ItemStack.EMPTY); PacketItemStackDisplay packet = new PacketItemStackDisplay(this, getIndividualOnDisplay()); - Proxies.net.sendNetworkPacket(packet, pos, world); + NetworkUtil.sendNetworkPacket(packet, pos, world); return true; } @@ -152,6 +156,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui } @Override + @SideOnly(Side.CLIENT) public void readData(PacketBufferForestry data) throws IOException { super.readData(data); individualOnDisplayClient = data.readItemStack(); @@ -229,7 +234,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui } PacketItemStackDisplay packet = new PacketItemStackDisplay(this, getIndividualOnDisplay()); - Proxies.net.sendNetworkPacket(packet, pos, world); + NetworkUtil.sendNetworkPacket(packet, pos, world); } public ItemStack getIndividualOnDisplay() { @@ -262,12 +267,13 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui } @Override - public Object getGui(EntityPlayer player, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, int data) { return new GuiAnalyzer(player.inventory, this); } @Override - public Object getContainer(EntityPlayer player, int data) { + public Container getContainer(EntityPlayer player, int data) { return new ContainerAnalyzer(player.inventory, this); } } diff --git a/src/main/java/forestry/core/tiles/TileEngine.java b/src/main/java/forestry/core/tiles/TileEngine.java index 75fc0e030..b05c2180d 100644 --- a/src/main/java/forestry/core/tiles/TileEngine.java +++ b/src/main/java/forestry/core/tiles/TileEngine.java @@ -20,7 +20,7 @@ import forestry.core.config.Constants; import forestry.core.errors.EnumErrorCode; import forestry.core.network.IStreamableGui; import forestry.core.network.PacketBufferForestry; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; import forestry.energy.EnergyHelper; import forestry.energy.EnergyManager; import forestry.energy.EnergyTransferMode; @@ -29,6 +29,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public abstract class TileEngine extends TileBase implements IActivatable, IStreamableGui { private static final int CANT_SEND_ENERGY_TIME = 20; @@ -175,7 +177,7 @@ public abstract class TileEngine extends TileBase implements IActivatable, IStre this.active = active; if (!world.isRemote) { - Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), pos, world); + NetworkUtil.sendNetworkPacket(new PacketActiveUpdate(this), pos, world); } } @@ -267,6 +269,7 @@ public abstract class TileEngine extends TileBase implements IActivatable, IStre } @Override + @SideOnly(Side.CLIENT) public void readData(PacketBufferForestry data) throws IOException { super.readData(data); active = data.readBoolean(); diff --git a/src/main/java/forestry/core/tiles/TileEscritoire.java b/src/main/java/forestry/core/tiles/TileEscritoire.java index fc13f353c..2feff34bb 100644 --- a/src/main/java/forestry/core/tiles/TileEscritoire.java +++ b/src/main/java/forestry/core/tiles/TileEscritoire.java @@ -24,12 +24,16 @@ import forestry.core.inventory.watchers.ISlotPickupWatcher; import forestry.core.network.IStreamableGui; import forestry.core.network.PacketBufferForestry; import forestry.core.network.packets.PacketItemStackDisplay; -import forestry.core.proxy.Proxies; import forestry.core.utils.InventoryUtil; +import forestry.core.utils.NetworkUtil; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TileEscritoire extends TileBase implements ISidedInventory, ISlotPickupWatcher, IStreamableGui, IItemStackDisplay { @@ -124,6 +128,7 @@ public class TileEscritoire extends TileBase implements ISidedInventory, ISlotPi } @Override + @SideOnly(Side.CLIENT) public void readData(PacketBufferForestry data) throws IOException { super.readData(data); individualOnDisplayClient = data.readItemStack(); @@ -135,7 +140,7 @@ public class TileEscritoire extends TileBase implements ISidedInventory, ISlotPi if (slotIndex == InventoryEscritoire.SLOT_ANALYZE) { game.reset(); PacketItemStackDisplay packet = new PacketItemStackDisplay(this, getIndividualOnDisplay()); - Proxies.net.sendNetworkPacket(packet, pos, world); + NetworkUtil.sendNetworkPacket(packet, pos, world); } } @@ -144,17 +149,18 @@ public class TileEscritoire extends TileBase implements ISidedInventory, ISlotPi super.setInventorySlotContents(slotIndex, itemstack); if (slotIndex == InventoryEscritoire.SLOT_ANALYZE) { PacketItemStackDisplay packet = new PacketItemStackDisplay(this, getIndividualOnDisplay()); - Proxies.net.sendNetworkPacket(packet, pos, world); + NetworkUtil.sendNetworkPacket(packet, pos, world); } } @Override - public Object getGui(EntityPlayer player, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, int data) { return new GuiEscritoire(player, this); } @Override - public Object getContainer(EntityPlayer player, int data) { + public Container getContainer(EntityPlayer player, int data) { return new ContainerEscritoire(player, this); } diff --git a/src/main/java/forestry/core/tiles/TileForestry.java b/src/main/java/forestry/core/tiles/TileForestry.java index 7b3abdbcd..10dc8403a 100644 --- a/src/main/java/forestry/core/tiles/TileForestry.java +++ b/src/main/java/forestry/core/tiles/TileForestry.java @@ -25,8 +25,8 @@ import forestry.core.inventory.IInventoryAdapter; import forestry.core.network.IStreamable; import forestry.core.network.PacketBufferForestry; import forestry.core.network.packets.PacketTileStream; -import forestry.core.proxy.Proxies; import forestry.core.utils.NBTUtilForestry; +import forestry.core.utils.NetworkUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -40,6 +40,8 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.wrapper.InvWrapper; import net.minecraftforge.items.wrapper.SidedInvWrapper; @@ -93,6 +95,7 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IE } } + @SideOnly(Side.CLIENT) protected void updateClientSide() { } @@ -132,6 +135,7 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IE } @Override + @SideOnly(Side.CLIENT) public void handleUpdateTag(NBTTagCompound tag) { super.handleUpdateTag(tag); NBTUtilForestry.readStreamableFromNbt(this, tag); @@ -140,7 +144,7 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IE /* INetworkedEntity */ protected final void sendNetworkUpdate() { PacketTileStream packet = new PacketTileStream(this); - Proxies.net.sendNetworkPacket(packet, pos, world); + NetworkUtil.sendNetworkPacket(packet, pos, world); } /* IStreamable */ @@ -150,6 +154,7 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IE } @Override + @SideOnly(Side.CLIENT) public void readData(PacketBufferForestry data) throws IOException { } diff --git a/src/main/java/forestry/core/tiles/TileMill.java b/src/main/java/forestry/core/tiles/TileMill.java index f99e41293..a9d897b0d 100644 --- a/src/main/java/forestry/core/tiles/TileMill.java +++ b/src/main/java/forestry/core/tiles/TileMill.java @@ -13,6 +13,8 @@ package forestry.core.tiles; import java.io.IOException; import forestry.core.network.PacketBufferForestry; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public abstract class TileMill extends TileBase { @@ -44,6 +46,7 @@ public abstract class TileMill extends TileBase { } @Override + @SideOnly(Side.CLIENT) public void readData(PacketBufferForestry data) throws IOException { super.readData(data); charge = data.readInt(); diff --git a/src/main/java/forestry/core/tiles/TileNaturalistChest.java b/src/main/java/forestry/core/tiles/TileNaturalistChest.java index 2e3446c0c..3e2aa648b 100644 --- a/src/main/java/forestry/core/tiles/TileNaturalistChest.java +++ b/src/main/java/forestry/core/tiles/TileNaturalistChest.java @@ -19,11 +19,15 @@ import forestry.core.gui.GuiNaturalistInventory; import forestry.core.gui.IPagedInventory; import forestry.core.inventory.InventoryNaturalistChest; import forestry.core.network.PacketBufferForestry; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; +import net.minecraft.inventory.Container; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.AxisAlignedBB; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public abstract class TileNaturalistChest extends TileBase implements IPagedInventory { private static final float lidAngleVariationPerTick = 0.1F; @@ -103,19 +107,21 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve } @Override + @SideOnly(Side.CLIENT) public void readData(PacketBufferForestry data) throws IOException { super.readData(data); numPlayersUsing = data.readInt(); } @Override - public Object getGui(EntityPlayer player, int page) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, int page) { ContainerNaturalistInventory container = new ContainerNaturalistInventory(player.inventory, this, page); return new GuiNaturalistInventory(speciesRoot, player, container, page, 5); } @Override - public Object getContainer(EntityPlayer player, int page) { + public Container getContainer(EntityPlayer player, int page) { return new ContainerNaturalistInventory(player.inventory, this, page); } } diff --git a/src/main/java/forestry/core/tiles/TilePowered.java b/src/main/java/forestry/core/tiles/TilePowered.java index 763022011..32f88ab50 100644 --- a/src/main/java/forestry/core/tiles/TilePowered.java +++ b/src/main/java/forestry/core/tiles/TilePowered.java @@ -25,6 +25,8 @@ import forestry.energy.EnergyTransferMode; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; //@Optional.Interface(iface = "buildcraft.api.tiles.IHasWork", modid = "BuildCraftAPI|tiles") public abstract class TilePowered extends TileBase implements IRenderableTile, ISpeedUpgradable, IStreamableGui { @@ -166,6 +168,7 @@ public abstract class TilePowered extends TileBase implements IRenderableTile, I } @Override + @SideOnly(Side.CLIENT) public void readGuiData(PacketBufferForestry data) throws IOException { energyManager.readData(data); workCounter = data.readVarInt(); diff --git a/src/main/java/forestry/core/utils/BlockUtil.java b/src/main/java/forestry/core/utils/BlockUtil.java index 712799c58..e5b9a40a7 100644 --- a/src/main/java/forestry/core/utils/BlockUtil.java +++ b/src/main/java/forestry/core/utils/BlockUtil.java @@ -14,7 +14,6 @@ import javax.annotation.Nullable; import java.util.List; import forestry.core.network.packets.PacketFXSignal; -import forestry.core.proxy.Proxies; import net.minecraft.block.Block; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.BlockOldLog; @@ -310,7 +309,7 @@ public abstract class BlockUtil { public static boolean setBlockWithPlaceSound(World world, BlockPos pos, IBlockState blockState) { if (world.setBlockState(pos, blockState)) { PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, blockState); - Proxies.net.sendNetworkPacket(packet, pos, world); + NetworkUtil.sendNetworkPacket(packet, pos, world); return true; } return false; @@ -319,7 +318,7 @@ public abstract class BlockUtil { public static boolean setBlockWithBreakSound(World world, BlockPos pos, IBlockState blockState, IBlockState oldState) { if (world.setBlockState(pos, blockState)) { PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, oldState); - Proxies.net.sendNetworkPacket(packet, pos, world); + NetworkUtil.sendNetworkPacket(packet, pos, world); return true; } return false; @@ -328,7 +327,7 @@ public abstract class BlockUtil { public static boolean setBlockToAirWithSound(World world, BlockPos pos, IBlockState oldState) { if (world.setBlockToAir(pos)) { PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, oldState); - Proxies.net.sendNetworkPacket(packet, pos, world); + NetworkUtil.sendNetworkPacket(packet, pos, world); return true; } return false; diff --git a/src/main/java/forestry/core/utils/ItemTooltipUtil.java b/src/main/java/forestry/core/utils/ItemTooltipUtil.java index 2e0fe86a4..5e47d4adf 100644 --- a/src/main/java/forestry/core/utils/ItemTooltipUtil.java +++ b/src/main/java/forestry/core/utils/ItemTooltipUtil.java @@ -5,8 +5,11 @@ import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemTooltipUtil { + @SideOnly(Side.CLIENT) public static void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { String unlocalizedName = stack.getUnlocalizedName(); String tooltipKey = unlocalizedName + ".tooltip"; diff --git a/src/main/java/forestry/core/utils/ModelUtil.java b/src/main/java/forestry/core/utils/ModelUtil.java index 19d783e2c..e139381ef 100644 --- a/src/main/java/forestry/core/utils/ModelUtil.java +++ b/src/main/java/forestry/core/utils/ModelUtil.java @@ -10,6 +10,7 @@ ******************************************************************************/ package forestry.core.utils; +import javax.annotation.Nullable; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -19,15 +20,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import javax.annotation.Nullable; - -import org.apache.commons.io.IOUtils; - import com.google.common.base.Charsets; import com.google.common.collect.Lists; import com.google.common.collect.Maps; - -import forestry.core.proxy.Proxies; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderItem; import net.minecraft.client.renderer.block.model.IBakedModel; @@ -38,9 +33,13 @@ import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourceManager; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.model.SimpleModelState; import net.minecraftforge.client.model.IPerspectiveAwareModel.MapWrapper; +import net.minecraftforge.client.model.SimpleModelState; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.apache.commons.io.IOUtils; +@SideOnly(Side.CLIENT) public class ModelUtil { private static final Map blockDefinitions = Maps.newHashMap(); @@ -50,7 +49,7 @@ public class ModelUtil { */ @Nullable public static IBakedModel getModel(ItemStack stack) { - RenderItem renderItem = Proxies.common.getClientInstance().getRenderItem(); + RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); if (renderItem == null || renderItem.getItemModelMesher() == null) { return null; } @@ -83,6 +82,7 @@ public class ModelUtil { return blockDefinitions.computeIfAbsent(resourcelocation, k -> loadMultipartMBD(location, resourcelocation)); } catch (Exception exception) { + Log.error("Failed to getModelBlockDefinition", exception); } return new ModelBlockDefinition(new ArrayList<>()); } @@ -94,7 +94,7 @@ public class ModelUtil { private static ModelBlockDefinition loadMultipartMBD(ResourceLocation location, ResourceLocation fileIn) { List list = Lists.newArrayList(); - Minecraft mc = Proxies.common.getClientInstance(); + Minecraft mc = Minecraft.getMinecraft(); IResourceManager manager = mc.getResourceManager(); try { @@ -125,5 +125,4 @@ public class ModelUtil { return definition; } - } diff --git a/src/main/java/forestry/core/utils/NBTUtilForestry.java b/src/main/java/forestry/core/utils/NBTUtilForestry.java index c4b184334..85c8070de 100644 --- a/src/main/java/forestry/core/utils/NBTUtilForestry.java +++ b/src/main/java/forestry/core/utils/NBTUtilForestry.java @@ -32,6 +32,8 @@ import net.minecraft.nbt.NBTTagLong; import net.minecraft.nbt.NBTTagShort; import net.minecraft.nbt.NBTTagString; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * @author CovertJaguar @@ -92,6 +94,7 @@ public abstract class NBTUtilForestry { return nbt; } + @SideOnly(Side.CLIENT) public static void readStreamableFromNbt(IStreamable streamable, NBTTagCompound nbt) { if (nbt.hasKey("dataBytes")) { byte[] bytes = nbt.getByteArray("dataBytes"); diff --git a/src/main/java/forestry/core/proxy/ProxyNetwork.java b/src/main/java/forestry/core/utils/NetworkUtil.java old mode 100755 new mode 100644 similarity index 68% rename from src/main/java/forestry/core/proxy/ProxyNetwork.java rename to src/main/java/forestry/core/utils/NetworkUtil.java index da7d03880..cff66fbc5 --- a/src/main/java/forestry/core/proxy/ProxyNetwork.java +++ b/src/main/java/forestry/core/utils/NetworkUtil.java @@ -8,11 +8,14 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.core.proxy; +package forestry.core.utils; +import com.google.common.base.Preconditions; import forestry.Forestry; import forestry.core.network.IForestryPacketClient; import forestry.core.network.IForestryPacketServer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.management.PlayerChunkMap; @@ -20,10 +23,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; -public class ProxyNetwork { - - public

void sendNetworkPacket(P packet, BlockPos pos, World world) { +public class NetworkUtil { + public static

void sendNetworkPacket(P packet, BlockPos pos, World world) { if (!(world instanceof WorldServer)) { return; } @@ -45,7 +49,7 @@ public class ProxyNetwork { } } - public void sendToPlayer(IForestryPacketClient packet, EntityPlayer entityplayer) { + public static void sendToPlayer(IForestryPacketClient packet, EntityPlayer entityplayer) { if (!(entityplayer instanceof EntityPlayerMP) || entityplayer instanceof FakePlayer) { return; } @@ -54,12 +58,16 @@ public class ProxyNetwork { Forestry.getPacketHandler().sendPacket(packet.getPacket(), player); } - public void sendToServer(IForestryPacketServer packet) { - } - - public void inventoryChangeNotify(EntityPlayer player) { + public static void inventoryChangeNotify(EntityPlayer player) { if (player instanceof EntityPlayerMP) { ((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer); } } + + @SideOnly(Side.CLIENT) + public static void sendToServer(IForestryPacketServer packet) { + NetHandlerPlayClient netHandler = Minecraft.getMinecraft().getConnection(); + Preconditions.checkNotNull(netHandler, "Tried to send packet before netHandler (client world) exists."); + netHandler.sendPacket(packet.getPacket()); + } } diff --git a/src/main/java/forestry/core/utils/SoundUtil.java b/src/main/java/forestry/core/utils/SoundUtil.java new file mode 100644 index 000000000..0ce098821 --- /dev/null +++ b/src/main/java/forestry/core/utils/SoundUtil.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.utils; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.audio.SoundHandler; +import net.minecraft.init.SoundEvents; +import net.minecraft.util.SoundEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class SoundUtil { + @SideOnly(Side.CLIENT) + public static void playButtonClick() { + playSoundEvent(SoundEvents.UI_BUTTON_CLICK); + } + + @SideOnly(Side.CLIENT) + public static void playSoundEvent(SoundEvent soundIn) { + playSoundEvent(soundIn, 1.0f); + } + + @SideOnly(Side.CLIENT) + public static void playSoundEvent(SoundEvent soundIn, float pitchIn) { + Minecraft minecraft = Minecraft.getMinecraft(); + SoundHandler soundHandler = minecraft.getSoundHandler(); + PositionedSoundRecord sound = PositionedSoundRecord.getMasterRecord(soundIn, pitchIn); + soundHandler.playSound(sound); + } +} diff --git a/src/main/java/forestry/core/utils/StringUtil.java b/src/main/java/forestry/core/utils/StringUtil.java index bec89fc23..83d36c45e 100755 --- a/src/main/java/forestry/core/utils/StringUtil.java +++ b/src/main/java/forestry/core/utils/StringUtil.java @@ -13,9 +13,10 @@ package forestry.core.utils; import java.util.Locale; import java.util.regex.Pattern; -import forestry.core.proxy.Proxies; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class StringUtil { @@ -58,8 +59,9 @@ public class StringUtil { return line.toString(); } + @SideOnly(Side.CLIENT) public static int getLineHeight(int maxWidth, String... strings) { - Minecraft minecraft = Proxies.common.getClientInstance(); + Minecraft minecraft = Minecraft.getMinecraft(); FontRenderer fontRenderer = minecraft.fontRendererObj; int lineCount = 0; diff --git a/src/main/java/forestry/energy/blocks/BlockTypeEngine.java b/src/main/java/forestry/energy/blocks/BlockTypeEngine.java index 7284500d8..894d475b8 100644 --- a/src/main/java/forestry/energy/blocks/BlockTypeEngine.java +++ b/src/main/java/forestry/energy/blocks/BlockTypeEngine.java @@ -21,7 +21,6 @@ import forestry.energy.PluginEnergy; import forestry.energy.tiles.TileEngineBiogas; import forestry.energy.tiles.TileEngineClockwork; import forestry.energy.tiles.TileEnginePeat; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; public enum BlockTypeEngine implements IBlockTypeTesr { PEAT(createEngineProperties(TileEnginePeat.class, "peat", "/engine_copper")), @@ -39,13 +38,15 @@ public enum BlockTypeEngine implements IBlockTypeTesr { } protected static IMachinePropertiesTesr createEngineProperties(Class teClass, String name, String textureName) { - TileEntitySpecialRenderer renderer = PluginEnergy.proxy.getRenderDefaultEngine(Constants.TEXTURE_PATH_BLOCKS + textureName + "_"); - return new MachinePropertiesEngine<>(teClass, name, renderer, Constants.MOD_ID + ":blocks" + textureName + ".0"); + MachinePropertiesTesr machinePropertiesEngine = new MachinePropertiesTesr<>(teClass, name, Constants.MOD_ID + ":blocks" + textureName + ".0"); + PluginEnergy.proxy.setRenderDefaultEngine(machinePropertiesEngine, Constants.TEXTURE_PATH_BLOCKS + textureName + "_"); + return machinePropertiesEngine; } protected static IMachinePropertiesTesr createMachineProperties(Class teClass, String name, String textureName) { - TileEntitySpecialRenderer renderer = Proxies.render.getRenderDefaultMachine(Constants.TEXTURE_PATH_BLOCKS + textureName + "_"); - return new MachinePropertiesTesr<>(teClass, name, renderer, Constants.MOD_ID + ":blocks" + textureName + ".0"); + MachinePropertiesTesr machinePropertiesTesr = new MachinePropertiesTesr<>(teClass, name, Constants.MOD_ID + ":blocks" + textureName + ".0"); + Proxies.render.setRenderDefaultMachine(machinePropertiesTesr, Constants.TEXTURE_PATH_BLOCKS + textureName + "_"); + return machinePropertiesTesr; } @Override diff --git a/src/main/java/forestry/energy/blocks/MachinePropertiesEngine.java b/src/main/java/forestry/energy/blocks/MachinePropertiesEngine.java deleted file mode 100644 index 3075a30cd..000000000 --- a/src/main/java/forestry/energy/blocks/MachinePropertiesEngine.java +++ /dev/null @@ -1,13 +0,0 @@ -package forestry.energy.blocks; - -import javax.annotation.Nullable; - -import forestry.core.blocks.MachinePropertiesTesr; -import forestry.core.tiles.TileEngine; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; - -public class MachinePropertiesEngine extends MachinePropertiesTesr { - public MachinePropertiesEngine(Class teClass, String name, @Nullable TileEntitySpecialRenderer renderer, String particleTextureLocation) { - super(teClass, name, renderer, particleTextureLocation); - } -} diff --git a/src/main/java/forestry/energy/gui/GuiEngine.java b/src/main/java/forestry/energy/gui/GuiEngine.java index 26e3d6d6a..12b26ebeb 100755 --- a/src/main/java/forestry/energy/gui/GuiEngine.java +++ b/src/main/java/forestry/energy/gui/GuiEngine.java @@ -12,7 +12,7 @@ package forestry.energy.gui; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.ledgers.Ledger; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; import forestry.core.tiles.TileEngine; import forestry.core.utils.Translator; import net.minecraft.inventory.Container; @@ -45,7 +45,7 @@ public abstract class GuiEngine exten drawBackground(x, y); // Draw icon - drawSprite(TextureManager.getInstance().getDefault("misc/energy"), x + 3, y + 4); + drawSprite(TextureManagerForestry.getInstance().getDefault("misc/energy"), x + 3, y + 4); if (!isFullyOpened()) { return; diff --git a/src/main/java/forestry/energy/proxy/ProxyEnergy.java b/src/main/java/forestry/energy/proxy/ProxyEnergy.java index 74450d564..d05f9194c 100755 --- a/src/main/java/forestry/energy/proxy/ProxyEnergy.java +++ b/src/main/java/forestry/energy/proxy/ProxyEnergy.java @@ -10,14 +10,11 @@ ******************************************************************************/ package forestry.energy.proxy; -import javax.annotation.Nullable; - +import forestry.core.blocks.MachinePropertiesTesr; import forestry.core.tiles.TileEngine; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; public class ProxyEnergy { - @Nullable - public TileEntitySpecialRenderer getRenderDefaultEngine(String gfxBase) { - return null; + public void setRenderDefaultEngine(MachinePropertiesTesr machineProperties, String gfxBase) { + } } diff --git a/src/main/java/forestry/energy/proxy/ProxyEnergyClient.java b/src/main/java/forestry/energy/proxy/ProxyEnergyClient.java index 405542afc..e66808adc 100644 --- a/src/main/java/forestry/energy/proxy/ProxyEnergyClient.java +++ b/src/main/java/forestry/energy/proxy/ProxyEnergyClient.java @@ -10,16 +10,17 @@ ******************************************************************************/ package forestry.energy.proxy; +import forestry.core.blocks.MachinePropertiesTesr; import forestry.core.tiles.TileEngine; import forestry.energy.render.RenderEngine; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SuppressWarnings("unused") +@SideOnly(Side.CLIENT) public class ProxyEnergyClient extends ProxyEnergy { - @Override - public TileEntitySpecialRenderer getRenderDefaultEngine(String gfxBase) { - return new RenderEngine(gfxBase); + public void setRenderDefaultEngine(MachinePropertiesTesr machineProperties, String gfxBase) { + machineProperties.setRenderer(new RenderEngine(gfxBase)); } - } diff --git a/src/main/java/forestry/energy/render/RenderEngine.java b/src/main/java/forestry/energy/render/RenderEngine.java index c4c2a76de..8a48aefa5 100755 --- a/src/main/java/forestry/energy/render/RenderEngine.java +++ b/src/main/java/forestry/energy/render/RenderEngine.java @@ -14,14 +14,15 @@ import javax.annotation.Nullable; import forestry.core.blocks.BlockBase; import forestry.core.config.Constants; -import forestry.core.proxy.Proxies; import forestry.core.render.ForestryResource; import forestry.core.tiles.TemperatureState; import forestry.core.tiles.TileEngine; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; @@ -153,10 +154,11 @@ public class RenderEngine extends TileEntitySpecialRenderer { float factor = (float) (1.0 / 16.0); - Proxies.render.bindTexture(textures[Textures.BASE.ordinal()]); + TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); + textureManager.bindTexture(textures[Textures.BASE.ordinal()]); boiler.render(factor); - Proxies.render.bindTexture(textures[Textures.PISTON.ordinal()]); + textureManager.bindTexture(textures[Textures.PISTON.ordinal()]); GlStateManager.translate(translate[0] * tfactor, translate[1] * tfactor, translate[2] * tfactor); piston.render(factor); GlStateManager.translate(-translate[0] * tfactor, -translate[1] * tfactor, -translate[2] * tfactor); @@ -182,10 +184,10 @@ public class RenderEngine extends TileEntitySpecialRenderer { break; } - Proxies.render.bindTexture(texture); + textureManager.bindTexture(texture); trunk.render(factor); - Proxies.render.bindTexture(textures[Textures.EXTENSION.ordinal()]); + textureManager.bindTexture(textures[Textures.EXTENSION.ordinal()]); float chamberf = 2F / 16F; if (step > 0) { diff --git a/src/main/java/forestry/energy/tiles/TileEngineBiogas.java b/src/main/java/forestry/energy/tiles/TileEngineBiogas.java index bdae9cdc1..7938a31fd 100644 --- a/src/main/java/forestry/energy/tiles/TileEngineBiogas.java +++ b/src/main/java/forestry/energy/tiles/TileEngineBiogas.java @@ -28,7 +28,9 @@ import forestry.core.tiles.TileEngine; import forestry.energy.gui.ContainerEngineBiogas; import forestry.energy.gui.GuiEngineBiogas; import forestry.energy.inventory.InventoryEngineBiogas; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.inventory.ISidedInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; @@ -37,6 +39,8 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILiquidTankTile { private final FilteredTank fuelTank; @@ -262,6 +266,7 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi } @Override + @SideOnly(Side.CLIENT) public void readData(PacketBufferForestry data) throws IOException { super.readData(data); shutdown = data.readBoolean(); @@ -284,12 +289,13 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi } @Override - public Object getGui(EntityPlayer player, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, int data) { return new GuiEngineBiogas(player.inventory, this); } @Override - public Object getContainer(EntityPlayer player, int data) { + public Container getContainer(EntityPlayer player, int data) { return new ContainerEngineBiogas(player.inventory, this); } } diff --git a/src/main/java/forestry/energy/tiles/TileEngineClockwork.java b/src/main/java/forestry/energy/tiles/TileEngineClockwork.java index 5500062e3..961e6cec8 100644 --- a/src/main/java/forestry/energy/tiles/TileEngineClockwork.java +++ b/src/main/java/forestry/energy/tiles/TileEngineClockwork.java @@ -16,11 +16,15 @@ import forestry.core.config.Constants; import forestry.core.tiles.TemperatureState; import forestry.core.tiles.TileEngine; import forestry.core.utils.DamageSourceForestry; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TileEngineClockwork extends TileEngine { @@ -154,13 +158,14 @@ public class TileEngineClockwork extends TileEngine { @Override @Nullable - public Object getGui(EntityPlayer player, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, int data) { return null; } @Override @Nullable - public Object getContainer(EntityPlayer player, int data) { + public Container getContainer(EntityPlayer player, int data) { return null; } } diff --git a/src/main/java/forestry/energy/tiles/TileEnginePeat.java b/src/main/java/forestry/energy/tiles/TileEnginePeat.java index 332d60ab4..206740426 100644 --- a/src/main/java/forestry/energy/tiles/TileEnginePeat.java +++ b/src/main/java/forestry/energy/tiles/TileEnginePeat.java @@ -26,11 +26,15 @@ import forestry.core.utils.InventoryUtil; import forestry.energy.gui.ContainerEnginePeat; import forestry.energy.gui.GuiEnginePeat; import forestry.energy.inventory.InventoryEnginePeat; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.InvWrapper; @@ -308,12 +312,13 @@ public class TileEnginePeat extends TileEngine implements ISidedInventory { // } @Override - public Object getGui(EntityPlayer player, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, int data) { return new GuiEnginePeat(player.inventory, this); } @Override - public Object getContainer(EntityPlayer player, int data) { + public Container getContainer(EntityPlayer player, int data) { return new ContainerEnginePeat(player.inventory, this); } } diff --git a/src/main/java/forestry/factory/blocks/BlockTypeFactoryTesr.java b/src/main/java/forestry/factory/blocks/BlockTypeFactoryTesr.java index b801021ee..1f6b5e759 100644 --- a/src/main/java/forestry/factory/blocks/BlockTypeFactoryTesr.java +++ b/src/main/java/forestry/factory/blocks/BlockTypeFactoryTesr.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.factory.blocks; -import javax.annotation.Nullable; - import forestry.core.blocks.IBlockTypeTesr; import forestry.core.blocks.IMachinePropertiesTesr; import forestry.core.blocks.MachinePropertiesTesr; import forestry.core.config.Constants; import forestry.core.proxy.Proxies; import forestry.core.tiles.TileBase; +import forestry.core.tiles.TileMill; import forestry.factory.tiles.TileBottler; import forestry.factory.tiles.TileCarpenter; import forestry.factory.tiles.TileCentrifuge; @@ -26,7 +25,6 @@ import forestry.factory.tiles.TileMillRainmaker; import forestry.factory.tiles.TileMoistener; import forestry.factory.tiles.TileSqueezer; import forestry.factory.tiles.TileStill; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; public enum BlockTypeFactoryTesr implements IBlockTypeTesr { BOTTLER(TileBottler.class, "bottler"), @@ -36,19 +34,22 @@ public enum BlockTypeFactoryTesr implements IBlockTypeTesr { MOISTENER(TileMoistener.class, "moistener"), SQUEEZER(TileSqueezer.class, "squeezer"), STILL(TileStill.class, "still"), - RAINMAKER(TileMillRainmaker.class, "rainmaker", Proxies.render.getRenderMill(Constants.TEXTURE_PATH_BLOCKS + "/rainmaker_")); + RAINMAKER(TileMillRainmaker.class, "rainmaker", Constants.TEXTURE_PATH_BLOCKS + "/rainmaker_"); public static final BlockTypeFactoryTesr[] VALUES = values(); private final IMachinePropertiesTesr machineProperties; BlockTypeFactoryTesr(Class teClass, String name) { - TileEntitySpecialRenderer renderer = Proxies.render.getRenderDefaultMachine(Constants.TEXTURE_PATH_BLOCKS + "/" + name + "_"); - this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, Constants.MOD_ID + ":blocks/" + name + ".0"); + MachinePropertiesTesr machineProperties = new MachinePropertiesTesr<>(teClass, name, Constants.MOD_ID + ":blocks/" + name + ".0"); + Proxies.render.setRenderDefaultMachine(machineProperties, Constants.TEXTURE_PATH_BLOCKS + "/" + name + "_"); + this.machineProperties = machineProperties; } - BlockTypeFactoryTesr(Class teClass, String name, @Nullable TileEntitySpecialRenderer renderer) { - this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, Constants.MOD_ID + ":blocks/" + name + ".0"); + BlockTypeFactoryTesr(Class teClass, String name, String renderMillTexture) { + MachinePropertiesTesr machineProperties = new MachinePropertiesTesr<>(teClass, name, Constants.MOD_ID + ":blocks/" + name + ".0"); + Proxies.render.setRenderMill(machineProperties, renderMillTexture); + this.machineProperties = machineProperties; } @Override diff --git a/src/main/java/forestry/factory/gui/ContainerFabricator.java b/src/main/java/forestry/factory/gui/ContainerFabricator.java index 989c731c0..f7b57b6a0 100755 --- a/src/main/java/forestry/factory/gui/ContainerFabricator.java +++ b/src/main/java/forestry/factory/gui/ContainerFabricator.java @@ -22,6 +22,8 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ContainerFabricator extends ContainerLiquidTanks implements IContainerCrafting { @@ -58,6 +60,7 @@ public class ContainerFabricator extends ContainerLiquidTanks im } @Override + @SideOnly(Side.CLIENT) public void updateProgressBar(int messageId, int data) { super.updateProgressBar(messageId, data); diff --git a/src/main/java/forestry/factory/gui/ContainerFermenter.java b/src/main/java/forestry/factory/gui/ContainerFermenter.java index dea3ed7ca..aace47b35 100755 --- a/src/main/java/forestry/factory/gui/ContainerFermenter.java +++ b/src/main/java/forestry/factory/gui/ContainerFermenter.java @@ -19,6 +19,8 @@ import forestry.factory.inventory.InventoryFermenter; import forestry.factory.tiles.TileFermenter; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IContainerListener; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ContainerFermenter extends ContainerLiquidTanks { @@ -33,6 +35,7 @@ public class ContainerFermenter extends ContainerLiquidTanks { } @Override + @SideOnly(Side.CLIENT) public void updateProgressBar(int messageId, int data) { super.updateProgressBar(messageId, data); diff --git a/src/main/java/forestry/factory/gui/ContainerMoistener.java b/src/main/java/forestry/factory/gui/ContainerMoistener.java index 3ab390d53..669424123 100755 --- a/src/main/java/forestry/factory/gui/ContainerMoistener.java +++ b/src/main/java/forestry/factory/gui/ContainerMoistener.java @@ -19,6 +19,8 @@ import forestry.factory.tiles.TileMoistener; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.IInventory; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ContainerMoistener extends ContainerLiquidTanks implements ISlotChangeWatcher { @@ -52,6 +54,7 @@ public class ContainerMoistener extends ContainerLiquidTanks impl } @Override + @SideOnly(Side.CLIENT) public void updateProgressBar(int messageId, int data) { super.updateProgressBar(messageId, data); diff --git a/src/main/java/forestry/factory/gui/ContainerRaintank.java b/src/main/java/forestry/factory/gui/ContainerRaintank.java index 140fc459b..1e25482da 100755 --- a/src/main/java/forestry/factory/gui/ContainerRaintank.java +++ b/src/main/java/forestry/factory/gui/ContainerRaintank.java @@ -17,6 +17,8 @@ import forestry.factory.inventory.InventoryRaintank; import forestry.factory.tiles.TileRaintank; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IContainerListener; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ContainerRaintank extends ContainerLiquidTanks { @@ -28,6 +30,7 @@ public class ContainerRaintank extends ContainerLiquidTanks { } @Override + @SideOnly(Side.CLIENT) public void updateProgressBar(int messageId, int data) { super.updateProgressBar(messageId, data); diff --git a/src/main/java/forestry/factory/gui/ContainerWorktable.java b/src/main/java/forestry/factory/gui/ContainerWorktable.java index 567e76793..16fc3ea02 100755 --- a/src/main/java/forestry/factory/gui/ContainerWorktable.java +++ b/src/main/java/forestry/factory/gui/ContainerWorktable.java @@ -16,8 +16,8 @@ import forestry.core.gui.IGuiSelectable; import forestry.core.gui.slots.SlotCraftMatrix; import forestry.core.gui.slots.SlotCrafter; import forestry.core.network.packets.PacketGuiSelectRequest; -import forestry.core.proxy.Proxies; import forestry.core.utils.ItemStackUtil; +import forestry.core.utils.NetworkUtil; import forestry.factory.inventory.InventoryCraftingForestry; import forestry.factory.inventory.InventoryGhostCrafting; import forestry.factory.inventory.InventoryWorktable; @@ -32,6 +32,8 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ContainerWorktable extends ContainerTile implements IContainerCrafting, IGuiSelectable { private final InventoryCraftingForestry craftMatrix = new InventoryCraftingForestry(this); @@ -112,12 +114,14 @@ public class ContainerWorktable extends ContainerTile implements } /* Gui Selection Handling */ + @SideOnly(Side.CLIENT) public static void clearRecipe() { sendRecipeClick(-1, 0); } + @SideOnly(Side.CLIENT) public static void sendRecipeClick(int mouseButton, int recipeIndex) { - Proxies.net.sendToServer(new PacketGuiSelectRequest(mouseButton, recipeIndex)); + NetworkUtil.sendToServer(new PacketGuiSelectRequest(mouseButton, recipeIndex)); } @Override @@ -154,7 +158,8 @@ public class ContainerWorktable extends ContainerTile implements } } + @SideOnly(Side.CLIENT) public void sendWorktableRecipeRequest(MemorizedRecipe recipe) { - Proxies.net.sendToServer(new PacketWorktableRecipeRequest(tile, recipe)); + NetworkUtil.sendToServer(new PacketWorktableRecipeRequest(tile, recipe)); } } diff --git a/src/main/java/forestry/factory/gui/GuiWorktable.java b/src/main/java/forestry/factory/gui/GuiWorktable.java index c02d329f0..c10d841e5 100755 --- a/src/main/java/forestry/factory/gui/GuiWorktable.java +++ b/src/main/java/forestry/factory/gui/GuiWorktable.java @@ -15,7 +15,8 @@ import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.buttons.GuiBetterButton; import forestry.core.gui.buttons.StandardButtonTextureSets; import forestry.core.network.packets.PacketGuiSelectRequest; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; +import forestry.core.utils.SoundUtil; import forestry.factory.gui.widgets.ClearWorktable; import forestry.factory.gui.widgets.MemorizedRecipeSlot; import forestry.factory.recipes.RecipeMemory; @@ -72,8 +73,8 @@ public class GuiWorktable extends GuiForestryTitled { @Override protected void actionPerformed(GuiButton button) { int id = 100 + button.id; - Proxies.net.sendToServer(new PacketGuiSelectRequest(id, 0)); - Proxies.common.playButtonClick(); + NetworkUtil.sendToServer(new PacketGuiSelectRequest(id, 0)); + SoundUtil.playButtonClick(); } @Override diff --git a/src/main/java/forestry/factory/gui/widgets/ClearWorktable.java b/src/main/java/forestry/factory/gui/widgets/ClearWorktable.java index 0ae29715b..748bc74fb 100644 --- a/src/main/java/forestry/factory/gui/widgets/ClearWorktable.java +++ b/src/main/java/forestry/factory/gui/widgets/ClearWorktable.java @@ -12,7 +12,7 @@ package forestry.factory.gui.widgets; import forestry.core.gui.widgets.Widget; import forestry.core.gui.widgets.WidgetManager; -import forestry.core.proxy.Proxies; +import forestry.core.utils.SoundUtil; import forestry.factory.gui.ContainerWorktable; public class ClearWorktable extends Widget { @@ -30,6 +30,6 @@ public class ClearWorktable extends Widget { @Override public void handleMouseClick(int mouseX, int mouseY, int mouseButton) { ContainerWorktable.clearRecipe(); - Proxies.common.playButtonClick(); + SoundUtil.playButtonClick(); } } diff --git a/src/main/java/forestry/factory/gui/widgets/MemorizedRecipeSlot.java b/src/main/java/forestry/factory/gui/widgets/MemorizedRecipeSlot.java index 58749b573..871f81029 100644 --- a/src/main/java/forestry/factory/gui/widgets/MemorizedRecipeSlot.java +++ b/src/main/java/forestry/factory/gui/widgets/MemorizedRecipeSlot.java @@ -12,8 +12,8 @@ package forestry.factory.gui.widgets; import forestry.core.gui.widgets.ItemStackWidgetBase; import forestry.core.gui.widgets.WidgetManager; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; +import forestry.core.utils.SoundUtil; import forestry.factory.gui.ContainerWorktable; import forestry.factory.recipes.RecipeMemory; import net.minecraft.client.renderer.GlStateManager; @@ -21,7 +21,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.item.ItemStack; public class MemorizedRecipeSlot extends ItemStackWidgetBase { - private static final TextureAtlasSprite lockIcon = TextureManager.getInstance().getDefault("slots/locked"); + private static final TextureAtlasSprite lockIcon = TextureManagerForestry.getInstance().getDefault("slots/locked"); private final RecipeMemory recipeMemory; private final int slotNumber; @@ -43,7 +43,7 @@ public class MemorizedRecipeSlot extends ItemStackWidgetBase { GlStateManager.disableDepth(); if (recipeMemory.isLocked(slotNumber)) { - Proxies.render.bindTexture(TextureManager.getInstance().getGuiTextureMap()); + TextureManagerForestry.getInstance().bindGuiTextureMap(); manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, lockIcon, 16, 16); } @@ -54,7 +54,7 @@ public class MemorizedRecipeSlot extends ItemStackWidgetBase { public void handleMouseClick(int mouseX, int mouseY, int mouseButton) { if (!getItemStack().isEmpty()) { ContainerWorktable.sendRecipeClick(mouseButton, slotNumber); - Proxies.common.playButtonClick(); + SoundUtil.playButtonClick(); } } } diff --git a/src/main/java/forestry/factory/network/PacketRegistryFactory.java b/src/main/java/forestry/factory/network/PacketRegistryFactory.java index 91fb2bd1c..790f9d2bf 100644 --- a/src/main/java/forestry/factory/network/PacketRegistryFactory.java +++ b/src/main/java/forestry/factory/network/PacketRegistryFactory.java @@ -18,15 +18,21 @@ import forestry.factory.network.packets.PacketRecipeTransferUpdate; import forestry.factory.network.packets.PacketWorktableMemoryUpdate; import forestry.factory.network.packets.PacketWorktableRecipeRequest; import forestry.factory.network.packets.PacketWorktableRecipeUpdate; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketRegistryFactory implements IPacketRegistry { @Override - public void registerPackets() { - PacketIdClient.WORKTABLE_MEMORY_UPDATE.setPacketHandler(new PacketWorktableMemoryUpdate.Handler()); - PacketIdClient.WORKTABLE_CRAFTING_UPDATE.setPacketHandler(new PacketWorktableRecipeUpdate.Handler()); - PacketIdClient.RECIPE_TRANSFER_UPDATE.setPacketHandler(new PacketRecipeTransferUpdate.Handler()); - + public void registerPacketsServer() { PacketIdServer.WORKTABLE_RECIPE_REQUEST.setPacketHandler(new PacketWorktableRecipeRequest.Handler()); PacketIdServer.RECIPE_TRANSFER_REQUEST.setPacketHandler(new PacketRecipeTransferRequest.Handler()); } + + @Override + @SideOnly(Side.CLIENT) + public void registerPacketsClient() { + PacketIdClient.WORKTABLE_MEMORY_UPDATE.setPacketHandler(new PacketWorktableMemoryUpdate.Handler()); + PacketIdClient.WORKTABLE_CRAFTING_UPDATE.setPacketHandler(new PacketWorktableRecipeUpdate.Handler()); + PacketIdClient.RECIPE_TRANSFER_UPDATE.setPacketHandler(new PacketRecipeTransferUpdate.Handler()); + } } diff --git a/src/main/java/forestry/factory/network/packets/PacketRecipeTransferRequest.java b/src/main/java/forestry/factory/network/packets/PacketRecipeTransferRequest.java index ab235141c..c80a2fa57 100644 --- a/src/main/java/forestry/factory/network/packets/PacketRecipeTransferRequest.java +++ b/src/main/java/forestry/factory/network/packets/PacketRecipeTransferRequest.java @@ -17,8 +17,8 @@ import forestry.core.network.IForestryPacketHandlerServer; import forestry.core.network.IForestryPacketServer; import forestry.core.network.PacketBufferForestry; import forestry.core.network.PacketIdServer; -import forestry.core.proxy.Proxies; import forestry.core.tiles.TileBase; +import forestry.core.utils.NetworkUtil; import forestry.factory.tiles.TileCarpenter; import forestry.factory.tiles.TileFabricator; import net.minecraft.entity.player.EntityPlayerMP; @@ -62,7 +62,7 @@ public class PacketRecipeTransferRequest extends ForestryPacket implements IFore index++; } - Proxies.net.sendNetworkPacket(new PacketRecipeTransferUpdate(carpenter, craftingInventory), pos, player.world); + NetworkUtil.sendNetworkPacket(new PacketRecipeTransferUpdate(carpenter, craftingInventory), pos, player.world); } else if (tile instanceof TileFabricator) { TileFabricator fabricator = (TileFabricator) tile; int index = 0; @@ -71,7 +71,7 @@ public class PacketRecipeTransferRequest extends ForestryPacket implements IFore index++; } - Proxies.net.sendNetworkPacket(new PacketRecipeTransferUpdate(fabricator, craftingInventory), pos, player.world); + NetworkUtil.sendNetworkPacket(new PacketRecipeTransferUpdate(fabricator, craftingInventory), pos, player.world); } } } diff --git a/src/main/java/forestry/factory/network/packets/PacketRecipeTransferUpdate.java b/src/main/java/forestry/factory/network/packets/PacketRecipeTransferUpdate.java index a05314686..92c98e7b5 100644 --- a/src/main/java/forestry/factory/network/packets/PacketRecipeTransferUpdate.java +++ b/src/main/java/forestry/factory/network/packets/PacketRecipeTransferUpdate.java @@ -25,6 +25,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketRecipeTransferUpdate extends ForestryPacket implements IForestryPacketClient { private final BlockPos pos; @@ -46,6 +48,7 @@ public class PacketRecipeTransferUpdate extends ForestryPacket implements IFores return PacketIdClient.RECIPE_TRANSFER_UPDATE; } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/factory/network/packets/PacketWorktableMemoryUpdate.java b/src/main/java/forestry/factory/network/packets/PacketWorktableMemoryUpdate.java index 643c84f40..29849e8bb 100644 --- a/src/main/java/forestry/factory/network/packets/PacketWorktableMemoryUpdate.java +++ b/src/main/java/forestry/factory/network/packets/PacketWorktableMemoryUpdate.java @@ -22,6 +22,8 @@ import forestry.factory.tiles.TileWorktable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketWorktableMemoryUpdate extends ForestryPacket implements IForestryPacketClient { private final BlockPos pos; @@ -43,6 +45,7 @@ public class PacketWorktableMemoryUpdate extends ForestryPacket implements IFore recipeMemory.writeData(data); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/factory/network/packets/PacketWorktableRecipeRequest.java b/src/main/java/forestry/factory/network/packets/PacketWorktableRecipeRequest.java index 218728760..ab5e98dc0 100644 --- a/src/main/java/forestry/factory/network/packets/PacketWorktableRecipeRequest.java +++ b/src/main/java/forestry/factory/network/packets/PacketWorktableRecipeRequest.java @@ -17,7 +17,7 @@ import forestry.core.network.IForestryPacketHandlerServer; import forestry.core.network.IForestryPacketServer; import forestry.core.network.PacketBufferForestry; import forestry.core.network.PacketIdServer; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; import forestry.factory.gui.ContainerWorktable; import forestry.factory.recipes.MemorizedRecipe; import forestry.factory.tiles.TileWorktable; @@ -65,7 +65,7 @@ public class PacketWorktableRecipeRequest extends ForestryPacket implements IFor containerWorktable.updateCraftMatrix(); } - Proxies.net.sendNetworkPacket(new PacketWorktableRecipeUpdate(worktable), pos, player.world); + NetworkUtil.sendNetworkPacket(new PacketWorktableRecipeUpdate(worktable), pos, player.world); } } } diff --git a/src/main/java/forestry/factory/network/packets/PacketWorktableRecipeUpdate.java b/src/main/java/forestry/factory/network/packets/PacketWorktableRecipeUpdate.java index bd1ee058f..ace05ebad 100644 --- a/src/main/java/forestry/factory/network/packets/PacketWorktableRecipeUpdate.java +++ b/src/main/java/forestry/factory/network/packets/PacketWorktableRecipeUpdate.java @@ -23,6 +23,8 @@ import forestry.factory.tiles.TileWorktable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; /** * Used to sync the worktable crafting result from Server to Client. @@ -48,6 +50,7 @@ public class PacketWorktableRecipeUpdate extends ForestryPacket implements IFore data.writeStreamable(recipe); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/factory/recipes/RecipeMemory.java b/src/main/java/forestry/factory/recipes/RecipeMemory.java index 3f8fe6db2..ec7cff8a4 100644 --- a/src/main/java/forestry/factory/recipes/RecipeMemory.java +++ b/src/main/java/forestry/factory/recipes/RecipeMemory.java @@ -26,6 +26,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class RecipeMemory implements INbtWritable, IStreamable { @@ -200,6 +202,7 @@ public class RecipeMemory implements INbtWritable, IStreamable { } @Override + @SideOnly(Side.CLIENT) public void readData(PacketBufferForestry data) throws IOException { data.readStreamables(memorizedRecipes, MemorizedRecipe::new); } diff --git a/src/main/java/forestry/factory/recipes/jei/FactoryJeiPlugin.java b/src/main/java/forestry/factory/recipes/jei/FactoryJeiPlugin.java index c2b703712..877172197 100644 --- a/src/main/java/forestry/factory/recipes/jei/FactoryJeiPlugin.java +++ b/src/main/java/forestry/factory/recipes/jei/FactoryJeiPlugin.java @@ -58,8 +58,11 @@ import mezz.jei.api.gui.BlankAdvancedGuiHandler; import mezz.jei.api.recipe.VanillaRecipeCategoryUid; import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @JEIPlugin +@SideOnly(Side.CLIENT) public class FactoryJeiPlugin extends BlankModPlugin { @Nullable public static IJeiHelpers jeiHelpers; diff --git a/src/main/java/forestry/factory/recipes/jei/WorktableRecipeTransferHandler.java b/src/main/java/forestry/factory/recipes/jei/WorktableRecipeTransferHandler.java index 910179afb..326572e36 100644 --- a/src/main/java/forestry/factory/recipes/jei/WorktableRecipeTransferHandler.java +++ b/src/main/java/forestry/factory/recipes/jei/WorktableRecipeTransferHandler.java @@ -14,7 +14,10 @@ import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) class WorktableRecipeTransferHandler implements IRecipeTransferHandler { @Override public Class getContainerClass() { diff --git a/src/main/java/forestry/factory/recipes/jei/carpenter/CarpenterRecipeTransferHandler.java b/src/main/java/forestry/factory/recipes/jei/carpenter/CarpenterRecipeTransferHandler.java index 88c206c7b..6a974f520 100644 --- a/src/main/java/forestry/factory/recipes/jei/carpenter/CarpenterRecipeTransferHandler.java +++ b/src/main/java/forestry/factory/recipes/jei/carpenter/CarpenterRecipeTransferHandler.java @@ -2,7 +2,7 @@ package forestry.factory.recipes.jei.carpenter; import java.util.Map.Entry; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; import forestry.factory.gui.ContainerCarpenter; import forestry.factory.network.packets.PacketRecipeTransferRequest; import mezz.jei.api.gui.IGuiIngredient; @@ -13,7 +13,10 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class CarpenterRecipeTransferHandler implements IRecipeTransferHandler { @Override @@ -37,7 +40,7 @@ public class CarpenterRecipeTransferHandler implements IRecipeTransferHandler { @Override @@ -35,7 +38,7 @@ public class FabricatorRecipeTransferHandler implements IRecipeTransferHandler { public static class Key { public final EnumFarmBlockTexture texture; diff --git a/src/main/java/forestry/farming/proxy/ProxyFarmingClient.java b/src/main/java/forestry/farming/proxy/ProxyFarmingClient.java index e445725c6..ec0ed3578 100644 --- a/src/main/java/forestry/farming/proxy/ProxyFarmingClient.java +++ b/src/main/java/forestry/farming/proxy/ProxyFarmingClient.java @@ -11,17 +11,20 @@ package forestry.farming.proxy; import forestry.core.models.BlockModelEntry; -import forestry.core.proxy.Proxies; +import forestry.core.models.ModelManager; import forestry.farming.PluginFarming; import forestry.farming.models.ModelFarmBlock; import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SuppressWarnings("unused") +@SideOnly(Side.CLIENT) public class ProxyFarmingClient extends ProxyFarming { @Override public void initializeModels() { - Proxies.render.registerBlockModel(new BlockModelEntry(new ModelResourceLocation("forestry:ffarm"), + ModelManager.getInstance().registerCustomBlockModel(new BlockModelEntry(new ModelResourceLocation("forestry:ffarm"), new ModelResourceLocation("forestry:ffarm", "inventory"), new ModelFarmBlock(), PluginFarming.getBlocks().farm)); } diff --git a/src/main/java/forestry/farming/tiles/TileFarm.java b/src/main/java/forestry/farming/tiles/TileFarm.java index 15d4f2f1a..1359fe94c 100644 --- a/src/main/java/forestry/farming/tiles/TileFarm.java +++ b/src/main/java/forestry/farming/tiles/TileFarm.java @@ -31,11 +31,15 @@ import forestry.farming.gui.GuiFarm; import forestry.farming.models.EnumFarmBlockTexture; import forestry.farming.multiblock.MultiblockLogicFarm; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public abstract class TileFarm extends MultiblockTileEntityForestry implements IFarmComponent, ISocketable, IStreamableGui, IErrorLogicSource, IOwnedTile, ITitled { private EnumFarmBlockTexture farmBlockTexture = EnumFarmBlockTexture.BRICK_STONE; @@ -140,6 +144,7 @@ public abstract class TileFarm extends MultiblockTileEntityForestry(BlockGreenhouseSprites.class); - TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks(); + TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks(); for (BlockGreenhouseSprites sprite : BlockGreenhouseSprites.VALUES) { ResourceLocation location = new ResourceLocation(Constants.MOD_ID, "blocks/greenhouse/" + sprite.spriteName); @@ -121,7 +120,7 @@ public enum BlockGreenhouseType { if (world != null && pos != null) { tile = world.getTileEntity(pos); } - TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks(); + TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks(); switch (type) { case PLAIN: return map.getAtlasSprite("minecraft:blocks/brick"); @@ -187,6 +186,7 @@ public enum BlockGreenhouseType { } } + @SideOnly(Side.CLIENT) public static EnumMap getSprites() { return sprites; } diff --git a/src/main/java/forestry/greenhouse/entities/SprinklerWater.java b/src/main/java/forestry/greenhouse/entities/SprinklerWater.java index 0f7de676a..b7fbd477e 100644 --- a/src/main/java/forestry/greenhouse/entities/SprinklerWater.java +++ b/src/main/java/forestry/greenhouse/entities/SprinklerWater.java @@ -3,6 +3,7 @@ package forestry.greenhouse.entities; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.Particle; import net.minecraft.client.renderer.VertexBuffer; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.Vec3d; @@ -39,7 +40,8 @@ public abstract class SprinklerWater extends Particle { float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * f0 - interpPosX); float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * f0 - interpPosY); float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * f0 - interpPosZ); - Minecraft.getMinecraft().renderEngine.bindTexture(FluidRegistry.WATER.getStill()); + TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); + textureManager.bindTexture(FluidRegistry.WATER.getStill()); int i = this.getBrightnessForRender(partialTicks); int j = i >> 16 & 65535; int k = i & 65535; diff --git a/src/main/java/forestry/greenhouse/gui/GuiGreenhouse.java b/src/main/java/forestry/greenhouse/gui/GuiGreenhouse.java index d5c8dd9de..02b366025 100644 --- a/src/main/java/forestry/greenhouse/gui/GuiGreenhouse.java +++ b/src/main/java/forestry/greenhouse/gui/GuiGreenhouse.java @@ -24,9 +24,9 @@ import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.ledgers.Ledger; import forestry.core.gui.widgets.TankWidget; import forestry.core.network.packets.PacketUpdateClimateControl; -import forestry.core.proxy.Proxies; import forestry.core.render.ColourProperties; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.Translator; import forestry.greenhouse.multiblock.IGreenhouseControllerInternal; import forestry.greenhouse.tiles.TileGreenhouse; @@ -128,7 +128,7 @@ public class GuiGreenhouse extends GuiForestryTitled { float hum = parseField(humidityField); setClimate(provider, temp, hum); } - Proxies.net.sendToServer(new PacketUpdateClimateControl(provider)); + NetworkUtil.sendToServer(new PacketUpdateClimateControl(provider)); } } @@ -207,7 +207,7 @@ public class GuiGreenhouse extends GuiForestryTitled { drawBackground(x, y); // Draw icon - drawSprite(TextureManager.getInstance().getDefault("misc/energy"), x + 3, y + 4); + drawSprite(TextureManagerForestry.getInstance().getDefault("misc/energy"), x + 3, y + 4); if (!isFullyOpened()) { return; diff --git a/src/main/java/forestry/greenhouse/gui/WidgetCamouflageTab.java b/src/main/java/forestry/greenhouse/gui/WidgetCamouflageTab.java index 774b734e3..4fb11a184 100644 --- a/src/main/java/forestry/greenhouse/gui/WidgetCamouflageTab.java +++ b/src/main/java/forestry/greenhouse/gui/WidgetCamouflageTab.java @@ -9,8 +9,9 @@ import forestry.core.gui.tooltips.ToolTip; import forestry.core.gui.widgets.Widget; import forestry.core.gui.widgets.WidgetCamouflageSlot; import forestry.core.gui.widgets.WidgetManager; -import forestry.core.proxy.Proxies; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderItem; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -52,14 +53,16 @@ public class WidgetCamouflageTab extends Widget { @Override public void draw(int startX, int startY) { - Proxies.render.bindTexture(manager.gui.textureFile); + Minecraft minecraft = Minecraft.getMinecraft(); + TextureManager textureManager = minecraft.getTextureManager(); + textureManager.bindTexture(manager.gui.textureFile); manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, 192, 0, 48, 25); if (handlerSlot != null) { manager.gui.drawTexturedModalRect(startX + xPos + 44, startY + yPos, 192, 25, 24, 25); } if (!typeStack.isEmpty()) { - Proxies.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - RenderItem renderItem = Proxies.common.getClientInstance().getRenderItem(); + textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + RenderItem renderItem = minecraft.getRenderItem(); renderItem.renderItemIntoGUI(typeStack, startX + xPos + 6, startY + yPos + 6); } greenhouseSlot.draw(startX, startY); diff --git a/src/main/java/forestry/greenhouse/gui/WidgetClimatePillar.java b/src/main/java/forestry/greenhouse/gui/WidgetClimatePillar.java index 49404cacf..2a50a8ba3 100644 --- a/src/main/java/forestry/greenhouse/gui/WidgetClimatePillar.java +++ b/src/main/java/forestry/greenhouse/gui/WidgetClimatePillar.java @@ -8,10 +8,11 @@ import forestry.api.genetics.AlleleManager; import forestry.core.gui.tooltips.ToolTip; import forestry.core.gui.widgets.Widget; import forestry.core.gui.widgets.WidgetManager; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -49,7 +50,8 @@ public class WidgetClimatePillar extends Widget { @Override public void draw(int startX, int startY) { - Proxies.render.bindTexture(manager.gui.textureFile); + TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); + textureManager.bindTexture(manager.gui.textureFile); manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, 216, 25, width, height); for(ClimateButton button : buttons){ button.draw(startX, startY); @@ -126,7 +128,7 @@ public class WidgetClimatePillar extends Widget { protected void drawSprite(TextureAtlasSprite sprite, int x, int y) { GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0F); - Proxies.render.bindTexture(TextureManager.getInstance().getGuiTextureMap()); + TextureManagerForestry.getInstance().bindGuiTextureMap(); manager.gui.drawTexturedModalRect(x, y, sprite, 16, 16); } } diff --git a/src/main/java/forestry/greenhouse/models/ModelGreenhouse.java b/src/main/java/forestry/greenhouse/models/ModelGreenhouse.java index 9bb8a312f..62e5d1350 100644 --- a/src/main/java/forestry/greenhouse/models/ModelGreenhouse.java +++ b/src/main/java/forestry/greenhouse/models/ModelGreenhouse.java @@ -33,9 +33,12 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.property.IExtendedBlockState; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.tuple.Pair; // DO NOT CACHE THIS. PLEASE. I BEG YOU. NOT IN THE CURRENT STATE. +@SideOnly(Side.CLIENT) public class ModelGreenhouse extends ModelBlockDefault { public static class Key { @Nullable diff --git a/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java b/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java index fd609fcae..11a277e5f 100644 --- a/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java +++ b/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java @@ -52,10 +52,10 @@ import forestry.core.multiblock.RectangularMultiblockControllerBase; import forestry.core.network.PacketBufferForestry; import forestry.core.network.packets.CamouflageSelectionType; import forestry.core.network.packets.PacketCamouflageSelectServer; -import forestry.core.proxy.Proxies; import forestry.core.tiles.ILiquidTankTile; import forestry.core.utils.CamouflageUtil; import forestry.core.utils.ItemStackUtil; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.Translator; import forestry.energy.EnergyManager; import forestry.greenhouse.inventory.InventoryGreenhouse; @@ -260,7 +260,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im } } } - Proxies.net.sendToServer(new PacketCamouflageSelectServer(this, type, CamouflageSelectionType.MULTIBLOCK)); + NetworkUtil.sendToServer(new PacketCamouflageSelectServer(this, type, CamouflageSelectionType.MULTIBLOCK)); } return true; } diff --git a/src/main/java/forestry/greenhouse/proxy/ProxyGreenhouseClient.java b/src/main/java/forestry/greenhouse/proxy/ProxyGreenhouseClient.java index 7f43deada..960e89910 100644 --- a/src/main/java/forestry/greenhouse/proxy/ProxyGreenhouseClient.java +++ b/src/main/java/forestry/greenhouse/proxy/ProxyGreenhouseClient.java @@ -13,7 +13,7 @@ package forestry.greenhouse.proxy; import com.google.common.base.Preconditions; import forestry.api.core.ForestryAPI; import forestry.core.models.BlockModelEntry; -import forestry.core.proxy.Proxies; +import forestry.core.models.ModelManager; import forestry.greenhouse.PluginGreenhouse; import forestry.greenhouse.blocks.BlockGreenhouseType; import forestry.greenhouse.blocks.BlockRegistryGreenhouse; @@ -21,7 +21,11 @@ import forestry.greenhouse.models.ModelGreenhouse; import forestry.plugins.ForestryPluginUids; import net.minecraft.block.Block; import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +@SuppressWarnings("unused") +@SideOnly(Side.CLIENT) public class ProxyGreenhouseClient extends ProxyGreenhouse { @Override @@ -33,7 +37,7 @@ public class ProxyGreenhouseClient extends ProxyGreenhouse { Block greenhouseBlock = blocks.getGreenhouseBlock(greenhouseType); if (greenhouseType == BlockGreenhouseType.DOOR) { - Proxies.render.registerBlockModel(new BlockModelEntry(new ModelResourceLocation("forestry:greenhouse." + greenhouseType, "camouflage"), + ModelManager.getInstance().registerCustomBlockModel(new BlockModelEntry(new ModelResourceLocation("forestry:greenhouse." + greenhouseType, "camouflage"), null, new ModelGreenhouse(), greenhouseBlock, false)); continue; @@ -49,7 +53,7 @@ public class ProxyGreenhouseClient extends ProxyGreenhouse { ModelResourceLocation blockModelLocation = new ModelResourceLocation("forestry:greenhouse." + greenhouseType); ModelResourceLocation itemModelLocation = new ModelResourceLocation("forestry:greenhouse", "inventory"); BlockModelEntry blockModelIndex = new BlockModelEntry(blockModelLocation, itemModelLocation, new ModelGreenhouse(), greenhouseBlock); - Proxies.render.registerBlockModel(blockModelIndex); + ModelManager.getInstance().registerCustomBlockModel(blockModelIndex); } } } diff --git a/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java b/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java index 5992ed0b5..055fccfb2 100644 --- a/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java +++ b/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java @@ -27,9 +27,9 @@ import forestry.core.network.packets.CamouflageSelectionType; import forestry.core.network.packets.PacketCamouflageSelectServer; import forestry.core.owner.IOwnedTile; import forestry.core.owner.IOwnerHandler; -import forestry.core.proxy.Proxies; import forestry.core.tiles.ITitled; import forestry.core.utils.ItemStackUtil; +import forestry.core.utils.NetworkUtil; import forestry.greenhouse.blocks.BlockGreenhouse; import forestry.greenhouse.blocks.BlockGreenhouseDoor; import forestry.greenhouse.blocks.BlockGreenhouseType; @@ -37,11 +37,15 @@ import forestry.greenhouse.gui.ContainerGreenhouse; import forestry.greenhouse.gui.GuiGreenhouse; import forestry.greenhouse.multiblock.MultiblockLogicGreenhouse; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public abstract class TileGreenhouse extends MultiblockTileEntityForestry implements IGreenhouseComponent, IStreamableGui, IErrorLogicSource, IOwnedTile, ITitled, ICamouflageHandler, ICamouflagedTile { protected ItemStack camouflageBlock; @@ -98,7 +102,7 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry implements IGreenhouseComponent, IStreamableGui, IErrorLogicSource, IOwnedTile, ICamouflageHandler, ICamouflagedTile { @@ -131,7 +133,7 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase machineProperties; - BlockTypeLepidopterologyTesr(Class teClass, String name, @Nullable TileEntitySpecialRenderer renderer, @Nullable AxisAlignedBB boundingBox) { - if (boundingBox != null) { - this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0"); - } else { - this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, Constants.MOD_ID + ":blocks/" + name + ".0", false); - } + BlockTypeLepidopterologyTesr(Class teClass, String name, String renderName, AxisAlignedBB boundingBox) { + MachinePropertiesTesr machineProperties = new MachinePropertiesTesr<>(teClass, name, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0"); + Proxies.render.setRenderChest(machineProperties, renderName); + this.machineProperties = machineProperties; } @Override diff --git a/src/main/java/forestry/lepidopterology/genetics/FlutterlyzerPlugin.java b/src/main/java/forestry/lepidopterology/genetics/FlutterlyzerPlugin.java index ce1e938b1..6345832f4 100644 --- a/src/main/java/forestry/lepidopterology/genetics/FlutterlyzerPlugin.java +++ b/src/main/java/forestry/lepidopterology/genetics/FlutterlyzerPlugin.java @@ -28,10 +28,10 @@ import forestry.core.genetics.GenericRatings; import forestry.core.genetics.alleles.AlleleBoolean; import forestry.core.gui.GuiAlyzer; import forestry.core.gui.TextLayoutHelper; -import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; import forestry.core.utils.Translator; import forestry.lepidopterology.PluginLepidopterology; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -223,7 +223,7 @@ public class FlutterlyzerPlugin implements IAlyzerPlugin { int x = GuiAlyzer.COLUMN_0; for (ItemStack stack : butterfly.getGenome().getPrimary().getButterflyLoot().keySet()) { - Proxies.common.getClientInstance().getRenderItem().renderItemIntoGUI(stack, guiAlyzer.getGuiLeft() + x, guiAlyzer.getGuiTop() + textLayout.getLineY()); + Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(stack, guiAlyzer.getGuiLeft() + x, guiAlyzer.getGuiTop() + textLayout.getLineY()); x += 18; if (x > 148) { x = GuiAlyzer.COLUMN_0; @@ -239,7 +239,7 @@ public class FlutterlyzerPlugin implements IAlyzerPlugin { x = GuiAlyzer.COLUMN_0; for (ItemStack stack : butterfly.getGenome().getPrimary().getCaterpillarLoot().keySet()) { - Proxies.common.getClientInstance().getRenderItem().renderItemIntoGUI(stack, guiAlyzer.getGuiLeft() + x, guiAlyzer.getGuiTop() + textLayout.getLineY()); + Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(stack, guiAlyzer.getGuiLeft() + x, guiAlyzer.getGuiTop() + textLayout.getLineY()); x += 18; if (x > 148) { x = GuiAlyzer.COLUMN_0; diff --git a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java index c8f2e7552..52d4d79e9 100755 --- a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java +++ b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java @@ -33,10 +33,10 @@ import forestry.core.config.Config; import forestry.core.genetics.ItemGE; import forestry.core.items.IColoredItem; import forestry.core.network.packets.PacketFXSignal; -import forestry.core.proxy.Proxies; import forestry.core.utils.BlockUtil; import forestry.core.utils.EntityUtil; import forestry.core.utils.GeneticsUtil; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.Translator; import forestry.lepidopterology.PluginLepidopterology; import forestry.lepidopterology.entities.EntityButterfly; @@ -236,7 +236,7 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored if (pos != BlockPos.ORIGIN) { PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, world.getBlockState(pos)); - Proxies.net.sendNetworkPacket(packet, pos, world); + NetworkUtil.sendNetworkPacket(packet, pos, world); if (!player.capabilities.isCreativeMode) { stack.shrink(1); @@ -261,7 +261,7 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState); - Proxies.net.sendNetworkPacket(packet, pos, world); + NetworkUtil.sendNetworkPacket(packet, pos, world); if (!player.capabilities.isCreativeMode) { stack.shrink(1); diff --git a/src/main/java/forestry/lepidopterology/proxy/ProxyLepidopterologyClient.java b/src/main/java/forestry/lepidopterology/proxy/ProxyLepidopterologyClient.java index 535dc65c6..c3ffc256b 100644 --- a/src/main/java/forestry/lepidopterology/proxy/ProxyLepidopterologyClient.java +++ b/src/main/java/forestry/lepidopterology/proxy/ProxyLepidopterologyClient.java @@ -12,18 +12,24 @@ package forestry.lepidopterology.proxy; import forestry.core.models.ModelEntry; import forestry.core.models.ModelManager; -import forestry.core.proxy.Proxies; import forestry.lepidopterology.entities.EntityButterfly; import forestry.lepidopterology.render.ModelButterflyItem; import forestry.lepidopterology.render.RenderButterflyEntity; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraftforge.fml.client.registry.RenderingRegistry; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SuppressWarnings("unused") +@SideOnly(Side.CLIENT) public class ProxyLepidopterologyClient extends ProxyLepidopterology { @Override public void preInitializeRendering() { RenderingRegistry.registerEntityRenderingHandler(EntityButterfly.class, new RenderButterflyEntity.Factory()); - Proxies.render.registerModel(new ModelEntry(ModelManager.getInstance().getModelLocation("butterflyGE"), new ModelButterflyItem())); + ModelManager modelManager = ModelManager.getInstance(); + ModelResourceLocation butterflyGE = modelManager.getModelLocation("butterflyGE"); + ModelEntry modelEntry = new ModelEntry(butterflyGE, new ModelButterflyItem()); + modelManager.registerCustomModel(modelEntry); } } diff --git a/src/main/java/forestry/lepidopterology/tiles/TileCocoon.java b/src/main/java/forestry/lepidopterology/tiles/TileCocoon.java index 1705cda1b..278501f1d 100644 --- a/src/main/java/forestry/lepidopterology/tiles/TileCocoon.java +++ b/src/main/java/forestry/lepidopterology/tiles/TileCocoon.java @@ -31,10 +31,10 @@ import forestry.core.network.packets.PacketTileStream; import forestry.core.owner.IOwnedTile; import forestry.core.owner.IOwnerHandler; import forestry.core.owner.OwnerHandler; -import forestry.core.proxy.Proxies; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; import forestry.core.utils.NBTUtilForestry; +import forestry.core.utils.NetworkUtil; import forestry.greenhouse.multiblock.IGreenhouseControllerInternal; import forestry.lepidopterology.genetics.Butterfly; import forestry.lepidopterology.genetics.ButterflyDefinition; @@ -49,6 +49,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TileCocoon extends TileEntity implements IStreamable, IOwnedTile, IButterflyCocoon { private final OwnerHandler ownerHandler = new OwnerHandler(); @@ -161,6 +163,7 @@ public class TileCocoon extends TileEntity implements IStreamable, IOwnedTile, I } @Override + @SideOnly(Side.CLIENT) public void handleUpdateTag(NBTTagCompound tag) { int oldAge = age; super.handleUpdateTag(tag); @@ -171,6 +174,7 @@ public class TileCocoon extends TileEntity implements IStreamable, IOwnedTile, I } @Override + @SideOnly(Side.CLIENT) public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); NBTTagCompound nbt = pkt.getNbtCompound(); @@ -270,7 +274,7 @@ public class TileCocoon extends TileEntity implements IStreamable, IOwnedTile, I } private void sendNetworkUpdate() { - Proxies.net.sendNetworkPacket(new PacketTileStream(this), pos, world); + NetworkUtil.sendNetworkPacket(new PacketTileStream(this), pos, world); } public int getAge() { diff --git a/src/main/java/forestry/mail/EventHandlerMailAlert.java b/src/main/java/forestry/mail/EventHandlerMailAlert.java index 2eea014dc..3022c3b69 100644 --- a/src/main/java/forestry/mail/EventHandlerMailAlert.java +++ b/src/main/java/forestry/mail/EventHandlerMailAlert.java @@ -12,7 +12,7 @@ package forestry.mail; import forestry.api.mail.IMailAddress; import forestry.api.mail.PostManager; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; import forestry.mail.gui.GuiMailboxInfo; import forestry.mail.network.packets.PacketPOBoxInfoResponse; import net.minecraft.client.Minecraft; @@ -21,9 +21,12 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class EventHandlerMailAlert { @SubscribeEvent + @SideOnly(Side.CLIENT) public void onRenderTick(TickEvent.RenderTickEvent event) { if (event.phase == Phase.END && Minecraft.getMinecraft().world != null && @@ -39,6 +42,6 @@ public class EventHandlerMailAlert { IMailAddress address = PostManager.postRegistry.getMailAddress(player.getGameProfile()); POBox pobox = PostRegistry.getOrCreatePOBox(player.world, address); PacketPOBoxInfoResponse packet = new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()); - Proxies.net.sendToPlayer(packet, player); + NetworkUtil.sendToPlayer(packet, player); } } diff --git a/src/main/java/forestry/mail/PostRegistry.java b/src/main/java/forestry/mail/PostRegistry.java index 3c6e0ad0a..7a9b19d95 100755 --- a/src/main/java/forestry/mail/PostRegistry.java +++ b/src/main/java/forestry/mail/PostRegistry.java @@ -25,8 +25,8 @@ import forestry.api.mail.IPostRegistry; import forestry.api.mail.IPostalCarrier; import forestry.api.mail.ITradeStation; import forestry.api.mail.PostManager; -import forestry.core.proxy.Proxies; import forestry.core.utils.Log; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.PlayerUtil; import forestry.mail.network.packets.PacketPOBoxInfoResponse; import net.minecraft.entity.player.EntityPlayer; @@ -77,7 +77,7 @@ public class PostRegistry implements IPostRegistry { EntityPlayer player = PlayerUtil.getPlayer(world, address.getPlayerProfile()); if (player != null) { - Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), player); + NetworkUtil.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), player); } } diff --git a/src/main/java/forestry/mail/PostalCarrier.java b/src/main/java/forestry/mail/PostalCarrier.java index 143225a45..0c2d2f77e 100755 --- a/src/main/java/forestry/mail/PostalCarrier.java +++ b/src/main/java/forestry/mail/PostalCarrier.java @@ -17,8 +17,8 @@ import forestry.api.mail.IPostalCarrier; import forestry.api.mail.IPostalState; import forestry.api.mail.ITradeStation; import forestry.api.mail.PostManager; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.PlayerUtil; import forestry.core.utils.Translator; import forestry.mail.network.packets.PacketPOBoxInfoResponse; @@ -53,7 +53,7 @@ public class PostalCarrier implements IPostalCarrier { @Override @SideOnly(Side.CLIENT) public TextureAtlasSprite getSprite() { - return TextureManager.getInstance().getDefault(iconID); + return TextureManagerForestry.getInstance().getDefault(iconID); } @Override @@ -86,7 +86,7 @@ public class PostalCarrier implements IPostalCarrier { } else { EntityPlayer player = PlayerUtil.getPlayer(world, recipient.getPlayerProfile()); if (player instanceof EntityPlayerMP) { - Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), player); + NetworkUtil.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), player); } } diff --git a/src/main/java/forestry/mail/gui/AddresseeSlot.java b/src/main/java/forestry/mail/gui/AddresseeSlot.java index 6e46f4a05..c98c63fa8 100644 --- a/src/main/java/forestry/mail/gui/AddresseeSlot.java +++ b/src/main/java/forestry/mail/gui/AddresseeSlot.java @@ -15,8 +15,8 @@ import forestry.api.mail.PostManager; import forestry.core.gui.tooltips.ToolTip; import forestry.core.gui.widgets.Widget; import forestry.core.gui.widgets.WidgetManager; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; +import forestry.core.render.TextureManagerForestry; +import forestry.core.utils.SoundUtil; import forestry.core.utils.Translator; import net.minecraft.client.renderer.GlStateManager; @@ -36,7 +36,7 @@ public class AddresseeSlot extends Widget { IPostalCarrier carrier = PostManager.postRegistry.getCarrier(containerLetter.getCarrierType()); if (carrier != null) { GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0F); - Proxies.render.bindTexture(TextureManager.getInstance().getGuiTextureMap()); + TextureManagerForestry.getInstance().bindGuiTextureMap(); manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, carrier.getSprite(), 32, 32); } } @@ -53,7 +53,7 @@ public class AddresseeSlot extends Widget { public void handleMouseClick(int mouseX, int mouseY, int mouseButton) { if (!containerLetter.getLetter().isProcessed()) { containerLetter.advanceCarrierType(); - Proxies.common.playButtonClick(); + SoundUtil.playButtonClick(); } } } diff --git a/src/main/java/forestry/mail/gui/ContainerCatalogue.java b/src/main/java/forestry/mail/gui/ContainerCatalogue.java index 66619bf10..b518951db 100755 --- a/src/main/java/forestry/mail/gui/ContainerCatalogue.java +++ b/src/main/java/forestry/mail/gui/ContainerCatalogue.java @@ -27,8 +27,7 @@ import forestry.api.mail.ITradeStation; import forestry.api.mail.ITradeStationInfo; import forestry.api.mail.PostManager; import forestry.core.gui.IGuiSelectable; -import forestry.core.network.packets.PacketGuiSelectRequest; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; import forestry.mail.network.packets.PacketLetterInfoResponse; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -105,47 +104,24 @@ public class ContainerCatalogue extends Container implements IGuiSelectable, ILe } public void nextPage() { - if (player.world.isRemote) { - sendSelection(true); - return; + if (!stations.isEmpty()) { + stationIndex = (stationIndex + 1) % stations.size(); + updateTradeInfo(); } - - if (stations.isEmpty()) { - return; - } - stationIndex = (stationIndex + 1) % stations.size(); - updateTradeInfo(); } public void previousPage() { - if (player.world.isRemote) { - sendSelection(false); - return; + if (!stations.isEmpty()) { + stationIndex = (stationIndex - 1 + stations.size()) % stations.size(); + updateTradeInfo(); } - - if (stations.isEmpty()) { - return; - } - stationIndex = (stationIndex - 1 + stations.size()) % stations.size(); - updateTradeInfo(); } public void cycleFilter() { - if (player.world.isRemote) { - Proxies.net.sendToServer(new PacketGuiSelectRequest(2, 0)); - return; - } - currentFilter = (currentFilter + 1) % FILTERS.size(); - rebuildStationsList(); } - private static void sendSelection(boolean advance) { - int value = advance ? 0 : 1; - Proxies.net.sendToServer(new PacketGuiSelectRequest(value, 0)); - } - /* Managing Trade info */ private void updateTradeInfo() { // Updating is done by the server. @@ -187,7 +163,7 @@ public class ContainerCatalogue extends Container implements IGuiSelectable, ILe crafter.sendProgressBarUpdate(this, 2, currentFilter); } - Proxies.net.sendToPlayer(new PacketLetterInfoResponse(EnumAddressee.TRADER, currentTrade, null), player); + NetworkUtil.sendToPlayer(new PacketLetterInfoResponse(EnumAddressee.TRADER, currentTrade, null), player); needsSync = false; } } diff --git a/src/main/java/forestry/mail/gui/ContainerLetter.java b/src/main/java/forestry/mail/gui/ContainerLetter.java index ca0d6e8d0..bacff9709 100755 --- a/src/main/java/forestry/mail/gui/ContainerLetter.java +++ b/src/main/java/forestry/mail/gui/ContainerLetter.java @@ -23,8 +23,8 @@ import forestry.api.mail.ITradeStationInfo; import forestry.api.mail.PostManager; import forestry.core.gui.ContainerItemInventory; import forestry.core.gui.slots.SlotFiltered; -import forestry.core.proxy.Proxies; import forestry.core.utils.Log; +import forestry.core.utils.NetworkUtil; import forestry.mail.Letter; import forestry.mail.inventory.ItemInventoryLetter; import forestry.mail.network.packets.PacketLetterInfoResponse; @@ -32,6 +32,8 @@ import forestry.mail.network.packets.PacketLetterTextSet; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ContainerLetter extends ContainerItemInventory implements ILetterInfoReceiver { @@ -133,7 +135,7 @@ public class ContainerLetter extends ContainerItemInventory } // Update info on client - Proxies.net.sendToPlayer(new PacketLetterInfoResponse(type, tradeInfo, recipient), player); + NetworkUtil.sendToPlayer(new PacketLetterInfoResponse(type, tradeInfo, recipient), player); } @Nullable @@ -163,10 +165,11 @@ public class ContainerLetter extends ContainerItemInventory return getLetter().getText(); } + @SideOnly(Side.CLIENT) public void setText(String text) { getLetter().setText(text); - Proxies.net.sendToServer(new PacketLetterTextSet(text)); + NetworkUtil.sendToServer(new PacketLetterTextSet(text)); } public void handleSetText(String text) { diff --git a/src/main/java/forestry/mail/gui/ContainerMailbox.java b/src/main/java/forestry/mail/gui/ContainerMailbox.java index 4f114bb5d..cc9348274 100755 --- a/src/main/java/forestry/mail/gui/ContainerMailbox.java +++ b/src/main/java/forestry/mail/gui/ContainerMailbox.java @@ -14,7 +14,7 @@ import javax.annotation.Nullable; import forestry.core.gui.ContainerTile; import forestry.core.gui.slots.SlotOutput; -import forestry.core.proxy.Proxies; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.SlotUtil; import forestry.mail.POBox; import forestry.mail.POBoxInfo; @@ -57,7 +57,7 @@ public class ContainerMailbox extends ContainerTile { if (SlotUtil.isSlotInRange(slotId, SLOT_LETTERS, SLOT_LETTERS_COUNT)) { if (!player.world.isRemote && mailInventory != null) { POBoxInfo info = mailInventory.getPOBoxInfo(); - Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(info), player); + NetworkUtil.sendToPlayer(new PacketPOBoxInfoResponse(info), player); } } diff --git a/src/main/java/forestry/mail/gui/GuiCatalogue.java b/src/main/java/forestry/mail/gui/GuiCatalogue.java index 41e736f47..591bfdc68 100755 --- a/src/main/java/forestry/mail/gui/GuiCatalogue.java +++ b/src/main/java/forestry/mail/gui/GuiCatalogue.java @@ -19,7 +19,9 @@ import forestry.core.config.SessionVars; import forestry.core.gui.GuiForestry; import forestry.core.gui.widgets.ItemStackWidget; import forestry.core.gui.widgets.Widget; +import forestry.core.network.packets.PacketGuiSelectRequest; import forestry.core.render.ColourProperties; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.Translator; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; @@ -134,14 +136,14 @@ public class GuiCatalogue extends GuiForestry { case 0: mc.player.closeScreen(); break; - case 2: - container.nextPage(); + case 2: // next page + NetworkUtil.sendToServer(new PacketGuiSelectRequest(0, 0)); break; - case 3: - container.previousPage(); + case 3: // previous page + NetworkUtil.sendToServer(new PacketGuiSelectRequest(1, 0)); break; - case 4: - container.cycleFilter(); + case 4: // cycle filter + NetworkUtil.sendToServer(new PacketGuiSelectRequest(2, 0)); break; case 5: ITradeStationInfo info = container.getTradeInfo(); diff --git a/src/main/java/forestry/mail/gui/GuiLetter.java b/src/main/java/forestry/mail/gui/GuiLetter.java index 6cd9d4546..fcde59f3f 100755 --- a/src/main/java/forestry/mail/gui/GuiLetter.java +++ b/src/main/java/forestry/mail/gui/GuiLetter.java @@ -21,13 +21,16 @@ import forestry.core.gui.GuiForestry; import forestry.core.gui.GuiTextBox; import forestry.core.gui.widgets.ItemStackWidget; import forestry.core.gui.widgets.Widget; -import forestry.core.proxy.Proxies; import forestry.core.render.ColourProperties; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.Translator; import forestry.mail.inventory.ItemInventoryLetter; import forestry.mail.network.packets.PacketLetterInfoRequest; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.StringUtils; import org.lwjgl.input.Keyboard; @@ -93,7 +96,7 @@ public class GuiLetter extends GuiForestry { if (this.text.isFocused()) { if (eventKey == Keyboard.KEY_RETURN) { - if (Proxies.common.isShiftDown()) { + if (GuiScreen.isShiftKeyDown()) { text.setText(text.getText() + "\n"); } else { this.text.setFocused(false); @@ -235,9 +238,10 @@ public class GuiLetter extends GuiForestry { } PacketLetterInfoRequest packet = new PacketLetterInfoRequest(recipientName, type); - Proxies.net.sendToServer(packet); + NetworkUtil.sendToServer(packet); } + @SideOnly(Side.CLIENT) private void setText() { if (this.isProcessedLetter) { return; diff --git a/src/main/java/forestry/mail/gui/GuiMailboxInfo.java b/src/main/java/forestry/mail/gui/GuiMailboxInfo.java index 7e71259a2..e111af8a7 100755 --- a/src/main/java/forestry/mail/gui/GuiMailboxInfo.java +++ b/src/main/java/forestry/mail/gui/GuiMailboxInfo.java @@ -14,19 +14,20 @@ import javax.annotation.Nullable; import forestry.core.config.Config; import forestry.core.config.Constants; -import forestry.core.proxy.Proxies; import forestry.core.render.ForestryResource; +import forestry.core.utils.SoundUtil; import forestry.mail.POBoxInfo; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundCategory; -import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class GuiMailboxInfo extends Gui { @@ -49,7 +50,7 @@ public class GuiMailboxInfo extends Gui { private final ResourceLocation textureAlert = new ForestryResource(Constants.TEXTURE_PATH_GUI + "/mailalert.png"); private GuiMailboxInfo() { - fontRendererObj = Proxies.common.getClientInstance().fontRendererObj; + fontRendererObj = Minecraft.getMinecraft().fontRendererObj; } public void render() { @@ -71,7 +72,8 @@ public class GuiMailboxInfo extends Gui { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.disableLighting(); - Proxies.render.bindTexture(textureAlert); + TextureManager textureManager = minecraft.getTextureManager(); + textureManager.bindTexture(textureAlert); this.drawTexturedModalRect(x, y, 0, 0, WIDTH, HEIGHT); @@ -87,7 +89,8 @@ public class GuiMailboxInfo extends Gui { return poInfo != null; } - public void setPOBoxInfo(POBoxInfo info) { + @SideOnly(Side.CLIENT) + public void setPOBoxInfo(EntityPlayer player, POBoxInfo info) { boolean playJingle = false; if (info.hasMail()) { @@ -99,9 +102,7 @@ public class GuiMailboxInfo extends Gui { } if (playJingle) { - EntityPlayerSP thePlayer = Proxies.common.getClientInstance().player; - World world = Proxies.common.getRenderWorld(); - world.playSound(null, thePlayer.posX, thePlayer.posY, thePlayer.posZ, SoundEvents.ENTITY_PLAYER_LEVELUP, SoundCategory.PLAYERS, 1.0f, 1.0F); + SoundUtil.playSoundEvent(SoundEvents.ENTITY_PLAYER_LEVELUP); } this.poInfo = info; diff --git a/src/main/java/forestry/mail/gui/GuiTradeName.java b/src/main/java/forestry/mail/gui/GuiTradeName.java index 9231b58c8..cee53b9a9 100755 --- a/src/main/java/forestry/mail/gui/GuiTradeName.java +++ b/src/main/java/forestry/mail/gui/GuiTradeName.java @@ -14,8 +14,8 @@ import java.io.IOException; import forestry.core.config.Constants; import forestry.core.gui.GuiForestry; -import forestry.core.proxy.Proxies; import forestry.core.render.ColourProperties; +import forestry.core.utils.NetworkUtil; import forestry.core.utils.Translator; import forestry.mail.network.packets.PacketTraderAddressRequest; import forestry.mail.tiles.TileTrader; @@ -89,7 +89,7 @@ public class GuiTradeName extends GuiForestry { String address = addressNameField.getText(); if (StringUtils.isNotBlank(address)) { PacketTraderAddressRequest packet = new PacketTraderAddressRequest(tile, address); - Proxies.net.sendToServer(packet); + NetworkUtil.sendToServer(packet); } } diff --git a/src/main/java/forestry/mail/items/ItemCatalogue.java b/src/main/java/forestry/mail/items/ItemCatalogue.java index 9749885b5..4c358c8c7 100644 --- a/src/main/java/forestry/mail/items/ItemCatalogue.java +++ b/src/main/java/forestry/mail/items/ItemCatalogue.java @@ -13,17 +13,22 @@ package forestry.mail.items; import forestry.core.items.ItemWithGui; import forestry.mail.gui.ContainerCatalogue; import forestry.mail.gui.GuiCatalogue; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemCatalogue extends ItemWithGui { @Override - public Object getGui(EntityPlayer player, ItemStack heldItem, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, ItemStack heldItem, int data) { return new GuiCatalogue(player); } @Override - public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) { + public Container getContainer(EntityPlayer player, ItemStack heldItem, int data) { return new ContainerCatalogue(player); } } diff --git a/src/main/java/forestry/mail/items/ItemLetter.java b/src/main/java/forestry/mail/items/ItemLetter.java index 06437493e..2e6797732 100755 --- a/src/main/java/forestry/mail/items/ItemLetter.java +++ b/src/main/java/forestry/mail/items/ItemLetter.java @@ -21,8 +21,10 @@ import forestry.mail.LetterProperties; import forestry.mail.gui.ContainerLetter; import forestry.mail.gui.GuiLetter; import forestry.mail.inventory.ItemInventoryLetter; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -64,6 +66,7 @@ public class ItemLetter extends ItemWithGui { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { super.addInformation(itemstack, player, list, flag); @@ -87,12 +90,13 @@ public class ItemLetter extends ItemWithGui { } @Override - public Object getGui(EntityPlayer player, ItemStack heldItem, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, ItemStack heldItem, int data) { return new GuiLetter(player, new ItemInventoryLetter(player, heldItem)); } @Override - public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) { + public Container getContainer(EntityPlayer player, ItemStack heldItem, int data) { return new ContainerLetter(player, new ItemInventoryLetter(player, heldItem)); } } diff --git a/src/main/java/forestry/mail/network/PacketRegistryMail.java b/src/main/java/forestry/mail/network/PacketRegistryMail.java index eaab4d585..688702eed 100644 --- a/src/main/java/forestry/mail/network/PacketRegistryMail.java +++ b/src/main/java/forestry/mail/network/PacketRegistryMail.java @@ -19,16 +19,22 @@ import forestry.mail.network.packets.PacketLetterTextSet; import forestry.mail.network.packets.PacketPOBoxInfoResponse; import forestry.mail.network.packets.PacketTraderAddressRequest; import forestry.mail.network.packets.PacketTraderAddressResponse; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketRegistryMail implements IPacketRegistry { @Override - public void registerPackets() { - PacketIdClient.LETTER_INFO_RESPONSE.setPacketHandler(new PacketLetterInfoResponse.Handler()); - PacketIdClient.TRADING_ADDRESS_RESPONSE.setPacketHandler(new PacketTraderAddressResponse.Handler()); - PacketIdClient.POBOX_INFO_RESPONSE.setPacketHandler(new PacketPOBoxInfoResponse.Handler()); - + public void registerPacketsServer() { PacketIdServer.LETTER_INFO_REQUEST.setPacketHandler(new PacketLetterInfoRequest.Handler()); PacketIdServer.TRADING_ADDRESS_REQUEST.setPacketHandler(new PacketTraderAddressRequest.Handler()); PacketIdServer.LETTER_TEXT_SET.setPacketHandler(new PacketLetterTextSet.Handler()); } + + @Override + @SideOnly(Side.CLIENT) + public void registerPacketsClient() { + PacketIdClient.LETTER_INFO_RESPONSE.setPacketHandler(new PacketLetterInfoResponse.Handler()); + PacketIdClient.TRADING_ADDRESS_RESPONSE.setPacketHandler(new PacketTraderAddressResponse.Handler()); + PacketIdClient.POBOX_INFO_RESPONSE.setPacketHandler(new PacketPOBoxInfoResponse.Handler()); + } } diff --git a/src/main/java/forestry/mail/network/packets/PacketLetterInfoResponse.java b/src/main/java/forestry/mail/network/packets/PacketLetterInfoResponse.java index 07512fea9..ca6075cce 100644 --- a/src/main/java/forestry/mail/network/packets/PacketLetterInfoResponse.java +++ b/src/main/java/forestry/mail/network/packets/PacketLetterInfoResponse.java @@ -32,6 +32,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; // TODO: split this into two different packets public class PacketLetterInfoResponse extends ForestryPacket implements IForestryPacketClient { @@ -90,6 +92,7 @@ public class PacketLetterInfoResponse extends ForestryPacket implements IForestr } } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { diff --git a/src/main/java/forestry/mail/network/packets/PacketPOBoxInfoResponse.java b/src/main/java/forestry/mail/network/packets/PacketPOBoxInfoResponse.java index 8c0d7fdbc..d02e275cd 100644 --- a/src/main/java/forestry/mail/network/packets/PacketPOBoxInfoResponse.java +++ b/src/main/java/forestry/mail/network/packets/PacketPOBoxInfoResponse.java @@ -20,6 +20,8 @@ import forestry.core.network.PacketIdClient; import forestry.mail.POBoxInfo; import forestry.mail.gui.GuiMailboxInfo; import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketPOBoxInfoResponse extends ForestryPacket implements IForestryPacketClient { public final POBoxInfo poboxInfo; @@ -39,12 +41,13 @@ public class PacketPOBoxInfoResponse extends ForestryPacket implements IForestry data.writeInt(poboxInfo.tradeLetters); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { POBoxInfo poboxInfo = new POBoxInfo(data.readInt(), data.readInt()); - GuiMailboxInfo.instance.setPOBoxInfo(poboxInfo); + GuiMailboxInfo.instance.setPOBoxInfo(player, poboxInfo); } } } diff --git a/src/main/java/forestry/mail/network/packets/PacketTraderAddressResponse.java b/src/main/java/forestry/mail/network/packets/PacketTraderAddressResponse.java index 509e34d3a..a88ab1878 100644 --- a/src/main/java/forestry/mail/network/packets/PacketTraderAddressResponse.java +++ b/src/main/java/forestry/mail/network/packets/PacketTraderAddressResponse.java @@ -21,6 +21,8 @@ import forestry.mail.tiles.TileTrader; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class PacketTraderAddressResponse extends ForestryPacket implements IForestryPacketClient { private final BlockPos pos; @@ -42,6 +44,7 @@ public class PacketTraderAddressResponse extends ForestryPacket implements IFore data.writeString(addressName); } + @SideOnly(Side.CLIENT) public static class Handler implements IForestryPacketHandlerClient { @Override diff --git a/src/main/java/forestry/mail/tiles/TileMailbox.java b/src/main/java/forestry/mail/tiles/TileMailbox.java index 69d485f78..7fcb7048f 100644 --- a/src/main/java/forestry/mail/tiles/TileMailbox.java +++ b/src/main/java/forestry/mail/tiles/TileMailbox.java @@ -22,11 +22,15 @@ import forestry.mail.POBox; import forestry.mail.PostRegistry; import forestry.mail.gui.ContainerMailbox; import forestry.mail.gui.GuiMailbox; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TileMailbox extends TileBase { @@ -78,12 +82,13 @@ public class TileMailbox extends TileBase { } @Override - public Object getGui(EntityPlayer player, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, int data) { return new GuiMailbox(player.inventory, this); } @Override - public Object getContainer(EntityPlayer player, int data) { + public Container getContainer(EntityPlayer player, int data) { return new ContainerMailbox(player.inventory, this); } } diff --git a/src/main/java/forestry/mail/tiles/TileStampCollector.java b/src/main/java/forestry/mail/tiles/TileStampCollector.java index 265213166..923f05723 100644 --- a/src/main/java/forestry/mail/tiles/TileStampCollector.java +++ b/src/main/java/forestry/mail/tiles/TileStampCollector.java @@ -18,9 +18,13 @@ import forestry.core.utils.InventoryUtil; import forestry.mail.gui.ContainerStampCollector; import forestry.mail.gui.GuiStampCollector; import forestry.mail.inventory.InventoryStampCollector; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TileStampCollector extends TileBase implements IInventory { public TileStampCollector() { @@ -54,12 +58,13 @@ public class TileStampCollector extends TileBase implements IInventory { } @Override - public Object getGui(EntityPlayer player, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, int data) { return new GuiStampCollector(player.inventory, this); } @Override - public Object getContainer(EntityPlayer player, int data) { + public Container getContainer(EntityPlayer player, int data) { return new ContainerStampCollector(player.inventory, this); } } diff --git a/src/main/java/forestry/mail/tiles/TileTrader.java b/src/main/java/forestry/mail/tiles/TileTrader.java index e935798df..524c1b2d0 100644 --- a/src/main/java/forestry/mail/tiles/TileTrader.java +++ b/src/main/java/forestry/mail/tiles/TileTrader.java @@ -24,9 +24,9 @@ import forestry.core.network.PacketBufferForestry; import forestry.core.owner.IOwnedTile; import forestry.core.owner.IOwnerHandler; import forestry.core.owner.OwnerHandler; -import forestry.core.proxy.Proxies; import forestry.core.tiles.TileBase; import forestry.core.utils.ItemStackUtil; +import forestry.core.utils.NetworkUtil; import forestry.mail.MailAddress; import forestry.mail.TradeStation; import forestry.mail.gui.ContainerTradeName; @@ -35,11 +35,15 @@ import forestry.mail.gui.GuiTradeName; import forestry.mail.gui.GuiTrader; import forestry.mail.inventory.InventoryTradeStation; import forestry.mail.network.packets.PacketTraderAddressResponse; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; +import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class TileTrader extends TileBase implements IOwnedTile { private final OwnerHandler ownerHandler = new OwnerHandler(); @@ -102,6 +106,7 @@ public class TileTrader extends TileBase implements IOwnedTile { } @Override + @SideOnly(Side.CLIENT) public void readData(PacketBufferForestry data) throws IOException { super.readData(data); ownerHandler.readData(data); @@ -256,10 +261,11 @@ public class TileTrader extends TileBase implements IOwnedTile { String newAddressName = newAddress.getName(); if (newAddressName.equals(addressName)) { PacketTraderAddressResponse packetResponse = new PacketTraderAddressResponse(this, addressName); - Proxies.net.sendNetworkPacket(packetResponse, pos, world); + NetworkUtil.sendNetworkPacket(packetResponse, pos, world); } } + @SideOnly(Side.CLIENT) public void handleSetAddressResponse(String addressName) { IMailAddress address = PostManager.postRegistry.getMailAddress(addressName); setAddress(address); @@ -317,7 +323,8 @@ public class TileTrader extends TileBase implements IOwnedTile { // } @Override - public Object getGui(EntityPlayer player, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, int data) { if (data == 0) { return new GuiTrader(player.inventory, this); } else { @@ -326,7 +333,7 @@ public class TileTrader extends TileBase implements IOwnedTile { } @Override - public Object getContainer(EntityPlayer player, int data) { + public Container getContainer(EntityPlayer player, int data) { if (data == 0) { return new ContainerTrader(player.inventory, this); } else { diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index 3764ba254..e8cf5f6f9 100644 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -45,6 +45,7 @@ import net.minecraftforge.fml.common.discovery.ASMDataTable; import net.minecraftforge.fml.common.event.FMLInterModComms; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.fml.relauncher.Side; public class PluginManager { @@ -79,12 +80,16 @@ public class PluginManager { return ImmutableSet.copyOf(loadedPlugins); } - private static void registerHandlers(IForestryPlugin plugin) { + private static void registerHandlers(IForestryPlugin plugin, Side side) { Log.debug("Registering Handlers for Plugin: {}", plugin); IPacketRegistry packetRegistry = plugin.getPacketRegistry(); if (packetRegistry != null) { - packetRegistry.registerPackets(); + if (side == Side.SERVER) { + packetRegistry.registerPacketsServer(); + } else { + packetRegistry.registerPacketsClient(); + } } IPickupHandler pickupHandler = plugin.getPickupHandler(); @@ -218,11 +223,11 @@ public class PluginManager { } } - public static void runPreInit() { + public static void runPreInit(Side side) { stage = Stage.PRE_INIT; for (IForestryPlugin plugin : loadedPlugins) { Log.debug("Pre-Init Start: {}", plugin); - registerHandlers(plugin); + registerHandlers(plugin, side); plugin.preInit(); if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.BUILDCRAFT_STATEMENTS)) { plugin.registerTriggers(); diff --git a/src/main/java/forestry/storage/items/ItemBackpack.java b/src/main/java/forestry/storage/items/ItemBackpack.java index a3b8ef488..ddaed0b87 100755 --- a/src/main/java/forestry/storage/items/ItemBackpack.java +++ b/src/main/java/forestry/storage/items/ItemBackpack.java @@ -34,10 +34,12 @@ import forestry.storage.gui.ContainerBackpack; import forestry.storage.gui.GuiBackpack; import forestry.storage.gui.GuiBackpackT2; import forestry.storage.inventory.ItemInventoryBackpack; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -192,6 +194,7 @@ public class ItemBackpack extends ItemWithGui implements IColoredItem { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { super.addInformation(itemstack, player, list, flag); @@ -293,10 +296,10 @@ public class ItemBackpack extends ItemWithGui implements IColoredItem { return oldItem != newItem || getMode(oldStack) != getMode(newStack); } - @SuppressWarnings("incomplete-switch") @Override @Nullable - public Object getGui(EntityPlayer player, ItemStack heldItem, int data) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, ItemStack heldItem, int data) { if (data > EnumBackpackType.values().length) { return null; } @@ -306,14 +309,14 @@ public class ItemBackpack extends ItemWithGui implements IColoredItem { return new GuiBackpack(new ContainerBackpack(player, ContainerBackpack.Size.DEFAULT, heldItem)); case WOVEN: return new GuiBackpackT2(new ContainerBackpack(player, ContainerBackpack.Size.T2, heldItem)); + default: + return null; } - return null; } - @SuppressWarnings("incomplete-switch") @Override @Nullable - public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) { + public Container getContainer(EntityPlayer player, ItemStack heldItem, int data) { if (data > EnumBackpackType.values().length) { return null; } @@ -323,7 +326,8 @@ public class ItemBackpack extends ItemWithGui implements IColoredItem { return new ContainerBackpack(player, ContainerBackpack.Size.DEFAULT, heldItem); case WOVEN: return new ContainerBackpack(player, ContainerBackpack.Size.T2, heldItem); + default: + return null; } - return null; } } diff --git a/src/main/java/forestry/storage/items/ItemBackpackNaturalist.java b/src/main/java/forestry/storage/items/ItemBackpackNaturalist.java index ad1bd813d..40810c6b6 100644 --- a/src/main/java/forestry/storage/items/ItemBackpackNaturalist.java +++ b/src/main/java/forestry/storage/items/ItemBackpackNaturalist.java @@ -18,8 +18,12 @@ import forestry.core.gui.GuiHandler; import forestry.core.gui.GuiNaturalistInventory; import forestry.storage.gui.ContainerNaturalistBackpack; import forestry.storage.inventory.ItemInventoryBackpackPaged; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class ItemBackpackNaturalist extends ItemBackpack { private final ISpeciesRoot speciesRoot; @@ -35,14 +39,15 @@ public class ItemBackpackNaturalist extends ItemBackpack { } @Override - public Object getGui(EntityPlayer player, ItemStack heldItem, int page) { + @SideOnly(Side.CLIENT) + public GuiContainer getGui(EntityPlayer player, ItemStack heldItem, int page) { ItemInventoryBackpackPaged inventory = new ItemInventoryBackpackPaged(player, Constants.SLOTS_BACKPACK_APIARIST, heldItem, this); ContainerNaturalistBackpack container = new ContainerNaturalistBackpack(player, inventory, page); return new GuiNaturalistInventory(speciesRoot, player, container, page, 5); } @Override - public Object getContainer(EntityPlayer player, ItemStack heldItem, int page) { + public Container getContainer(EntityPlayer player, ItemStack heldItem, int page) { ItemInventoryBackpackPaged inventory = new ItemInventoryBackpackPaged(player, Constants.SLOTS_BACKPACK_APIARIST, heldItem, this); return new ContainerNaturalistBackpack(player, inventory, page); } diff --git a/src/main/java/forestry/storage/proxy/ProxyStorageClient.java b/src/main/java/forestry/storage/proxy/ProxyStorageClient.java index 8058ce33b..5c7086e81 100644 --- a/src/main/java/forestry/storage/proxy/ProxyStorageClient.java +++ b/src/main/java/forestry/storage/proxy/ProxyStorageClient.java @@ -2,16 +2,20 @@ package forestry.storage.proxy; import forestry.core.models.ModelCrate; import forestry.core.models.ModelEntry; -import forestry.core.proxy.Proxies; +import forestry.core.models.ModelManager; import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SuppressWarnings("unused") +@SideOnly(Side.CLIENT) public class ProxyStorageClient extends ProxyStorage { @Override public void registerCrateModel() { ModelResourceLocation modelLocation = new ModelResourceLocation("forestry:crate-filled", "crate-filled"); - Proxies.render.registerModel(new ModelEntry(modelLocation, new ModelCrate())); + ModelEntry modelEntry = new ModelEntry(modelLocation, new ModelCrate()); + ModelManager.getInstance().registerCustomModel(modelEntry); } }