Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alcatrazEscapee committed Jun 19, 2018
1 parent 71c0aff commit 826d2e5
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 261 deletions.
3 changes: 0 additions & 3 deletions src/main/java/net/dries007/tfc/TerraFirmaCraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ public void preInit(FMLPreInitializationEvent event)
int id = 0;
network.registerMessage(ChunkDataMessage.Handler.class, ChunkDataMessage.class, ++id, Side.CLIENT);
ChunkCapabilityHandler.preInit();
// For world item rendering
//network.registerMessage(PacketUpdateWorldItem.Handler.class, PacketUpdateWorldItem.class, ++id, Side.CLIENT);
//network.registerMessage(PacketRequestWorldItem.Handler.class, PacketRequestWorldItem.class, ++id, Side.SERVER);

CalenderTFC.reload();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ public class TESRWorldItem extends TileEntitySpecialRenderer<TEWorldItem>
@Override
public void render(TEWorldItem te, double x, double y, double z, float partialTicks, int destroyStage, float alpha){
ItemStack stack = te.inventory.getStackInSlot(0);
//if (stack.isEmpty())
//{
// TerraFirmaCraft.getNetwork().sendToServer(new PacketRequestWorldItem(te));
// return;
//}
GlStateManager.pushMatrix();
//GlStateManager.translate((i % 2 == 0 ? 1 : 0), 0, (i < 2 ? 1 : 0));
//GlStateManager.rotate(timeD, 0, 1, 0);
Expand Down
75 changes: 0 additions & 75 deletions src/main/java/net/dries007/tfc/network/PacketRequestWorldItem.java

This file was deleted.

73 changes: 0 additions & 73 deletions src/main/java/net/dries007/tfc/network/PacketUpdateWorldItem.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class BlockWorldItem extends Block implements ITileEntityProvider
{
private static final AxisAlignedBB AABB = new AxisAlignedBB(0.25D, 0D, 0.25D, 0.75D, 0.0625D, 0.75D);

public BlockWorldItem()
BlockWorldItem()
{
super(Material.CIRCUITS);
setDefaultState(blockState.getBaseState());
Expand Down Expand Up @@ -101,10 +101,7 @@ public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
TEWorldItem te = (TEWorldItem) worldIn.getTileEntity(pos);
if (te == null) return true;
te.inventory.setStackInSlot(0, playerIn.getHeldItem(hand).copy());
//worldIn.setBlockToAir(pos);
worldIn.setBlockToAir(pos);
return true;
}
}
109 changes: 15 additions & 94 deletions src/main/java/net/dries007/tfc/objects/te/TEWorldItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,9 @@
@MethodsReturnNonnullByDefault
public class TEWorldItem extends TileEntity
{
public ItemStackHandler inventory = new ItemStackHandler(1);/*{
@Override
protected void onContentsChanged(int slot) {
if (!world.isRemote) {
TerraFirmaCraft.getNetwork().sendToAllAround(new PacketUpdateWorldItem(TEWorldItem.this),
new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 32));
}
}
};*/
public ItemStackHandler inventory = new ItemStackHandler(1);

public static final ResourceLocation ID = new ResourceLocation(MOD_ID, "world_item");
//private ItemStack item = ItemStack.EMPTY;

public TEWorldItem()
{
Expand All @@ -52,45 +43,18 @@ public void onBreakBlock()
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), inventory.getStackInSlot(0));
}

/*public void setItem(ItemStack item){
this.item = item;
//updateBlock(doMarkDirty);
if(!world.isRemote)
{
this.markDirty();
TerraFirmaCraft.getNetwork().sendToAllAround(new PacketUpdateWorldItem(this),
new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 64));
}
}*/

/*public void setItem(){
}*/

/*public ItemStack getItem(){
//if(item == ItemStack.EMPTY)
// updateBlock(false);
return item;
}*/

@Override
public void readFromNBT(NBTTagCompound compound)
{
inventory.deserializeNBT(compound.getCompoundTag("inventory"));
super.readFromNBT(compound);
//ItemStack stack = new ItemStack(compound.getCompoundTag("Item"));
//TerraFirmaCraft.getLog().debug("Trying to load state + "+compound.getCompoundTag("Item")+" and "+stack.getDisplayName());
//if(stack != null && !stack.isEmpty())
// setItem(stack);
}

