Fix #1244 Opening Greenhouse GUI causes a drop in fps, from 90fps to 6fps(in my case)

This commit is contained in:
Nedelosk committed 2016-06-03 23:11:52 +02:00
1 parent 6adcde4a75
commit 4dd95625e1
3 files changed
+60 -35

No files matched your search

@@ -19,6 +19,7 @@ import java.util.List;
import java.util.Set;
import java.util.Stack;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@@ -64,6 +65,7 @@ import forestry.core.network.DataOutputStreamForestry;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.ILiquidTankTile;
import forestry.core.utils.CamouflageUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.Log;
import forestry.core.utils.Translator;
import forestry.energy.EnergyManager;
@@ -288,35 +290,52 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
/* CAMOUFLAGE */
@Override
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
ItemStack oldCamouflageBlock;
switch (type) {
case DEFAULT:
camouflagePlainBlock = camouflageBlock;
break;
case GLASS:
camouflageGlassBlock = camouflageBlock;
break;
case DOOR:
camouflageDoorBlock = camouflageBlock;
break;
default:
return;
case DEFAULT:
oldCamouflageBlock = camouflagePlainBlock;
break;
case GLASS:
oldCamouflageBlock = camouflageGlassBlock;
break;
case DOOR:
oldCamouflageBlock = camouflageDoorBlock;
break;
default:
return;
}
if (worldObj != null) {
if (worldObj.isRemote) {
for (IMultiblockComponent comp : connectedParts) {
if (comp instanceof ICamouflagedTile) {
ICamouflagedTile camBlock = (ICamouflagedTile) comp;
if (camBlock.getCamouflageType() == type) {
worldObj.markBlockRangeForRenderUpdate(camBlock.getCoordinates(), camBlock.getCoordinates());
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, oldCamouflageBlock)){
switch (type) {
case DEFAULT:
camouflagePlainBlock = camouflageBlock;
break;
case GLASS:
camouflageGlassBlock = camouflageBlock;
break;
case DOOR:
camouflageDoorBlock = camouflageBlock;
break;
default:
return;
}
if (worldObj != null) {
if (worldObj.isRemote) {
for (IMultiblockComponent comp : connectedParts) {
if (comp instanceof ICamouflagedTile) {
ICamouflagedTile camBlock = (ICamouflagedTile) comp;
if (camBlock.getCamouflageType() == type) {
worldObj.markBlockRangeForRenderUpdate(camBlock.getCoordinates(), camBlock.getCoordinates());
}
}
}
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type, true));
}
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type, true));
}
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(createState(), null, this, type));
}
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(createState(), null, this, type));
}
@Override
@@ -41,6 +41,7 @@ import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamableGui;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.ITitled;
import forestry.core.utils.ItemStackUtil;
import forestry.greenhouse.blocks.BlockGreenhouse;
import forestry.greenhouse.blocks.BlockGreenhouseType;
import forestry.greenhouse.gui.ContainerGreenhouse;
@@ -93,15 +94,17 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry<Multib
@Override
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
this.camouflageBlock = camouflageBlock;
if (worldObj != null) {
if (worldObj.isRemote) {
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, this.camouflageBlock)){
this.camouflageBlock = camouflageBlock;
if (worldObj != null) {
if (worldObj.isRemote) {
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
}
}
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
}
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
}
@Override
@@ -47,6 +47,7 @@ import forestry.core.config.Config;
import forestry.core.gui.IHintSource;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.PlayerUtil;
import forestry.greenhouse.blocks.BlockGreenhouse;
import forestry.greenhouse.blocks.BlockGreenhouseType;
@@ -140,15 +141,17 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
/* CONSTRUCTION MATERIAL */
@Override
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
this.camouflageBlock = camouflageBlock;
if (worldObj != null) {
if (worldObj.isRemote) {
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, this.camouflageBlock)){
this.camouflageBlock = camouflageBlock;
if (worldObj != null) {
if (worldObj.isRemote) {
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
}
}
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
}
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
}
@Override