I try to port and fix addon Advanced Solar Panel to SMP mode. I already do it. All work at SSP, but in SMP is some small bugs. In SMP mode not display value "Generating:". And not display status "Sun is up" and "Sun is down". Gauge with energy storage work fine. How recieve and update this values in SMP ?
I can't find the documentation on the mechanism of synchronization of adjustments server and the client. Sample: i have adjustment value "generation" on client and server. I setup in client value "5" on server value "10". I need in SMP mode use only server values. How i can do it ?
And i need to update client GUI with server adjustment.
This is code:
TileEntity:
Java
package net.minecraft.src;
import ic2.common.TileEntityBaseGenerator;
import java.util.Random;
// Referenced classes of package net.minecraft.src:
// BlockAdvancedSolarPanel, World, Block, ContainerAdvancedSolarPanel,
// InventoryPlayer, Container
public class TileEntityAdvancedSolarPanel extends TileEntityBaseGenerator
{
public TileEntityAdvancedSolarPanel()
{
super(1);
initialized = false;
sunIsUp = false;
skyIsVisible = false;
initialized = false;
production = 512;
ticker = randomizer.nextInt(tickRate());
}
public short getMaximumStorage()
{
return 16000;
}
public int gaugeEnergyScaled(int i)
{
return (storage * i) / getMaximumStorage();
}
public int gaugeFuelScaled(int i)
{
return i;
}
public boolean gainFuel()
{
boolean flag = false;
if(ticker++ % tickRate() == 0 || !initialized)
{
updateVisibility();
initialized = true;
}
if(sunIsUp && skyIsVisible)
{
generating = 0 + BlockAdvancedSolarPanel.genDay;
int i = storage + generating;
storage = (short)i;
return true;
}
if(skyIsVisible)
{
generating = 0 + BlockAdvancedSolarPanel.genNight;
int j = storage + generating;
storage = (short)j;
return true;
} else
{
generating = 0;
return false;
}
}
public void updateVisibility()
{
if(!worldObj.isDaytime())
{
sunIsUp = false;
} else
{
sunIsUp = true;
}
skyIsVisible = true;
for(int i = yCoord + 1; i < 128; i++)
{
int j = worldObj.getBlockId(xCoord, i, zCoord);
if(j != 0 && j != Block.glass.blockID)
{
skyIsVisible = false;
return;
}
}
}
public boolean needsFuel()
{
return true;
}
public String getInvName()
{
return "Adv Solar Panel";
}
public int tickRate()
{
return 128;
}
public String getLoopSound()
{
return "none";
}
public int getLoopingTime()
{
return 256;
}
public Container getGuiContainer(InventoryPlayer inventoryplayer)
{
return new ContainerAdvancedSolarPanel(inventoryplayer, this);
}
public static Random randomizer = new Random();
public int ticker;
public int generating;
public int genDay;
public int genNight;
public boolean initialized;
public boolean sunIsUp;
public boolean skyIsVisible;
}
Display More
GUI:
Code
package net.minecraft.src;
import net.minecraft.client.Minecraft;
import org.lwjgl.opengl.GL11;
// Referenced classes of package net.minecraft.src:
// GuiContainer, ContainerAdvancedSolarPanel, FontRenderer, TileEntityAdvancedSolarPanel,
// RenderEngine, InventoryPlayer
public class GuiAdvancedSolarPanel extends GuiContainer
{
public GuiAdvancedSolarPanel(InventoryPlayer inventoryplayer, TileEntityAdvancedSolarPanel tileentityadvancedsolarpanel)
{
super(new ContainerAdvancedSolarPanel(inventoryplayer, tileentityadvancedsolarpanel));
tileentity = tileentityadvancedsolarpanel;
}
protected void drawGuiContainerForegroundLayer()
{
fontRenderer.drawString("Advanced Solar Panel", 38, 6, 0x404040);
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
fontRenderer.drawString((new StringBuilder()).append("Storage: ").append(tileentity.storage).append("/").append(tileentity.maxStorage).toString(), 45, 25, 0x404040);
fontRenderer.drawString((new StringBuilder()).append("Max Output: ").append(tileentity.production).append(" EU/t").toString(), 45, 35, 0x404040);
fontRenderer.drawString((new StringBuilder()).append("Generating: ").append(tileentity.generating).append(" EU/t").toString(), 45, 45, 0x404040);
}
protected void drawGuiContainerBackgroundLayer(float f)
{
int i = mc.renderEngine.getTexture("/GUIAdvancedSolarPanel.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(i);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
if(tileentity.storage > 0)
{
int l = tileentity.gaugeEnergyScaled(24);
drawTexturedModalRect(j + 14, k + 25, 176, 14, l + 1, 16);
}
if(tileentity.skyIsVisible)
{
if(tileentity.sunIsUp)
{
drawTexturedModalRect(j + 19, k + 45, 176, 0, 14, 14);
} else
if(!tileentity.sunIsUp)
{
drawTexturedModalRect(j + 19, k + 45, 190, 0, 14, 14);
}
}
}
public TileEntityAdvancedSolarPanel tileentity;
}
Display More
Big thanks for you help.
P.S. Sorry for my bad English