@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound)
{
compound.setTag("inventory", inventory.serializeNBT());
return super.writeToNBT(compound);
//compound.setTag("Item", item.writeToNBT(new NBTTagCompound()));
//return compound;
}

@Override
Expand All @@ -101,17 +65,15 @@ public double getMaxRenderDistanceSquared()
}

@Override
public void onLoad(){
//if (world.isRemote) {
// TerraFirmaCraft.getNetwork().sendToServer(new PacketRequestWorldItem(this));
//}
// updateBlock(false);
}

public NBTTagCompound getUpdatePacketTag(NBTTagCompound nbt)
public NBTTagCompound getUpdateTag()
{
nbt.setTag("inventory", inventory.serializeNBT());
return nbt;
// The tag from this method is used for the initial chunk packet, and it needs to have the TE position!
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("x", this.getPos().getX());
nbt.setInteger("y", this.getPos().getY());
nbt.setInteger("z", this.getPos().getZ());
return getUpdatePacketTag(nbt);

}

@Override
Expand All @@ -127,19 +89,10 @@ public SPacketUpdateTileEntity getUpdatePacket()
}

@Override
public NBTTagCompound getUpdateTag()
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()
{
// The tag from this method is used for the initial chunk packet,
// and it needs to have the TE position!
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("x", this.getPos().getX());
nbt.setInteger("y", this.getPos().getY());
nbt.setInteger("z", this.getPos().getZ());
getUpdatePacketTag(nbt);
//nbt.setTag("inventory", inventory.serializeNBT());

// Add the per-block data to the tag
return nbt;
return new AxisAlignedBB(getPos(), getPos().add(1D, 1D, 1D));
}

@Override
Expand All @@ -155,43 +108,11 @@ public void handleUpdateTag(NBTTagCompound tag)
{
inventory.deserializeNBT(tag.getCompoundTag("inventory"));
}
//TerraFirmaCraft.getLog().debug("Got update packet!");
}

/*public void updateBlock(boolean doMarkDirty)
{
if(world == null) return;
IBlockState state = world.getBlockState(pos);
world.notifyBlockUpdate(pos, state, state, 2); // sync TE
if(doMarkDirty)
markDirty();
}*/

/*@Nullable
@Override
public SPacketUpdateTileEntity getUpdatePacket()
{
return new SPacketUpdateTileEntity(pos, 127, getUpdateTag());
}
@Override
public NBTTagCompound getUpdateTag()
{
return item.writeToNBT(new NBTTagCompound());
}

@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
private NBTTagCompound getUpdatePacketTag(NBTTagCompound nbt)
{
//readFromNBT(pkt.getNbtCompound());
setItem(new ItemStack(pkt.getNbtCompound()));
//updateBlock();
}*/

@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()
{
return new AxisAlignedBB(getPos(), getPos().add(1D, 1D, 1D));//TODO:see block bounding box method
nbt.setTag("inventory", inventory.serializeNBT());
return nbt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,10 @@ private void generateRock(World world, BlockPos pos, @Nullable VeinType vein, Ro
IBlockState stateAt = world.getBlockState(pos.down());
if (world.isAirBlock(pos) && stateAt.isFullCube())
{
// todo: replace this with actual ore stone blocks
// ores are gotten from vein.oreSpawnData.ore
// the current rock can be gotten from the rock
world.setBlockState(pos, BlocksTFC.WORLD_ITEM.getDefaultState(),2);
TEWorldItem tile = (TEWorldItem) world.getTileEntity(pos);
if(tile != null)
tile.inventory.setStackInSlot(0, vein == null ? ItemRock.get(rock, 1) : ItemSmallOre.get(vein.oreSpawnData.ore, 1));
//TerraFirmaCraft.getNetwork().sendToAllAround(new PacketUpdateWorldItem(tile),
// new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 32));
//world.setBlockState(pos, vein == null ? BlockRockVariant.get(rock, Rock.Type.RAW).getDefaultState() : BlockOreTFC.get(vein.oreSpawnData.ore, Rock.ANDESITE, Ore.Grade.NORMAL), 2);
}
}

Expand Down

0 comments on commit 826d2e5

Please sign in to comment.