use server data in SSP for certain tiles, add changelog

This commit is contained in:
Adrian 2015-07-14 10:18:25 +02:00
parent c91d74b016
commit 50c2cf0f99
7 changed files with 70 additions and 17 deletions

View file

@ -0,0 +1,14 @@
Additions:
* Clay fluid pipe! The power of insertion applied to liquids. (asie)
* New blueprint library GUI, now featuring a scrollbar! (asie)
* New Lists - sort by type, material, or both, and other improvements! (asie)
Improvements:
* Use integrated server data in singleplayer for certain tiles - back to the smoothness of 1.2.5! (asie)
* Rewritten pipe wires - should now propagate more or less instantly. (asie)
* Fluid pipe capacity and extraction rate now scales with the base flow multiplier. (asie)
* Debugger support for fluid pipes (asie)
* Add events for robot interaction and removal (asie)

View file

@ -21,6 +21,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.network.INetHandler;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import cpw.mods.fml.common.Loader;
@ -167,4 +168,8 @@ public class CoreProxy implements ICoreProxy {
return null;
}
}
public TileEntity getServerTile(TileEntity source) {
return source;
}
}

View file

@ -20,10 +20,13 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.INetHandler;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraftforge.common.DimensionManager;
import buildcraft.BuildCraftCore;
import buildcraft.core.LaserKind;
@ -142,4 +145,18 @@ public class CoreProxyClient extends CoreProxy {
return Minecraft.getMinecraft().thePlayer;
}
}
@Override
public TileEntity getServerTile(TileEntity source) {
if (source.getWorldObj().isRemote) {
WorldServer w = DimensionManager.getWorld(source.getWorldObj().provider.dimensionId);
if (w != null) {
TileEntity t = w.getTileEntity(source.xCoord, source.yCoord, source.zCoord);
if (t != null && t.getClass().equals(source.getClass())) {
return t;
}
}
}
return source;
}
}

View file

@ -22,6 +22,7 @@ import buildcraft.core.lib.fluids.Tank;
import buildcraft.core.lib.render.FluidRenderer;
import buildcraft.core.lib.render.IInventoryRenderer;
import buildcraft.core.lib.render.RenderUtils;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.factory.TileRefinery;
public class RenderRefinery extends TileEntitySpecialRenderer implements IInventoryRenderer {
@ -68,7 +69,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
render((TileRefinery) tileentity, x, y, z);
render((TileRefinery) CoreProxy.proxy.getServerTile(tileentity), x, y, z);
}
private void render(TileRefinery tile, double x, double y, double z) {

View file

@ -16,6 +16,7 @@ import net.minecraftforge.fluids.FluidStack;
import buildcraft.core.lib.render.FluidRenderer;
import buildcraft.core.lib.render.RenderUtils;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.factory.TileTank;
public class RenderTank extends TileEntitySpecialRenderer {
@ -23,7 +24,7 @@ public class RenderTank extends TileEntitySpecialRenderer {
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
TileTank tank = (TileTank) tileentity;
TileTank tank = (TileTank) CoreProxy.proxy.getServerTile(tileentity);
FluidStack liquid = tank.tank.getFluid();
int color = tank.tank.colorRenderCache;

View file

@ -427,6 +427,18 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler,
return outputCount;
}
public FluidRenderData createServerFluidRenderData() {
FluidRenderData rCache = new FluidRenderData();
rCache.fluidID = fluidType != null ? fluidType.getFluid().getID() : 0;
rCache.color = fluidType != null ? fluidType.getFluid().getColor(fluidType) : 0;
if (fluidType != null) {
for (int i = 0; i < 7; i++) {
rCache.amount[i] = sections[i].amount;
}
}
return rCache;
}
/**
* Computes the PacketFluidUpdate packet for transmission to a client
*

View file

@ -45,6 +45,7 @@ import buildcraft.core.lib.render.RenderEntityBlock;
import buildcraft.core.lib.render.RenderEntityBlock.RenderInfo;
import buildcraft.core.lib.render.RenderUtils;
import buildcraft.core.lib.utils.MatrixTranformations;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeRenderState;
@ -300,9 +301,9 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
if (pipeType == IPipeTile.PipeType.ITEM) {
renderSolids(pipe.pipe, x, y, z, f);
} else if (pipeType == IPipeTile.PipeType.FLUID) {
renderFluids(pipe.pipe, x, y, z);
renderFluids(((TileGenericPipe) CoreProxy.proxy.getServerTile(pipe)).pipe, x, y, z);
} else if (pipeType == IPipeTile.PipeType.POWER) {
renderPower(pipe.pipe, x, y, z);
renderPower(((TileGenericPipe) CoreProxy.proxy.getServerTile(pipe)).pipe, x, y, z);
} /* else if (pipeType == PipeType.STRUCTURE) {
// no object to render in a structure pipe;
} */
@ -723,7 +724,13 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
PipeTransportFluids trans = pipe.transport;
boolean needsRender = false;
FluidRenderData renderData = trans.renderCache;
FluidRenderData renderData;
if (!pipe.container.getWorldObj().isRemote) {
renderData = trans.createServerFluidRenderData();
} else {
renderData = trans.renderCache;
}
for (int i = 0; i < 7; ++i) {
if (renderData.amount[i] > 0) {
needsRender = true;
@ -751,9 +758,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
int i = side.ordinal();
FluidRenderData fluidRenderData = trans.renderCache;
if (fluidRenderData.amount[i] <= 0) {
if (renderData.amount[i] <= 0) {
continue;
}
@ -761,13 +766,13 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
continue;
}
DisplayFluidList d = getDisplayFluidLists(fluidRenderData.fluidID, pipe.container.getWorldObj());
DisplayFluidList d = getDisplayFluidLists(renderData.fluidID, pipe.container.getWorldObj());
if (d == null) {
continue;
}
int stage = (int) ((float) fluidRenderData.amount[i] / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));
int stage = (int) ((float) renderData.amount[i] / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));
GL11.glPushMatrix();
int list = 0;
@ -796,21 +801,19 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
default:
}
bindTexture(TextureMap.locationBlocksTexture);
RenderUtils.setGLColorFromInt(fluidRenderData.color);
RenderUtils.setGLColorFromInt(renderData.color);
GL11.glCallList(list);
GL11.glPopMatrix();
}
// CENTER
FluidRenderData fluidRenderData = trans.renderCache;
if (fluidRenderData.amount[6] > 0) {
DisplayFluidList d = getDisplayFluidLists(fluidRenderData.fluidID, pipe.container.getWorldObj());
if (renderData.amount[6] > 0) {
DisplayFluidList d = getDisplayFluidLists(renderData.fluidID, pipe.container.getWorldObj());
if (d != null) {
int stage = (int) ((float) fluidRenderData.amount[6] / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));
int stage = (int) ((float) renderData.amount[6] / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));
bindTexture(TextureMap.locationBlocksTexture);
RenderUtils.setGLColorFromInt(fluidRenderData.color);
RenderUtils.setGLColorFromInt(renderData.color);
if (above) {
GL11.glCallList(d.centerVertical[stage]);