Fix filler GUI and world rendering
This commit is contained in:
parent
05c235da6f
commit
4a5d5b219d
8 changed files with 57 additions and 34 deletions
|
@ -14,12 +14,17 @@ import java.util.LinkedList;
|
|||
import java.util.TreeMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.client.event.TextureLoadEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.Property;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.bptblocks.BptBlockBed;
|
||||
import buildcraft.api.bptblocks.BptBlockCustomStack;
|
||||
|
@ -47,6 +52,7 @@ import buildcraft.builders.BlockFiller;
|
|||
import buildcraft.builders.BlockMarker;
|
||||
import buildcraft.builders.BlockPathMarker;
|
||||
import buildcraft.builders.BptBlockFiller;
|
||||
import buildcraft.builders.BuilderProxyClient;
|
||||
import buildcraft.builders.EventHandlerBuilders;
|
||||
import buildcraft.builders.FillerFillAll;
|
||||
import buildcraft.builders.FillerFillPyramid;
|
||||
|
@ -82,6 +88,8 @@ import cpw.mods.fml.common.network.NetworkMod;
|
|||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Mod(name = "BuildCraft Builders", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Builders", dependencies = DefaultProps.DEPENDENCY_CORE)
|
||||
@NetworkMod(channels = { DefaultProps.NET_CHANNEL_NAME }, packetHandler = PacketHandlerBuilders.class, clientSideRequired = true, serverSideRequired = true)
|
||||
|
@ -274,6 +282,8 @@ public class BuildCraftBuilders {
|
|||
BuildCraftCore.mainConfiguration.save();
|
||||
}
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
// public static final Block music;
|
||||
// public static final Block cloth;
|
||||
// public static final Block tilledField;
|
||||
|
@ -382,4 +392,20 @@ public class BuildCraftBuilders {
|
|||
TilePathMarker.clearAvailableMarkersList();
|
||||
}
|
||||
|
||||
|
||||
@ForgeSubscribe
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void loadTextures(TextureStitchEvent.Pre evt) {
|
||||
if (evt.map == Minecraft.getMinecraft().renderEngine.textureMapBlocks) {
|
||||
TextureMap terrainMap = evt.map;
|
||||
BuilderProxyClient.fillerFillAllTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/fillAll");
|
||||
BuilderProxyClient.fillerClearTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/clear");
|
||||
BuilderProxyClient.fillerWallsTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/walls");
|
||||
BuilderProxyClient.fillerStairsTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/stairs");
|
||||
BuilderProxyClient.fillerFlattenTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/flatten");
|
||||
BuilderProxyClient.fillerPyramidTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/pyramid");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -109,8 +109,7 @@ public class BlockFiller extends BlockContainer {
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
public void registerIcons(IconRegister par1IconRegister) {
|
||||
textureTopOn = par1IconRegister.registerIcon("buildcraft:blockFillerTopOn");
|
||||
textureTopOff = par1IconRegister.registerIcon("buildcraft:blockFillerTopOff");
|
||||
textureSides = par1IconRegister.registerIcon("buildcraft:blockFillerSides");
|
||||
|
|
|
@ -13,16 +13,6 @@ public class BuilderProxyClient extends BuilderProxy {
|
|||
public static Icon fillerFlattenTexture;
|
||||
public static Icon fillerPyramidTexture;
|
||||
|
||||
|
||||
public void initializeTextures() {
|
||||
TextureMap terrainMap = Minecraft.getMinecraft().renderEngine.textureMapItems;
|
||||
fillerFillAllTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/fillAll");
|
||||
fillerClearTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/clear");
|
||||
fillerWallsTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/walls");
|
||||
fillerStairsTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/stairs");
|
||||
fillerFlattenTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/flatten");
|
||||
fillerPyramidTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/pyramid");
|
||||
}
|
||||
@Override
|
||||
public void registerClientHook() {
|
||||
BuildCraftBuilders.addHook(new ClientBuilderHook());
|
||||
|
|
|
@ -52,6 +52,7 @@ public class GuiFiller extends GuiBuildCraft {
|
|||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
if (filler.currentPattern != null) {
|
||||
mc.renderEngine.bindTexture("/terrain.png");
|
||||
drawTexturedModelRectFromIcon(guiLeft + patternSymbolX, guiTop + patternSymbolY, filler.currentPattern.getTexture(), 16, 16);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
|
|||
private short currentTime = 0;
|
||||
|
||||
// Tracks how much of the liquid is inbound in timeslots
|
||||
private short[] incomming = new short[travelDelay];
|
||||
private int[] incomming = new int[travelDelay];
|
||||
|
||||
// Tracks how much is currently available (has spent it's inbound delaytime)
|
||||
|
||||
|
@ -88,36 +88,36 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
|
|||
|
||||
public void reset() {
|
||||
this.setLiquid(null);
|
||||
incomming = new short[travelDelay];
|
||||
incomming = new int[travelDelay];
|
||||
}
|
||||
|
||||
public int getAvailable() {
|
||||
int all = this.getLiquid() != null ? this.getLiquid().amount : 0;
|
||||
for (short slot : incomming) {
|
||||
for (int slot : incomming) {
|
||||
all -= slot;
|
||||
}
|
||||
return all;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compoundTag) {
|
||||
public LiquidTank readFromNBT(NBTTagCompound compoundTag) {
|
||||
super.readFromNBT(compoundTag);
|
||||
this.setCapacity(compoundTag.getInteger("capacity"));
|
||||
|
||||
for (int i = 0; i < travelDelay; ++i) {
|
||||
incomming[i] = compoundTag.getShort("in[" + i + "]");
|
||||
}
|
||||
setLiquid(LiquidStack.loadLiquidStackFromNBT(compoundTag));
|
||||
return this;
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound subTag) {
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound subTag) {
|
||||
subTag.setInteger("capacity", this.getCapacity());
|
||||
|
||||
for (int i = 0; i < travelDelay; ++i) {
|
||||
incomming[i] = subTag.getShort("in[" + i + "]");
|
||||
}
|
||||
|
||||
if (this.getLiquid() != null) {
|
||||
this.getLiquid().writeToNBT(subTag);
|
||||
}
|
||||
super.writeToNBT(subTag);
|
||||
return subTag;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
|
|||
|
||||
public byte initClient = 0;
|
||||
public short travelDelay = 12;
|
||||
public short flowRate = 10;
|
||||
public int flowRate = 10;
|
||||
public LiquidStack[] renderCache = new LiquidStack[orientations.length];
|
||||
|
||||
private final PipeSection[] internalTanks = new PipeSection[orientations.length];
|
||||
|
@ -550,4 +550,8 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
|
|||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void forceSize(ForgeDirection dir, int maxCapacity) {
|
||||
internalTanks[dir.ordinal()].setCapacity(maxCapacity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class PipeLiquidsEmerald extends PipeLiquidsWood {
|
|||
standardIconIndex = PipeIconProvider.PipeLiquidsEmerald_Standard;
|
||||
solidIconIndex = PipeIconProvider.PipeAllEmerald_Solid;
|
||||
|
||||
((PipeTransportLiquids) transport).flowRate = 40;
|
||||
((PipeTransportLiquids) transport).flowRate = Short.MAX_VALUE - 1;
|
||||
((PipeTransportLiquids) transport).travelDelay = 4;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,13 +45,15 @@ public class PipeLiquidsWood extends Pipe implements IPowerReceptor {
|
|||
public PipeLiquidsWood(int itemID) {
|
||||
this(new PipeLogicWood(), itemID);
|
||||
}
|
||||
|
||||
|
||||
protected PipeLiquidsWood(PipeLogic logic, int itemID) {
|
||||
super(new PipeTransportLiquids(), logic, itemID);
|
||||
|
||||
powerProvider = PowerFramework.currentFramework.createPowerProvider();
|
||||
powerProvider.configure(50, 1, 100, 1, 250);
|
||||
powerProvider.configurePowerPerdition(1, 1);
|
||||
powerProvider.configure(50, 1, 64, 1, 250);
|
||||
powerProvider.configurePowerPerdition(64, 1);
|
||||
((PipeTransportLiquids) transport).flowRate = 1000;
|
||||
((PipeTransportLiquids) transport).travelDelay = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,7 +61,7 @@ public class PipeLiquidsWood extends Pipe implements IPowerReceptor {
|
|||
*/
|
||||
@Override
|
||||
public void doWork() {
|
||||
if (powerProvider.getEnergyStored() <= 0)
|
||||
if (powerProvider.getEnergyStored() <= 0 || liquidToExtract > LiquidContainerRegistry.BUCKET_VOLUME * 4.0f)
|
||||
return;
|
||||
|
||||
World w = worldObj;
|
||||
|
@ -77,9 +79,10 @@ public class PipeLiquidsWood extends Pipe implements IPowerReceptor {
|
|||
if (!PipeManager.canExtractLiquids(this, w, (int) pos.x, (int) pos.y, (int) pos.z))
|
||||
return;
|
||||
|
||||
if (liquidToExtract <= LiquidContainerRegistry.BUCKET_VOLUME) {
|
||||
liquidToExtract += powerProvider.useEnergy(1, 1, true) * LiquidContainerRegistry.BUCKET_VOLUME;
|
||||
}
|
||||
double p = powerProvider.useEnergy(1, 64, true);
|
||||
double d = ( Math.log(p)/Math.log(2) + 1 ) * LiquidContainerRegistry.BUCKET_VOLUME / 7.0f;
|
||||
System.out.printf("Extracting %f %f %f\n",p,d,( Math.log(p)/Math.log(2) + 1 ));
|
||||
liquidToExtract = (int)Math.floor(d);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,15 +111,15 @@ public class PipeLiquidsWood extends Pipe implements IPowerReceptor {
|
|||
if (tile instanceof ITankContainer) {
|
||||
ITankContainer container = (ITankContainer) tile;
|
||||
|
||||
int flowRate = ((PipeTransportLiquids) transport).flowRate;
|
||||
|
||||
LiquidStack extracted = container.drain(pos.orientation.getOpposite(), liquidToExtract > flowRate ? flowRate : liquidToExtract, false);
|
||||
LiquidStack extracted = container.drain(pos.orientation.getOpposite(), liquidToExtract, false);
|
||||
|
||||
int inserted = 0;
|
||||
if (extracted != null) {
|
||||
System.out.printf("Can extract %d of %d\n", extracted.amount, extracted.itemID);
|
||||
inserted = ((PipeTransportLiquids) transport).fill(pos.orientation, extracted, true);
|
||||
|
||||
container.drain(pos.orientation.getOpposite(), inserted, true);
|
||||
System.out.printf("Did extract %d of %d\n", inserted, extracted.itemID);
|
||||
}
|
||||
|
||||
liquidToExtract -= inserted;
|
||||
|
|
|
@ -43,7 +43,7 @@ public class PipeLogicWood extends PipeLogic {
|
|||
}
|
||||
|
||||
if (newMeta != meta) {
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta,0);
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta,3);
|
||||
container.scheduleRenderUpdate();
|
||||
// worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue