Pipes track the player that placed them now.

This commit is contained in:
SirSengir 2012-05-14 18:21:23 +02:00
parent a3b727aa9e
commit 73e04b24b1
3 changed files with 44 additions and 5 deletions

View file

@ -0,0 +1,11 @@
package net.minecraft.src.buildcraft.core.utils;
import net.minecraft.src.EntityPlayer;
public interface IOwnable {
String getOwnerName();
void setOwner(EntityPlayer player);
}

View file

@ -18,6 +18,7 @@ import net.minecraft.src.BlockContainer;
import net.minecraft.src.BuildCraftCore;
import net.minecraft.src.BuildCraftTransport;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IBlockAccess;
import net.minecraft.src.Item;
@ -299,6 +300,18 @@ public class BlockGenericPipe extends BlockContainer implements
pipe.onBlockPlaced();
}
@Override
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving) {
if(APIProxy.isClient(world))
return;
TileGenericPipe tile = (TileGenericPipe)world.getBlockTileEntity(i, j, k);
if(entityliving instanceof EntityPlayer)
tile.setOwner((EntityPlayer)entityliving);
}
@Override
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) {
super.blockActivated(world, i, j, k, entityplayer);

View file

@ -47,10 +47,12 @@ import net.minecraft.src.buildcraft.core.network.PacketPayload;
import net.minecraft.src.buildcraft.core.network.PacketPipeDescription;
import net.minecraft.src.buildcraft.core.network.PacketTileUpdate;
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
import net.minecraft.src.buildcraft.core.utils.IOwnable;
public class TileGenericPipe extends TileEntity implements IPowerReceptor,
ILiquidContainer, ISpecialInventory, IPipeEntry, ISynchronizedTile,
IOverrideDefaultTriggers, ITileBufferHolder, IPipeConnection, IDropControlInventory {
IOverrideDefaultTriggers, ITileBufferHolder, IPipeConnection, IDropControlInventory,
IOwnable {
public TileBuffer [] tileBuffer;
public boolean [] pipeConnectionsBuffer = new boolean [6];
@ -63,14 +65,13 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor,
@TileNetworkData public int pipeId = -1;
public TileGenericPipe () {
}
public TileGenericPipe () {}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
nbttagcompound.setString("owner", owner);
if (pipe != null) {
nbttagcompound.setInteger("pipeId", pipe.itemID);
pipe.writeToNBT(nbttagcompound);
@ -81,8 +82,9 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor,
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
if(nbttagcompound.hasKey("owner"))
owner = nbttagcompound.getString("owner");
pipe = BlockGenericPipe.createPipe(nbttagcompound.getInteger("pipeId"));
if (pipe != null) {
pipe.setTile(this);
pipe.readFromNBT(nbttagcompound);
@ -115,6 +117,19 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor,
public boolean initialized = false;
/// OWNERSHIP
private String owner;
@Override
public String getOwnerName() {
return owner;
}
@Override
public void setOwner(EntityPlayer player) {
owner = player.username;
}
/// UPDATING
@Override
public void updateEntity () {
if (!initialized) {