Merge pull request #1 from SirSengir/master

rebased
This commit is contained in:
Xhamolk 2012-10-05 08:39:21 -07:00
commit 569fde6e0c
36 changed files with 450 additions and 295 deletions

View file

@ -18,7 +18,7 @@
<property name="mcpsrc.dir" value="${mcp.dir}/src/minecraft"/>
<property name="mcp.version" value="72"/>
<property name="forge.version" value="4.1.1.251"/>
<property name="forge.version" value="4.1.4.287"/>
<property name="bc.version" value="3.1.8"/>
<available property="forge-exists" file="${download.dir}/minecraftforge-src-${forge.version}.zip"/>

View file

@ -17,7 +17,7 @@
<property name="mc.version" value="1.3.2"/>
<property name="mcp.version" value="72"/>
<property name="forge.version" value="4.0.0.232"/>
<property name="forge.version" value="4.1.4.287"/>
<property name="bc.version" value="3.2.0"/>
<property name="bc.version.full" value="${bc.version}pre7"/>

View file

@ -69,7 +69,7 @@ import net.minecraft.src.ItemStack;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.Property;
@Mod(name="BuildCraft", version=Version.VERSION, useMetadata = false, modid = "BuildCraft|Core")
@Mod(name="BuildCraft", version=Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", dependencies="required-after:Forge@[4.1.4.285,)")
@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true)
public class BuildCraftCore {
public static enum RenderMode {
@ -142,9 +142,9 @@ public class BuildCraftCore {
@PreInit
public void loadConfiguration(FMLPreInitializationEvent evt) {
Version.versionCheck();
bcLog.setParent(FMLLog.getLogger());
bcLog.info("Starting BuildCraft " + Version.getVersion());
bcLog.info("Copyright (c) SpaceToad, 2011");
@ -266,7 +266,7 @@ public class BuildCraftCore {
CommandHandler commandManager = (CommandHandler)event.getServer().getCommandManager();
commandManager.registerCommand(new CommandBuildCraft());
}
public void loadRecipes() {
GameRegistry.addRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", Character.valueOf('I'), Item.ingotIron, Character.valueOf('G'), stoneGearItem);
GameRegistry.addRecipe(new ItemStack(woodenGearItem), " S ", "S S", " S ", Character.valueOf('S'), Item.stick);

View file

@ -142,7 +142,7 @@ public class BuildCraftEnergy {
LanguageRegistry.addName(bucketOil, "Oil Bucket");
bucketFuel = new ItemBuildCraft(Integer.parseInt(bucketFuelId.value)).setItemName("bucketFuel").setContainerItem(Item.bucketEmpty);
bucketFuel.setIconIndex(0 * 16 + 3).setMaxStackSize(1).setTabToDisplayOn(CreativeTabs.tabMisc);
bucketFuel.setIconIndex(0 * 16 + 3).setMaxStackSize(1).setCreativeTab(CreativeTabs.tabMisc);
LanguageRegistry.addName(bucketFuel, "Fuel Bucket");
RefineryRecipe.registerRefineryRecipe(new RefineryRecipe(new LiquidStack(oilStill.blockID, 1, 0), null, new LiquidStack(fuel.shiftedIndex, 1, 0), 10, 1));

View file

@ -8,6 +8,10 @@
package buildcraft;
import java.util.List;
import com.google.common.collect.Lists;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
@ -49,7 +53,10 @@ import buildcraft.silicon.TileLaser;
import net.minecraft.src.Block;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.World;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.Property;
@Mod(name="BuildCraft Factory", version=Version.VERSION, useMetadata = false, modid = "BuildCraft|Factory", dependencies = DefaultProps.DEPENDENCY_CORE)
@ -77,6 +84,42 @@ public class BuildCraftFactory {
@PostInit
public void postInit(FMLPostInitializationEvent evt) {
FactoryProxy.proxy.initializeNEIIntegration();
ForgeChunkManager.setForcedChunkLoadingCallback(instance,new QuarryChunkloadCallback());
}
public class QuarryChunkloadCallback implements ForgeChunkManager.OrderedLoadingCallback
{
@Override
public void ticketsLoaded(List<Ticket> tickets, World world) {
for (Ticket ticket : tickets)
{
int quarryX = ticket.getModData().getInteger("quarryX");
int quarryY = ticket.getModData().getInteger("quarryY");
int quarryZ = ticket.getModData().getInteger("quarryZ");
TileQuarry tq = (TileQuarry) world.getBlockTileEntity(quarryX, quarryY, quarryZ);
tq.forceChunkLoading(ticket);
}
}
@Override
public List<Ticket> ticketsLoaded(List<Ticket> tickets, World world, int maxTicketCount) {
List<Ticket> validTickets = Lists.newArrayList();
for (Ticket ticket : tickets)
{
int quarryX = ticket.getModData().getInteger("quarryX");
int quarryY = ticket.getModData().getInteger("quarryY");
int quarryZ = ticket.getModData().getInteger("quarryZ");
int blId = world.getBlockId(quarryX, quarryY, quarryZ);
if (blId == quarryBlock.blockID)
{
validTickets.add(ticket);
}
}
return validTickets;
}
}
@Init
public void load(FMLInitializationEvent evt) {

View file

@ -237,12 +237,12 @@ public class BuildCraftTransport {
groupItemsTrigger = Integer.parseInt(groupItemsTriggerProp.value);
Property genericPipeId = BuildCraftCore.mainConfiguration.getOrCreateBlockIdProperty("pipe.id", DefaultProps.GENERIC_PIPE_ID);
Property pipeWaterproofId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("pipeWaterproof.id", Configuration.CATEGORY_ITEM, DefaultProps.PIPE_WATERPROOF_ID);
pipeWaterproof = new ItemBuildCraft(Integer.parseInt(pipeWaterproofId.value)).setIconIndex(2 * 16 + 1);
pipeWaterproof.setItemName("pipeWaterproof");
pipeWaterproof.setTabToDisplayOn(CreativeTabs.tabMaterials);
pipeWaterproof.setCreativeTab(CreativeTabs.tabMaterials);
LanguageRegistry.addName(pipeWaterproof, "Pipe Waterproof");
genericPipeBlock = new BlockGenericPipe(Integer.parseInt(genericPipeId.value));
GameRegistry.registerBlock(genericPipeBlock);
@ -316,28 +316,28 @@ public class BuildCraftTransport {
}
Property redPipeWireId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("redPipeWire.id", Configuration.CATEGORY_ITEM, DefaultProps.RED_PIPE_WIRE);
redPipeWire = new ItemBuildCraft(Integer.parseInt(redPipeWireId.value)).setIconIndex(4 * 16 + 0).setTabToDisplayOn(CreativeTabs.tabRedstone);
redPipeWire = new ItemBuildCraft(Integer.parseInt(redPipeWireId.value)).setIconIndex(4 * 16 + 0).setCreativeTab(CreativeTabs.tabRedstone);
redPipeWire.setItemName("redPipeWire");
LanguageRegistry.addName(redPipeWire, "Red Pipe Wire");
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 1),
new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1) }, 500, new ItemStack(redPipeWire, 8)));
Property bluePipeWireId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("bluePipeWire.id", Configuration.CATEGORY_ITEM, DefaultProps.BLUE_PIPE_WIRE);
bluePipeWire = new ItemBuildCraft(Integer.parseInt(bluePipeWireId.value)).setIconIndex(4 * 16 + 1).setTabToDisplayOn(CreativeTabs.tabRedstone);
bluePipeWire = new ItemBuildCraft(Integer.parseInt(bluePipeWireId.value)).setIconIndex(4 * 16 + 1).setCreativeTab(CreativeTabs.tabRedstone);
bluePipeWire.setItemName("bluePipeWire");
LanguageRegistry.addName(bluePipeWire, "Blue Pipe Wire");
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 4),
new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1) }, 500, new ItemStack(bluePipeWire, 8)));
Property greenPipeWireId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("greenPipeWire.id", Configuration.CATEGORY_ITEM, DefaultProps.GREEN_PIPE_WIRE);
greenPipeWire = new ItemBuildCraft(Integer.parseInt(greenPipeWireId.value)).setIconIndex(4 * 16 + 2).setTabToDisplayOn(CreativeTabs.tabRedstone);
greenPipeWire = new ItemBuildCraft(Integer.parseInt(greenPipeWireId.value)).setIconIndex(4 * 16 + 2).setCreativeTab(CreativeTabs.tabRedstone);
greenPipeWire.setItemName("greenPipeWire");
LanguageRegistry.addName(greenPipeWire, "Green Pipe Wire");
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 2),
new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1) }, 500, new ItemStack(greenPipeWire, 8)));
Property yellowPipeWireId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("yellowPipeWire.id", Configuration.CATEGORY_ITEM, DefaultProps.YELLOW_PIPE_WIRE);
yellowPipeWire = new ItemBuildCraft(Integer.parseInt(yellowPipeWireId.value)).setIconIndex(4 * 16 + 3).setTabToDisplayOn(CreativeTabs.tabRedstone);
yellowPipeWire = new ItemBuildCraft(Integer.parseInt(yellowPipeWireId.value)).setIconIndex(4 * 16 + 3).setCreativeTab(CreativeTabs.tabRedstone);
yellowPipeWire.setItemName("yellowPipeWire");
LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire");
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 11),
@ -355,7 +355,7 @@ public class BuildCraftTransport {
facadeItem = new ItemFacade(Integer.parseInt(pipeFacadeId.value));
facadeItem.setItemName("pipeFacade");
ItemFacade.initialize();
BuildCraftCore.mainConfiguration.save();
new BptBlockPipe(genericPipeBlock.blockID);

View file

@ -1,8 +1,8 @@
/**
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
@ -64,7 +64,7 @@ public class FillerFlattener extends FillerPattern {
}
if (lastX != Integer.MAX_VALUE && stackToPlace != null) {
stackToPlace.getItem().tryPlaceIntoWorld(stackToPlace, CoreProxy.proxy.getBuildCraftPlayer(tile.worldObj), tile.worldObj,
stackToPlace.getItem().onItemUse(stackToPlace, CoreProxy.proxy.getBuildCraftPlayer(tile.worldObj), tile.worldObj,
lastX, lastY - 1, lastZ, 1, 0.0f, 0.0f, 0.0f);
}

View file

@ -1,8 +1,8 @@
/**
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
@ -66,7 +66,7 @@ public abstract class FillerPattern implements IFillerPattern {
}
if (found && stackToPlace != null) {
stackToPlace.getItem().tryPlaceIntoWorld(stackToPlace, CoreProxy.proxy.getBuildCraftPlayer(world), world, xSlot, ySlot - 1,
stackToPlace.getItem().onItemUse(stackToPlace, CoreProxy.proxy.getBuildCraftPlayer(world), world, xSlot, ySlot - 1,
zSlot, 1, 0.0f, 0.0f, 0.0f);
}

View file

@ -1,8 +1,8 @@
/**
/**
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
@ -27,7 +27,7 @@ public abstract class ItemBptBase extends ItemBuildCraft {
maxStackSize = 1;
iconIndex = 5 * 16 + 0;
this.setTabToDisplayOn(CreativeTabs.tabMisc);
this.setCreativeTab(CreativeTabs.tabMisc);
}
@SuppressWarnings({ "all" })

View file

@ -235,7 +235,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
for (BlockIndex b : path) {
if (previous != null) {
EntityLaser laser = new EntityPowerLaser(worldObj,
EntityPowerLaser laser = new EntityPowerLaser(worldObj,
new Position(previous.i + 0.5, previous.j + 0.5, previous.k + 0.5),
new Position(b.i + 0.5, b.j + 0.5, b.k + 0.5));

View file

@ -12,20 +12,16 @@ package buildcraft.builders;
import buildcraft.BuildCraftCore;
import buildcraft.api.core.IAreaProvider;
import buildcraft.api.core.LaserKind;
import buildcraft.api.core.Orientations;
import buildcraft.api.filler.FillerManager;
import buildcraft.api.filler.IFillerPattern;
import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionReceptor;
import buildcraft.api.inventory.ISpecialInventory;
import buildcraft.api.power.IPowerProvider;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerFramework;
import buildcraft.core.Box;
import buildcraft.core.IMachine;
import buildcraft.core.TileBuildCraft;
import buildcraft.core.inventory.ITransactor;
import buildcraft.core.inventory.TransactorSimple;
import buildcraft.core.network.PacketUpdate;
import buildcraft.core.network.TileNetworkData;
import buildcraft.core.proxy.CoreProxy;
@ -35,8 +31,10 @@ import buildcraft.core.utils.Utils;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPowerReceptor, IMachine, IActionReceptor {
public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowerReceptor, IMachine, IActionReceptor {
public @TileNetworkData
Box box = new Box();
@ -136,7 +134,7 @@ public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPo
}
if (done) {
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
sendNetworkUpdate();
}
}
@ -177,7 +175,7 @@ public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPo
}
if (worldObj != null) {
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
}
if (currentPattern == null) {
@ -309,7 +307,7 @@ public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPo
super.handleDescriptionPacket(packet);
currentPattern = FillerManager.registry.getPattern(currentPatternId);
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
if (!initialized && box.isInitialized()) {
box.createLasers(worldObj, LaserKind.Stripes);
@ -323,7 +321,7 @@ public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPo
super.handleUpdatePacket(packet);
currentPattern = FillerManager.registry.getPattern(currentPatternId);
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
if (!initialized && box.isInitialized()) {
box.createLasers(worldObj, LaserKind.Stripes);
@ -390,29 +388,24 @@ public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPo
return true;
}
/* ISPECIALINVENTORY */
@Override
public int addItem(ItemStack stack, boolean doAdd, Orientations from) {
ITransactor transactor = new TransactorSimple(this);
ItemStack added = transactor.add(stack, from, doAdd);
return added.stackSize;
/**
* Get the start of the side inventory.
* @param side The global side to get the start of range.
*/
public int getStartInventorySide(ForgeDirection side) {
if(side == ForgeDirection.UP)
return 0;
return 9;
}
@Override
public ItemStack[] extractItem(boolean doRemove, Orientations from, int maxItemCount) {
for (int i = 9; i < contents.length; ++i) {
if (contents[i] != null) {
if (doRemove) {
return new ItemStack[] { decrStackSize(i, 1) };
} else {
return new ItemStack[] { contents[i] };
}
}
}
/**
* Get the size of the side inventory.
* @param side The global side.
*/
public int getSizeInventorySide(ForgeDirection side) {
if(side == ForgeDirection.UP)
return 9;
return getSizeInventory()-9;
return null;
}
}

View file

@ -60,7 +60,7 @@ public class TilePathMarker extends TileMarker {
if (CoreProxy.proxy.isRenderWorld(worldObj))
return;
EntityLaser laser = new EntityPowerLaser(worldObj, new Position(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5), new Position(pathMarker.xCoord + 0.5, pathMarker.yCoord + 0.5, pathMarker.zCoord + 0.5));
EntityPowerLaser laser = new EntityPowerLaser(worldObj, new Position(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5), new Position(pathMarker.xCoord + 0.5, pathMarker.yCoord + 0.5, pathMarker.zCoord + 0.5));
laser.show();
laser.setTexture(DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_1.png");
@ -76,7 +76,7 @@ public class TilePathMarker extends TileMarker {
double nearestDistance = 0, distance; //The initialization of nearestDistance is only to make the compiler shut up
for (TilePathMarker t : availableMarkers) {
if (t == this || t == this.links[0] || t == this.links[1] || t.worldObj.provider.worldType != this.worldObj.provider.worldType)
if (t == this || t == this.links[0] || t == this.links[1] || t.worldObj.provider.dimensionId != this.worldObj.provider.dimensionId)
continue;
distance = Math.sqrt(Math.pow(this.xCoord - t.xCoord, 2) + Math.pow(this.yCoord - t.yCoord, 2) + Math.pow(this.zCoord - t.zCoord, 2));
@ -257,7 +257,7 @@ public class TilePathMarker extends TileMarker {
public static void clearAvailableMarkersList(World w) {
for (Iterator<TilePathMarker> it = availableMarkers.iterator(); it.hasNext();) {
TilePathMarker t = it.next();
if (t.worldObj.provider.worldType != w.provider.worldType) {
if (t.worldObj.provider.dimensionId != w.provider.dimensionId) {
it.remove();
}
}

View file

@ -58,27 +58,20 @@ public class EntityEnergyLaser extends EntityLaser {
}
@Override
protected void updateData() {
super.updateData();
protected void updateDataClient() {
super.updateDataClient();
powerAverage = (float)decodeDouble(dataWatcher.getWatchableObjectInt(15));
}
@Override
public void setPositions(Position head, Position tail) {
super.setPositions(head, tail);
protected void updateDataServer() {
super.updateDataServer();
dataWatcher.updateObject(15, Integer.valueOf(encodeDouble((double)powerAverage)));
}
@Override
protected void initClientSide() {
super.initClientSide();
protected void entityInit() {
super.entityInit();
dataWatcher.addObject(15, Integer.valueOf(0));
}
@Override
protected void initServerSide() {
super.initServerSide();
dataWatcher.addObject(15, encodeDouble((double)powerAverage));
}
}

View file

@ -16,19 +16,22 @@ import net.minecraft.src.Entity;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.World;
public class EntityLaser extends Entity {
public abstract class EntityLaser extends Entity {
protected Position head, tail;
public double renderSize = 0;
public double angleY = 0;
public double angleZ = 0;
protected String texture;
private boolean isVisible = false;
protected boolean needsUpdate = true;
public EntityLaser(World world) {
super(world);
initClientSide();
head = new Position(0, 0, 0);
tail = new Position(0, 0, 0);
}
public EntityLaser(World world, Position head, Position tail) {
@ -39,46 +42,23 @@ public class EntityLaser extends Entity {
this.tail = tail;
setPositionAndRotation(head.x, head.y, head.z, 0, 0);
initServerSide();
setSize(10, 10);
}
protected void initClientSide() {
head = new Position(0, 0, 0);
tail = new Position(0, 0, 0);
dataWatcher.addObject(8 , Integer.valueOf(0));
dataWatcher.addObject(9 , Integer.valueOf(0));
@Override
protected void entityInit() {
preventEntitySpawning = false;
noClip = true;
isImmuneToFire = true;
dataWatcher.addObject(8, Integer.valueOf(0));
dataWatcher.addObject(9, Integer.valueOf(0));
dataWatcher.addObject(10, Integer.valueOf(0));
dataWatcher.addObject(11, Integer.valueOf(0));
dataWatcher.addObject(12, Integer.valueOf(0));
dataWatcher.addObject(13, Integer.valueOf(0));
dataWatcher.addObject(14, Byte.valueOf((byte) 0));
dataWatcher.addObject(16, "");
}
protected void initServerSide() {
preventEntitySpawning = false;
noClip = true;
isImmuneToFire = true;
setPositionAndRotation(head.x, head.y, head.z, 0, 0);
setSize(10, 10);
dataWatcher.addObject(8 , Integer.valueOf(encodeDouble(head.x)));
dataWatcher.addObject(9 , Integer.valueOf(encodeDouble(head.y)));
dataWatcher.addObject(10, Integer.valueOf(encodeDouble(head.z)));
dataWatcher.addObject(11, Integer.valueOf(encodeDouble(tail.x)));
dataWatcher.addObject(12, Integer.valueOf(encodeDouble(tail.y)));
dataWatcher.addObject(13, Integer.valueOf(encodeDouble(tail.z)));
dataWatcher.addObject(14, Byte.valueOf((byte) 0));
dataWatcher.addObject(16, "");
}
@Override
@ -87,8 +67,13 @@ public class EntityLaser extends Entity {
if (head == null || tail == null)
return;
if (CoreProxy.proxy.isSimulating(worldObj) && needsUpdate) {
updateDataServer();
needsUpdate = false;
}
if (CoreProxy.proxy.isRenderWorld(worldObj))
updateData();
updateDataClient();
boundingBox.minX = Math.min(head.x, tail.x);
boundingBox.minY = Math.min(head.y, tail.y);
@ -116,66 +101,62 @@ public class EntityLaser extends Entity {
angleY = -Math.atan2(dy, dx) * 180 / Math.PI;
}
protected void updateData() {
protected void updateDataClient() {
head.x = decodeDouble(dataWatcher.getWatchableObjectInt(8));
head.y = decodeDouble(dataWatcher.getWatchableObjectInt(9));
head.z = decodeDouble(dataWatcher.getWatchableObjectInt(10));
tail.x = decodeDouble(dataWatcher.getWatchableObjectInt(11));
tail.y = decodeDouble(dataWatcher.getWatchableObjectInt(12));
tail.z = decodeDouble(dataWatcher.getWatchableObjectInt(13));
texture = dataWatcher.getWatchableObjectString(16);
isVisible = (dataWatcher.getWatchableObjectByte(14) == 1);
}
public void setPositions(Position head, Position tail) {
this.head = head;
this.tail = tail;
setPositionAndRotation(head.x, head.y, head.z, 0, 0);
dataWatcher.updateObject(8 , Integer.valueOf(encodeDouble(head.x)));
dataWatcher.updateObject(9 , Integer.valueOf(encodeDouble(head.y)));
protected void updateDataServer() {
dataWatcher.updateObject(8, Integer.valueOf(encodeDouble(head.x)));
dataWatcher.updateObject(9, Integer.valueOf(encodeDouble(head.y)));
dataWatcher.updateObject(10, Integer.valueOf(encodeDouble(head.z)));
dataWatcher.updateObject(11, Integer.valueOf(encodeDouble(tail.x)));
dataWatcher.updateObject(12, Integer.valueOf(encodeDouble(tail.y)));
dataWatcher.updateObject(13, Integer.valueOf(encodeDouble(tail.z)));
onUpdate();
dataWatcher.updateObject(14, Byte.valueOf((byte) (isVisible ? 1 : 0)));
}
public void setPositions(Position head, Position tail) {
this.head = head;
this.tail = tail;
setPositionAndRotation(head.x, head.y, head.z, 0, 0);
needsUpdate = true;
}
public void show() {
dataWatcher.updateObject(14, Byte.valueOf((byte) 1));
isVisible = true;
needsUpdate = true;
}
public void hide() {
dataWatcher.updateObject(14, Byte.valueOf((byte) 0));
isVisible = false;
needsUpdate = true;
}
public boolean isVisible() {
return dataWatcher.getWatchableObjectByte(14) == 0 ? false : true;
return this.isVisible;
}
public void setTexture(String texture) {
this.texture = texture;
dataWatcher.updateObject(16, texture);
}
public String getTexture() {
return texture;
}
public abstract String getTexture();
protected int encodeDouble(double d) {
return (int) (d * 8000);
return (int) (d * 8192);
}
protected double decodeDouble(int i) {
return (i / 8000D);
return (i / 8192D);
}
@Override
protected void entityInit() {}
//The read/write to nbt seem to be useless
@Override
protected void readEntityFromNBT(NBTTagCompound nbt) {
@ -201,4 +182,9 @@ public class EntityLaser extends Entity {
nbt.setDouble("tailY", tail.y);
nbt.setDouble("tailZ", tail.z);
}
//Workaround for the laser's posY loosing it's precision e.g 103.5 becomes 104
public Position renderOffset() {
return new Position(head.x - posX, head.y - posY, head.z - posZ);
}
}

View file

@ -4,6 +4,7 @@ import net.minecraft.src.World;
import buildcraft.api.core.Position;
public class EntityPowerLaser extends EntityLaser {
private String texture;
public EntityPowerLaser(World world) {
super(world);
@ -13,4 +14,31 @@ public class EntityPowerLaser extends EntityLaser {
super(world, head, tail);
}
@Override
protected void entityInit() {
super.entityInit();
dataWatcher.addObject(15, "");
}
@Override
public String getTexture() {
return texture;
}
public void setTexture(String texture) {
this.texture = texture;
needsUpdate = true;
}
@Override
protected void updateDataClient() {
super.updateDataClient();
texture = dataWatcher.getWatchableObjectString(15);
}
@Override
protected void updateDataServer() {
super.updateDataServer();
dataWatcher.updateObject(15, texture);
}
}

View file

@ -15,7 +15,7 @@ public class ItemRedstoneChipset extends ItemBuildCraft {
setHasSubtypes(true);
setMaxDamage(0);
setTabToDisplayOn(CreativeTabs.tabRedstone);
setCreativeTab(CreativeTabs.tabRedstone);
}
@SuppressWarnings({ "all" })
@ -40,7 +40,7 @@ public class ItemRedstoneChipset extends ItemBuildCraft {
return (new StringBuilder()).append(super.getItemName()).append(".").append(itemstack.getItemDamage()).toString();
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List itemList) {

View file

@ -8,7 +8,7 @@ public class ItemWrench extends ItemBuildCraft implements IToolWrench {
public ItemWrench(int i) {
super(i);
setTabToDisplayOn(CreativeTabs.tabTools);
setCreativeTab(CreativeTabs.tabTools);
}
@Override

View file

@ -83,7 +83,7 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
}
@Override
public Packet getAuxillaryInfoPacket() {
public Packet getDescriptionPacket() {
return new PacketTileUpdate(this).getPacket();
}

View file

@ -57,7 +57,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
drawTexturedModalRect(cornerX + x, cornerY + y, 16 * textureJ, 16 * textureI, 16, 16);
}
}
public void drawStack(ItemStack item) {
@ -165,7 +165,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
if (s.length() > 0) {
int i2 = (lastX - cornerX);
int k2 = lastY - cornerY;
func_74190_a(s, i2, k2);
drawCreativeTabHoveringText(s, i2, k2);
}
}

View file

@ -40,7 +40,7 @@ public class TransactorSimple extends Transactor {
if(inventory.getStackInSlot(i) == null)
continue;
if(!inventory.getStackInSlot(i).isItemEqual(stack))
if(!inventory.getStackInSlot(i).isItemEqual(stack) || !ItemStack.func_77970_a(inventory.getStackInSlot(i), stack))
continue;
if(inventory.getStackInSlot(i).stackSize >= inventory.getStackInSlot(i).getMaxStackSize())
@ -75,7 +75,7 @@ public class TransactorSimple extends Transactor {
return remaining;
}
if(!inventory.getStackInSlot(slot).isItemEqual(stack))
if(!inventory.getStackInSlot(slot).isItemEqual(stack) || !ItemStack.func_77970_a(inventory.getStackInSlot(slot), stack))
return 0;
int space = inventory.getStackInSlot(slot).getMaxStackSize() - inventory.getStackInSlot(slot).stackSize;

View file

@ -21,7 +21,7 @@ public interface ISynchronizedTile {
public Packet getUpdatePacket();
public Packet getAuxillaryInfoPacket();
public Packet getDescriptionPacket();
public PacketPayload getPacketPayload();
}

View file

@ -40,9 +40,9 @@ public class CoreProxy {
public String getMinecraftVersion() { return "1.3.2"; }
/* INSTANCES */
public Object getClient() { return null; }
public Object getClient() { return null; }
public World getClientWorld() { return null; }
/* SIMULATION */
public boolean isSimulating(World world) {
return !world.isRemote;
@ -63,7 +63,7 @@ public class CoreProxy {
/* WRAPPER */
public void feedSubBlocks(int id, CreativeTabs tab, List itemList) {}
/* LOCALIZATION */
public void addName(Object obj, String s) {}
public void addLocalization(String s1, String string) {}
@ -103,14 +103,14 @@ public class CoreProxy {
if (Math.abs(player.posX - x) <= maxDistance && Math.abs(player.posY - y) <= maxDistance
&& Math.abs(player.posZ - z) <= maxDistance)
player.serverForThisPlayer.sendPacketToPlayer(packet);
player.playerNetServerHandler.sendPacketToPlayer(packet);
}
}
}
public void sendToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) {
EntityPlayerMP player = (EntityPlayerMP) entityplayer;
player.serverForThisPlayer.sendPacketToPlayer(packet.getPacket());
player.playerNetServerHandler.sendPacketToPlayer(packet.getPacket());
}
public void sendToServer(Packet packet) {}

View file

@ -1,5 +1,6 @@
package buildcraft.core.render;
import buildcraft.api.core.Position;
import net.minecraft.src.Entity;
import net.minecraft.src.ModelBase;
import net.minecraft.src.ModelRenderer;
@ -38,7 +39,9 @@ public class RenderLaser extends Render {
GL11.glPushMatrix();
GL11.glDisable(2896 /* GL_LIGHTING */);
GL11.glTranslated(x, y, z);
Position offset = laser.renderOffset();
GL11.glTranslated(x + offset.x, y + offset.y, z + offset.z);
GL11.glRotatef((float) laser.angleZ, 0, 1, 0);
GL11.glRotatef((float) laser.angleY, 0, 0, 1);

View file

@ -68,28 +68,28 @@ public class Utils {
for(Orientations orientation : Orientations.values()) {
if(from.reverse() == orientation)
continue;
Position pos = new Position(x, y, z, orientation);
pos.moveForwards(1.0);
TileEntity tileInventory = world.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z);
ITransactor transactor = Transactor.getTransactorFor(tileInventory);
if(transactor != null
if(transactor != null && !(tileInventory instanceof TileBuildCraft)
&& transactor.add(stack, from, false).stackSize > 0)
possibleInventories.add(transactor);
}
if (possibleInventories.size() > 0) {
int choice = world.rand.nextInt(possibleInventories.size());
return possibleInventories.get(choice).add(stack, from, true);
}
ItemStack added = stack.copy();
added.stackSize = 0;
return added;
}
/**
* Depending on the kind of item in the pipe, set the floor at a different
* level to optimize graphical aspect.
@ -180,7 +180,7 @@ public class Utils {
public static void dropItems(World world, ItemStack stack, int i, int j, int k) {
if(stack.stackSize <= 0)
return;
float f1 = 0.7F;
double d = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D;
double d1 = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D;

View file

@ -1,8 +1,8 @@
/**
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
@ -18,7 +18,9 @@ import buildcraft.api.liquids.LiquidTank;
import buildcraft.core.DefaultProps;
import buildcraft.core.utils.Utils;
import buildcraft.energy.gui.ContainerEngine;
import net.minecraft.src.Block;
import net.minecraft.src.ICrafting;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
@ -125,7 +127,15 @@ public class EngineIron extends Engine {
super.update();
if (itemInInventory != null) {
LiquidStack liquid = LiquidManager.getLiquidForFilledItem(itemInInventory);
LiquidStack liquid = null;
if (Block.ice.blockID == itemInInventory.itemID && heat > COOLANT_THRESHOLD)
{
liquid = LiquidManager.getLiquidForFilledItem(new ItemStack(Item.bucketWater));
}
else
{
liquid = LiquidManager.getLiquidForFilledItem(itemInInventory);
}
if (liquid != null) {
if (fill(Orientations.Unknown, liquid, false) == liquid.amount) {
@ -190,7 +200,7 @@ public class EngineIron extends Engine {
coolantQty = nbttagcompound.getInteger("coolantQty");
heat = nbttagcompound.getInteger("heat");
penaltyCooling = nbttagcompound.getInteger("penaltyCooling");
if (nbttagcompound.hasKey("itemInInventory")) {
NBTTagCompound cpt = nbttagcompound.getCompoundTag("itemInInventory");
itemInInventory = ItemStack.loadItemStackFromNBT(cpt);
@ -206,8 +216,8 @@ public class EngineIron extends Engine {
nbttagcompound.setInteger("coolantId", coolantId);
nbttagcompound.setInteger("coolantQty", coolantQty);
nbttagcompound.setInteger("heat", heat);
nbttagcompound.setInteger("penaltyCooling", penaltyCooling);
nbttagcompound.setInteger("penaltyCooling", penaltyCooling);
if (itemInInventory != null) {
NBTTagCompound cpt = new NBTTagCompound();
itemInInventory.writeToNBT(cpt);
@ -272,10 +282,10 @@ public class EngineIron extends Engine {
public int getHeat() {
return heat;
}
/* ITANKCONTAINER */
public int fill(Orientations from, LiquidStack resource, boolean doFill) {
// Handle coolant
if (IronEngineCoolant.getCoolantForLiquid(resource) != null)
return fillCoolant(from, resource, doFill);
@ -337,7 +347,7 @@ public class EngineIron extends Engine {
new LiquidTank(coolantId, coolantQty, MAX_LIQUID) };
}
/* IINVENTORY */
@Override public int getSizeInventory() { return 1; }
@Override public ItemStack getStackInSlot(int i) { return itemInInventory; }

View file

@ -1,8 +1,8 @@
/**
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
@ -38,7 +38,7 @@ import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.Packet;
import net.minecraft.src.TileEntity;
//TODO: All Engines need to take func_48081_b into account
//TODO: All Engines need to take func_48081_b into account
public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInventory, ITankContainer, IEngineProvider,
IOverrideDefaultTriggers, IPipeConnection, IBuilderInventory {
@ -132,7 +132,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
progressPart = 0;
}
} else if (isRedstonePowered && engine.isActive()) {
Position pos = new Position(xCoord, yCoord, zCoord, engine.orientation);
pos.moveForwards(1.0);
TileEntity tile = worldObj.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z);
@ -148,7 +148,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
setActive(false);
} else
setActive(false);
} else
setActive(false);
@ -158,11 +158,11 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
private void setActive(boolean isActive) {
if(this.isActive == isActive)
return;
this.isActive = isActive;
sendNetworkUpdate();
}
private void createEngineIfNeeded() {
if (engine == null) {
int kind = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
@ -189,8 +189,8 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
engine.orientation = o;
}
orientation = o.ordinal();
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord));
break;
}
}
@ -321,10 +321,10 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
/* SMP UPDATING */
@Override
public Packet getAuxillaryInfoPacket() {
public Packet getDescriptionPacket() {
createEngineIfNeeded();
return super.getAuxillaryInfoPacket();
return super.getDescriptionPacket();
}
@Override
@ -466,7 +466,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain) {
return null;
}
@Override
public LiquidTank[] getTanks() {
if (engine == null) {

View file

@ -33,7 +33,7 @@ public class BlockAutoWorkbench extends BlockBuildCraft {
topTexture = 2 * 16 + 11;
sideTexture = 2 * 16 + 12;
setHardness(1.0F);
setCreativeTab(CreativeTabs.tabDeco);
setCreativeTab(CreativeTabs.tabDecorations);
}
@Override

View file

@ -20,7 +20,7 @@ public class BlockHopper extends BlockBuildCraft {
public BlockHopper(int blockId) {
super(blockId, Material.iron);
setHardness(5F);
setCreativeTab(CreativeTabs.tabDeco);
setCreativeTab(CreativeTabs.tabDecorations);
}
@Override

View file

@ -1,8 +1,8 @@
/**
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
@ -11,6 +11,8 @@ package buildcraft.factory;
import java.util.ArrayList;
import com.google.common.math.IntMath;
import buildcraft.BuildCraftFactory;
import buildcraft.api.core.Orientations;
import buildcraft.api.core.Position;
@ -57,6 +59,11 @@ public class BlockQuarry extends BlockMachineRoot {
new Position(i, j, k));
world.setBlockMetadataWithNotify(i, j, k, orientation.reverse().ordinal());
if (entityliving instanceof EntityPlayer)
{
TileQuarry tq = (TileQuarry) world.getBlockTileEntity(i,j,k);
tq.placedBy = (EntityPlayer) entityliving;
}
}
@Override
@ -125,46 +132,48 @@ public class BlockQuarry extends BlockMachineRoot {
world.setBlockMetadata(x, y, z, 1);
}
}
@Override
public void breakBlock(World world, int i, int j, int k, int par5, int par6) {
if (CoreProxy.proxy.isRenderWorld(world)){
if (!CoreProxy.proxy.isSimulating(world)){
return;
}
TileEntity tile = world.getBlockTileEntity(i, j, k);
if (tile instanceof TileQuarry){
TileQuarry quarry = (TileQuarry)tile;
Box box = quarry.box;
//X - Axis
for (int x = box.xMin; x <= box.xMax; x++) {
markFrameForDecay(world, x, box.yMin, box.zMin);
markFrameForDecay(world, x, box.yMax, box.zMin);
markFrameForDecay(world, x, box.yMin, box.zMax);
markFrameForDecay(world, x, box.yMax, box.zMax);
}
//Z - Axis
for (int z = box.zMin + 1; z <= box.zMax - 1; z++) {
markFrameForDecay(world, box.xMin, box.yMin, z);
markFrameForDecay(world, box.xMax, box.yMin, z);
markFrameForDecay(world, box.xMin, box.yMax, z);
markFrameForDecay(world, box.xMax, box.yMax, z);
}
//Y - Axis
for (int y = box.yMin + 1; y <= box.yMax -1; y++) {
markFrameForDecay(world, box.xMin, y, box.zMin);
markFrameForDecay(world, box.xMax, y, box.zMin);
markFrameForDecay(world, box.xMin, y, box.zMax);
markFrameForDecay(world, box.xMax, y, box.zMax);
if (box.isInitialized() && Integer.MAX_VALUE != box.xMax)
{
//X - Axis
for (int x = box.xMin; x <= box.xMax; x++) {
markFrameForDecay(world, x, box.yMin, box.zMin);
markFrameForDecay(world, x, box.yMax, box.zMin);
markFrameForDecay(world, x, box.yMin, box.zMax);
markFrameForDecay(world, x, box.yMax, box.zMax);
}
//Z - Axis
for (int z = box.zMin + 1; z <= box.zMax - 1; z++) {
markFrameForDecay(world, box.xMin, box.yMin, z);
markFrameForDecay(world, box.xMax, box.yMin, z);
markFrameForDecay(world, box.xMin, box.yMax, z);
markFrameForDecay(world, box.xMax, box.yMax, z);
}
//Y - Axis
for (int y = box.yMin + 1; y <= box.yMax -1; y++) {
markFrameForDecay(world, box.xMin, y, box.zMin);
markFrameForDecay(world, box.xMax, y, box.zMin);
markFrameForDecay(world, box.xMin, y, box.zMax);
markFrameForDecay(world, box.xMax, y, box.zMax);
}
}
quarry.destroy();
}
Utils.preDestroyBlock(world, i, j, k);
// byte width = 1;
@ -197,7 +206,7 @@ public class BlockQuarry extends BlockMachineRoot {
super.breakBlock(world, i, j, k, par5, par6);
}
@Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) {
TileQuarry tile = (TileQuarry) world.getBlockTileEntity(i, j, k);

View file

@ -11,6 +11,13 @@ package buildcraft.factory;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import com.google.common.collect.Sets;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import buildcraft.BuildCraftFactory;
import buildcraft.api.core.BuildCraftAPI;
@ -37,10 +44,16 @@ import buildcraft.core.utils.Utils;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.Block;
import net.minecraft.src.ChunkCoordIntPair;
import net.minecraft.src.EntityItem;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.Packet3Chat;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.ForgeChunkManager.Type;
public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, IPipeConnection, IBuilderInventory {
public @TileNetworkData
@ -109,6 +122,9 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
private boolean movingHorizontally;
private boolean movingVertically;
private double headTrajectory;
private Ticket chunkTicket;
public @TileNetworkData boolean isAlive;
public EntityPlayer placedBy;
private void createArm() {
@ -127,6 +143,16 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
@Override
public void updateEntity() {
if (!isAlive && CoreProxy.proxy.isSimulating(worldObj))
{
super.updateEntity();
return;
}
if (!CoreProxy.proxy.isSimulating(worldObj) && isAlive)
{
super.updateEntity();
return;
}
super.updateEntity();
if (inProcess) {
float energyToUse = 2 + powerProvider.getEnergyStored() / 1000;
@ -138,7 +164,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
}
}
if (CoreProxy.proxy.isSimulating(worldObj)) {
if (CoreProxy.proxy.isSimulating(worldObj) && inProcess) {
sendNetworkUpdate();
}
if (inProcess || !isDigging) {
@ -386,7 +412,6 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
}
private void mineStack(ItemStack stack) {
// First, try to add to a nearby chest
ItemStack added = Utils.addToRandomInventory(stack, worldObj, xCoord, yCoord, zCoord, Orientations.Unknown);
stack.stackSize -= added.stackSize;
@ -425,6 +450,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
@Override
public void invalidate() {
ForgeChunkManager.releaseTicket(chunkTicket);
super.invalidate();
destroy();
@ -456,6 +482,24 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
}
private void setBoundaries(boolean useDefault) {
if (chunkTicket == null)
{
chunkTicket = ForgeChunkManager.requestTicket(BuildCraftFactory.instance, worldObj, Type.NORMAL);
}
if (chunkTicket == null)
{
isAlive = false;
if (placedBy!=null && CoreProxy.proxy.isSimulating(worldObj))
{
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(String.format("[BUILDCRAFT] The quarry at %d, %d, %d will not work because there are no more chunkloaders available", xCoord, yCoord, zCoord)), (Player) placedBy);
}
sendNetworkUpdate();
return;
}
chunkTicket.getModData().setInteger("quarryX", xCoord);
chunkTicket.getModData().setInteger("quarryY", yCoord);
chunkTicket.getModData().setInteger("quarryZ", zCoord);
ForgeChunkManager.forceChunk(chunkTicket, new ChunkCoordIntPair(xCoord >> 4, zCoord >> 4));
IAreaProvider a = null;
@ -473,7 +517,12 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
int ySize = a.yMax() - a.yMin() + 1;
int zSize = a.zMax() - a.zMin() + 1;
if (xSize < 3 || zSize < 3) {
if (xSize < 3 || zSize < 3 || ((xSize * zSize) >> 8) >= chunkTicket.getMaxChunkListDepth())
{
if (placedBy != null)
{
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(String.format("Quarry size is outside of chunkloading bounds or too small %d %d (%d)", xSize, zSize, chunkTicket.getMaxChunkListDepth())),(Player) placedBy);
}
a = new DefaultAreaProvider(xCoord, yCoord, zCoord, xCoord + 10, yCoord + 4, zCoord + 10);
useDefault = true;
@ -519,10 +568,10 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
}
a.removeFromWorld();
forceChunkLoading(chunkTicket);
}
private void initializeBluePrintBuilder() {
BptBlueprint bluePrint = new BptBlueprint(box.sizeX(), box.sizeY(), box.sizeZ());
for (int i = 0; i < bluePrint.sizeX; ++i) {
@ -558,11 +607,18 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
@Override
public void postPacketHandling(PacketUpdate packet) {
super.postPacketHandling(packet);
createUtilsIfNeeded();
if (isAlive)
{
createUtilsIfNeeded();
}
else
{
box.deleteLasers();
box.reset();
return;
}
if (arm != null) {
arm.setHead(headPosX, headPosY, headPosZ);
arm.updatePosition();
@ -573,6 +629,11 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
public void initialize() {
super.initialize();
if (CoreProxy.proxy.isSimulating(this.worldObj) && !box.initialized)
{
setBoundaries(false);
}
createUtilsIfNeeded();
sendNetworkUpdate();
@ -738,4 +799,32 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
this.targetZ = z;
}
public void forceChunkLoading(Ticket ticket) {
if (chunkTicket == null)
{
chunkTicket = ticket;
}
Set<ChunkCoordIntPair> chunks = Sets.newHashSet();
isAlive = true;
ChunkCoordIntPair quarryChunk = new ChunkCoordIntPair(xCoord >> 4, zCoord >> 4);
chunks.add(quarryChunk);
ForgeChunkManager.forceChunk(ticket, quarryChunk);
for (int chunkX = box.xMin >> 4; chunkX <= box.xMax >> 4; chunkX ++)
{
for (int chunkZ = box.zMin >> 4; chunkZ <= box.zMax >> 4; chunkZ ++)
{
ChunkCoordIntPair chunk = new ChunkCoordIntPair(chunkX, chunkZ);
ForgeChunkManager.forceChunk(ticket, chunk);
chunks.add(chunk);
}
}
if (placedBy != null)
{
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(String.format("[BUILDCRAFT] The quarry at %d %d %d will keep %d chunks loaded",xCoord, yCoord, zCoord, chunks.size())),(Player) placedBy);
}
sendNetworkUpdate();
}
}

View file

@ -207,7 +207,9 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor {
assemblyTable.zCoord + 0.475 + (worldObj.rand.nextFloat() - 0.5) / 5F);
laser.setPositions(head, tail);
laser.show();
if(!laser.isVisible())
laser.show();
}
protected void removeLaser() {

View file

@ -32,7 +32,7 @@ public class ItemFacade extends ItemBuildCraft {
setHasSubtypes(true);
setMaxDamage(0);
this.setTabToDisplayOn(CreativeTabs.tabMisc);
this.setCreativeTab(CreativeTabs.tabMisc);
}
@Override
@ -77,8 +77,7 @@ public class ItemFacade extends ItemBuildCraft {
return true;
} else {
if (((TileGenericPipe)tile).addFacade(Orientations.values()[side], ItemFacade.getBlockId(stack.getItemDamage()), ItemFacade.getMetaData(stack.getItemDamage()))){
if (!player.capabilities.isCreativeMode)
stack.stackSize--;
stack.stackSize--;
return true;
}
return false;

View file

@ -21,7 +21,7 @@ public class ItemGate extends ItemBuildCraft {
setHasSubtypes(true);
setMaxDamage(0);
setTabToDisplayOn(CreativeTabs.tabRedstone);
setCreativeTab(CreativeTabs.tabRedstone);
}
@SuppressWarnings({ "all" })

View file

@ -21,16 +21,16 @@ import net.minecraft.src.World;
public class ItemPipe extends ItemBuildCraft implements IItemPipe {
Pipe dummyPipe;
private int textureIndex = 0;
protected ItemPipe(int i) {
super(i);
this.setTabToDisplayOn(CreativeTabs.tabTransport);
this.setCreativeTab(CreativeTabs.tabTransport);
}
@Override
public boolean tryPlaceIntoWorld(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int side, float par8, float par9, float par10) {
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int side, float par8, float par9, float par10) {
int blockID = BuildCraftTransport.genericPipeBlock.blockID;
if (world.getBlockId(i, j, k) == Block.snow.blockID)
@ -49,15 +49,15 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe {
if (side == 5)
i++;
}
if (itemstack.stackSize == 0)
return false;
if (entityplayer.canPlayerEdit(i, j, k)
&& world.canPlaceEntityOnSide(blockID, i, j, k, false, side, entityplayer)) {
Pipe pipe = BlockGenericPipe.createPipe(shiftedIndex);
if (BlockGenericPipe.placePipe(pipe, world, i, j, k, blockID, 0)) {
Block.blocksList[blockID].onBlockPlacedBy(world, i, j, k, entityplayer);
// To move to a proxt
// world.playSoundEffect((float)i + 0.5F, (float)j + 0.5F,
@ -75,7 +75,7 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe {
this.textureIndex = textureIndex;
return this;
}
public int getTextureIndex() {
return textureIndex;
}

View file

@ -94,7 +94,7 @@ public class PipeTransportItems extends PipeTransport {
((IPipeTransportItemsHook) container.pipe).entityEntered(item, orientation);
if (!worldObj.isRemote && item.getSynchroTracker().markTimeIfDelay(worldObj, 6 * BuildCraftCore.updateFactor)) {
int dimension = worldObj.provider.worldType;
int dimension = worldObj.provider.dimensionId;
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE, dimension, createItemPacket(item, orientation));
}

View file

@ -52,12 +52,12 @@ import net.minecraft.src.TileEntity;
public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITankContainer, IPipeEntry,
IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder, IPipeConnection, IDropControlInventory, IPipeRenderState,
ISyncedTile {
private class CoreState implements IClientState {
public int pipeId = -1;
public int gateKind = 0;
@Override
public void writeData(DataOutputStream data) throws IOException {
data.writeInt(pipeId);
@ -69,9 +69,9 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
pipeId = data.readInt();
gateKind = data.readInt();
}
}
private PipeRenderState renderState = new PipeRenderState();
private CoreState coreState = new CoreState();
@ -84,10 +84,10 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
private boolean blockNeighborChange = false;
private boolean refreshRenderState = false;
private boolean pipeBound = false;
private int[] facadeBlocks = new int[Orientations.dirs().length];
private int[] facadeMeta = new int[Orientations.dirs().length];
public TileGenericPipe() {
}
@ -101,7 +101,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
pipe.writeToNBT(nbttagcompound);
} else
nbttagcompound.setInteger("pipeId", coreState.pipeId);
for (int i = 0; i < Orientations.dirs().length; i++){
nbttagcompound.setInteger("facadeBlocks[" + i + "]", facadeBlocks[i]);
nbttagcompound.setInteger("facadeMeta[" + i + "]", facadeMeta[i]);
@ -112,14 +112,14 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
coreState.pipeId = nbttagcompound.getInteger("pipeId");
pipe = BlockGenericPipe.createPipe(coreState.pipeId);
if (pipe != null) {
pipe.readFromNBT(nbttagcompound);
}
for (int i = 0; i < Orientations.dirs().length; i++){
facadeBlocks[i] = nbttagcompound.getInteger("facadeBlocks[" + i + "]");
facadeMeta[i] = nbttagcompound.getInteger("facadeMeta[" + i + "]");
@ -149,10 +149,10 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
@Override
public void updateEntity() {
if (pipe == null)
return;
if (!initialized)
initialize(pipe);
@ -160,13 +160,13 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
return;
if (blockNeighborChange) {
computeConnections();
pipe.onNeighborBlockChange(0);
blockNeighborChange = false;
refreshRenderState = true;
}
if (refreshRenderState){
refreshRenderState();
refreshRenderState = false;
@ -183,21 +183,21 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
//PRECONDITION: worldObj must not be null
private void refreshRenderState() {
//Only done on server/SSP
if (worldObj.isRemote) return;
// Pipe connections;
for(Orientations o : Orientations.dirs()){
renderState.pipeConnectionMatrix.setConnected(o, this.pipeConnectionsBuffer[o.ordinal()]);
}
// Pipe Textures
renderState.setTextureFile(pipe.getTextureFile());
for(Orientations o: Orientations.values()){
renderState.textureMatrix.setTextureIndex(o, pipe.getTextureIndex(o));
}
// WireState
for (IPipe.WireColor color : IPipe.WireColor.values()){
renderState.wireMatrix.setWire(color, pipe.wireSet[color.ordinal()]);
@ -205,33 +205,33 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
renderState.wireMatrix.setWireConnected(color, direction, pipe.isWireConnectedTo(this.getTile(direction), color));
}
}
// Wire Textures
if (pipe.wireSet[IPipe.WireColor.Red.ordinal()]) {
renderState.wireMatrix.setTextureIndex(WireColor.Red, pipe.signalStrength[IPipe.WireColor.Red.ordinal()] > 0 ? 6 : 5);
} else {
renderState.wireMatrix.setTextureIndex(WireColor.Red, 0);
}
if (pipe.wireSet[IPipe.WireColor.Blue.ordinal()]) {
renderState.wireMatrix.setTextureIndex(WireColor.Blue, pipe.signalStrength[IPipe.WireColor.Blue.ordinal()] > 0 ? 8 : 7);
} else {
renderState.wireMatrix.setTextureIndex(WireColor.Blue, 0);
}
if (pipe.wireSet[IPipe.WireColor.Green.ordinal()]) {
renderState.wireMatrix.setTextureIndex(WireColor.Green, pipe.signalStrength[IPipe.WireColor.Green.ordinal()] > 0 ? 10 : 9);
} else {
renderState.wireMatrix.setTextureIndex(WireColor.Green, 0);
}
if (pipe.wireSet[IPipe.WireColor.Yellow.ordinal()]) {
renderState.wireMatrix.setTextureIndex(WireColor.Yellow, pipe.signalStrength[IPipe.WireColor.Yellow.ordinal()] > 0 ? 12 : 11);
} else {
renderState.wireMatrix.setTextureIndex(WireColor.Yellow, 0);
}
// Gate Textures
renderState.setHasGate(pipe.hasGate());
renderState.setGateTexture(!pipe.hasGate()?0:pipe.gate.getTexture(pipe.isGateActive()));
@ -246,19 +246,19 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
renderState.facadeMatrix.setTextureIndex(direction, block.getBlockTextureFromSideAndMetadata(direction.ordinal(), this.facadeMeta[direction.ordinal()]));
}
}
if (renderState.isDirty()){
worldObj.markBlockNeedsUpdate(this.xCoord, this.yCoord, this.zCoord);
renderState.clean();
}
}
public void initialize(Pipe pipe) {
this.pipe = pipe;
tileBuffer = new TileBuffer[6];
for (Orientations o : Orientations.dirs()) {
@ -283,21 +283,21 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
if (pipe != null)
pipe.initialize();
initialized = true;
}
private void bindPipe() {
if (!pipeBound && pipe != null) {
pipe.setTile(this);
coreState.pipeId = pipe.itemID;
pipeBound = true;
}
}
@Override
public IPipe getPipe() {
return pipe;
@ -342,16 +342,16 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
@Override
public void entityEntering(ItemStack payload, Orientations orientation) {
/* FIXME: This is untested guesswork */
Position itemPos = new Position(xCoord, yCoord, zCoord, orientation);
itemPos.moveBackwards(1.0);
itemPos.x += 0.5;
itemPos.y += 0.25;
itemPos.z += 0.5;
itemPos.moveForwards(0.5);
EntityPassiveItem pipedItem = new EntityPassiveItem(worldObj, itemPos.x, itemPos.y, itemPos.z, payload);
entityEntering(pipedItem, orientation);
}
@ -371,15 +371,15 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
initialize(BlockGenericPipe.createPipe(packet.getPipeId()));
}
renderState = packet.getRenderState();
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
}
return;
return;
}
@Override
public Packet getAuxillaryInfoPacket() {
public Packet getDescriptionPacket() {
bindPipe();
PacketTileState packet = new PacketTileState(this.xCoord, this.yCoord, this.zCoord);
if (pipe != null && pipe.gate != null){
coreState.gateKind = pipe.gate.kind.ordinal();
@ -496,7 +496,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
else
return false;
}
@Override
public void onChunkUnload() {
if (pipe != null){
@ -504,9 +504,9 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
}
}
/** ITankContainer implementation **/
@Override
public int fill(Orientations from, LiquidStack resource, boolean doFill) {
if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof ITankContainer)
@ -546,31 +546,31 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
else
return null;
}
public void scheduleRenderUpdate(){
refreshRenderState = true;
}
public boolean addFacade(Orientations direction, int blockid, int meta){
if (this.worldObj.isRemote) return false;
if (this.facadeBlocks[direction.ordinal()] == blockid) return false;
if (hasFacade(direction)){
dropFacade(direction);
}
this.facadeBlocks[direction.ordinal()] = blockid;
this.facadeMeta[direction.ordinal()] = meta;
scheduleRenderUpdate();
return true;
}
public boolean hasFacade(Orientations direction){
if (this.worldObj.isRemote) return false;
return (this.facadeBlocks[direction.ordinal()] != 0);
}
public void dropFacade(Orientations direction){
if (this.worldObj.isRemote) return;
if (!hasFacade(direction)) return;
@ -579,7 +579,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
this.facadeMeta[direction.ordinal()] = 0;
scheduleRenderUpdate();
}
/** IPipeRenderState implementation **/
@Override
@ -599,7 +599,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
@Override
public void afterStateUpdated(byte stateId) {
if (!worldObj.isRemote) return;
switch (stateId){
case 0:
if (pipe == null && coreState.pipeId != 0){
@ -613,9 +613,9 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
}
break;
}
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
}
@Override
public double getRenderDistance() {
return 24;