pre-fix for guis, large chests

This commit is contained in:
Sen 2025-07-14 17:01:04 +02:00
parent ab3bc0407c
commit 2e43f24e23
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
99 changed files with 756 additions and 3619 deletions

View file

@ -1,6 +1,7 @@
package common.block.tech;
import common.block.Rotatable;
import common.block.Block;
import common.block.BlockFalling;
import common.block.Material;
import common.entity.item.EntityFalling;
@ -15,7 +16,6 @@ import common.model.ModelProvider;
import common.model.ModelRotation;
import common.model.Transforms;
import common.properties.Property;
import common.tileentity.IInteractionObject;
import common.util.BlockPos;
import common.util.ExtMath;
import common.util.Facing;
@ -78,7 +78,7 @@ public class BlockAnvil extends BlockFalling implements Rotatable
{
if (!worldIn.client)
{
playerIn.displayGui(new BlockAnvil.Anvil(worldIn, pos));
playerIn.connection.show(new Anvil(worldIn, pos));
}
return true;
@ -144,7 +144,7 @@ public class BlockAnvil extends BlockFalling implements Rotatable
.rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
public static class Anvil implements IInteractionObject
public class Anvil implements InteractionObject
{
private final World world;
private final BlockPos position;
@ -155,29 +155,14 @@ public class BlockAnvil extends BlockFalling implements Rotatable
this.position = pos;
}
public String getName()
{
return "anvil";
}
public boolean hasCustomName()
{
return false;
}
public String getCommandName()
{
return "Amboss";
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
return new ContainerRepair(playerInventory, this.world, this.position);
}
public String getGuiID()
public Block getBlock()
{
return "anvil";
return BlockAnvil.this;
}
}
}

View file

@ -1,140 +0,0 @@
package common.block.tech;
import common.block.Block;
import common.block.BlockContainer;
import common.block.Material;
import common.entity.npc.EntityNPC;
import common.item.CheatTab;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityBeacon;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import common.world.World;
public class BlockBeacon extends BlockContainer
{
private static final Model beacon = ModelProvider.getModelProvider().getModel("glass")
.add(0, 0, 0, 16, 16, 16)
.d().uv(0, 0, 16, 16).noCull()
.u().uv(0, 0, 16, 16).noCull()
.n().uv(0, 0, 16, 16).noCull()
.s().uv(0, 0, 16, 16).noCull()
.w().uv(0, 0, 16, 16).noCull()
.e().uv(0, 0, 16, 16).noCull()
.add(2, 0.1f, 2, 14, 3, 14)
.d("obsidian").uv(2, 2, 14, 14).noCull()
.u("obsidian").uv(2, 2, 14, 14).noCull()
.n("obsidian").uv(2, 13, 14, 16).noCull()
.s("obsidian").uv(2, 13, 14, 16).noCull()
.w("obsidian").uv(2, 13, 14, 16).noCull()
.e("obsidian").uv(2, 13, 14, 16).noCull()
.add(3, 3, 3, 13, 14, 13)
.d("beacon").uv(3, 3, 13, 13).noCull()
.u("beacon").uv(3, 3, 13, 13).noCull()
.n("beacon").uv(3, 2, 13, 13).noCull()
.s("beacon").uv(3, 2, 13, 13).noCull()
.w("beacon").uv(3, 2, 13, 13).noCull()
.e("beacon").uv(3, 2, 13, 13).noCull()
;
public BlockBeacon()
{
super(Material.TRANSLUCENT);
this.setHardness(3.0F);
this.setTab(CheatTab.TECHNOLOGY);
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity()
{
return new TileEntityBeacon();
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
{
if (worldIn.client)
{
return true;
}
else
{
// TileEntity tileentity = worldIn.getTileEntity(pos);
//
// if (tileentity instanceof TileEntityBeacon)
// {
// playerIn.displayGUIChest((TileEntityBeacon)tileentity);
//// playerIn.triggerAchievement(StatRegistry.beaconStat);
// }
return true;
}
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
// public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer, ItemStack stack)
// {
// super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
//
// if (stack.hasDisplayName())
// {
// TileEntity tileentity = worldIn.getTileEntity(pos);
//
// if (tileentity instanceof TileEntityBeacon)
// {
// ((TileEntityBeacon)tileentity).setName(stack.getDisplayName());
// }
// }
// }
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityBeacon)
{
((TileEntityBeacon)tileentity).updateBeacon();
// worldIn.addBlockEvent(pos, this, 1, 0);
}
}
public BlockLayer getBlockLayer()
{
return BlockLayer.CUTOUT;
}
public Model getModel(ModelProvider provider, String name, State state) {
return beacon;
}
}

View file

@ -6,13 +6,11 @@ import common.block.BlockContainer;
import common.block.Material;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.init.Items;
import common.inventory.Container;
import common.inventory.InventoryHelper;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.block.ItemSmallBlock;
import common.model.BlockLayer;
import common.model.Model;
@ -429,7 +427,7 @@ public class BlockBrewingStand extends BlockContainer
if (tileentity instanceof TileEntityBrewingStand)
{
playerIn.displayGUIChest((TileEntityBrewingStand)tileentity);
playerIn.connection.show((TileEntityBrewingStand)tileentity);
// playerIn.triggerAchievement(StatRegistry.brewingStat);
}
@ -437,22 +435,6 @@ public class BlockBrewingStand extends BlockContainer
}
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer, ItemStack stack)
{
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityBrewingStand)
{
((TileEntityBrewingStand)tileentity).setName(stack.getDisplayName());
}
}
}
public void randomDisplayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
{
double d0 = (double)((float)pos.getX() + 0.4F + rand.floatv() * 0.2F);

View file

@ -1,8 +1,8 @@
package common.block.tech;
import common.block.Block;
import common.block.BlockContainer;
import common.block.Rotatable;
import common.block.SoundType;
import common.block.Material;
import common.color.TextColor;
import common.entity.Entity;
@ -14,43 +14,37 @@ import common.init.SoundEvent;
import common.inventory.Container;
import common.inventory.IInventory;
import common.inventory.InventoryHelper;
import common.inventory.InventoryLargeChest;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.block.ItemChest;
import common.packet.SPacketSoundEffect;
import common.properties.Property;
import common.tileentity.ILockableContainer;
import common.tileentity.Passcode;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.ExtMath;
import common.util.Facing;
import common.vars.Vars;
import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockChest extends BlockContainer implements Rotatable
{
public final int chestType;
private final int capacity;
public BlockChest(int type)
public BlockChest(int capacity)
{
super(Material.WOOD);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
this.chestType = type;
this.capacity = capacity * 27;
this.setTab(CheatTab.TECHNOLOGY);
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
this.setHardness(2.5F);
this.setStepSound(SoundType.WOOD);
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
@ -61,113 +55,18 @@ public class BlockChest extends BlockContainer implements Rotatable
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 2;
}
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
{
if (worldIn.getState(pos.north()).getBlock() == this)
{
this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F);
}
else if (worldIn.getState(pos.south()).getBlock() == this)
{
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F);
}
else if (worldIn.getState(pos.west()).getBlock() == this)
{
this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
}
else if (worldIn.getState(pos.east()).getBlock() == this)
{
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F);
}
else
{
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
}
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
this.checkForSurroundingChests(worldIn, pos, state);
for (Facing enumfacing : Facing.Plane.HORIZONTAL)
{
BlockPos blockpos = pos.offset(enumfacing);
State iblockstate = worldIn.getState(blockpos);
if (iblockstate.getBlock() == this)
{
this.checkForSurroundingChests(worldIn, blockpos, iblockstate);
}
}
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{
return this.getState().withProperty(FACING, placer.getHorizontalFacing());
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer, ItemStack stack)
{
Facing enumfacing = Facing.getHorizontal(ExtMath.floord((double)(placer.rotYaw * 4.0F / 360.0F) + 0.5D) & 3).getOpposite();
state = state.withProperty(FACING, enumfacing);
BlockPos blockpos = pos.north();
BlockPos blockpos1 = pos.south();
BlockPos blockpos2 = pos.west();
BlockPos blockpos3 = pos.east();
boolean flag = this == worldIn.getState(blockpos).getBlock();
boolean flag1 = this == worldIn.getState(blockpos1).getBlock();
boolean flag2 = this == worldIn.getState(blockpos2).getBlock();
boolean flag3 = this == worldIn.getState(blockpos3).getBlock();
if (!flag && !flag1 && !flag2 && !flag3)
{
worldIn.setState(pos, state, 3);
}
else if (enumfacing.getAxis() != Facing.Axis.X || !flag && !flag1)
{
if (enumfacing.getAxis() == Facing.Axis.Z && (flag2 || flag3))
{
if (flag2)
{
worldIn.setState(blockpos2, state, 3);
}
else
{
worldIn.setState(blockpos3, state, 3);
}
worldIn.setState(pos, state, 3);
}
}
else
{
if (flag)
{
worldIn.setState(blockpos, state, 3);
}
else
{
worldIn.setState(blockpos1, state, 3);
}
worldIn.setState(pos, state, 3);
}
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
@ -179,107 +78,6 @@ public class BlockChest extends BlockContainer implements Rotatable
}
}
public State checkForSurroundingChests(World worldIn, BlockPos pos, State state)
{
if (worldIn.client)
{
return state;
}
else
{
State iblockstate = worldIn.getState(pos.north());
State iblockstate1 = worldIn.getState(pos.south());
State iblockstate2 = worldIn.getState(pos.west());
State iblockstate3 = worldIn.getState(pos.east());
Facing enumfacing = (Facing)state.getValue(FACING);
Block block = iblockstate.getBlock();
Block block1 = iblockstate1.getBlock();
Block block2 = iblockstate2.getBlock();
Block block3 = iblockstate3.getBlock();
if (block != this && block1 != this)
{
boolean flag = block.isFullBlock();
boolean flag1 = block1.isFullBlock();
if (block2 == this || block3 == this)
{
BlockPos blockpos1 = block2 == this ? pos.west() : pos.east();
State iblockstate6 = worldIn.getState(blockpos1.north());
State iblockstate7 = worldIn.getState(blockpos1.south());
enumfacing = Facing.SOUTH;
Facing enumfacing2;
if (block2 == this)
{
enumfacing2 = (Facing)iblockstate2.getValue(FACING);
}
else
{
enumfacing2 = (Facing)iblockstate3.getValue(FACING);
}
if (enumfacing2 == Facing.NORTH)
{
enumfacing = Facing.NORTH;
}
Block block6 = iblockstate6.getBlock();
Block block7 = iblockstate7.getBlock();
if ((flag || block6.isFullBlock()) && !flag1 && !block7.isFullBlock())
{
enumfacing = Facing.SOUTH;
}
if ((flag1 || block7.isFullBlock()) && !flag && !block6.isFullBlock())
{
enumfacing = Facing.NORTH;
}
}
}
else
{
BlockPos blockpos = block == this ? pos.north() : pos.south();
State iblockstate4 = worldIn.getState(blockpos.west());
State iblockstate5 = worldIn.getState(blockpos.east());
enumfacing = Facing.EAST;
Facing enumfacing1;
if (block == this)
{
enumfacing1 = (Facing)iblockstate.getValue(FACING);
}
else
{
enumfacing1 = (Facing)iblockstate1.getValue(FACING);
}
if (enumfacing1 == Facing.WEST)
{
enumfacing = Facing.WEST;
}
Block block4 = iblockstate4.getBlock();
Block block5 = iblockstate5.getBlock();
if ((block2.isFullBlock() || block4.isFullBlock()) && !block3.isFullBlock() && !block5.isFullBlock())
{
enumfacing = Facing.EAST;
}
if ((block3.isFullBlock() || block5.isFullBlock()) && !block2.isFullBlock() && !block4.isFullBlock())
{
enumfacing = Facing.WEST;
}
}
state = state.withProperty(FACING, enumfacing);
worldIn.setState(pos, state, 3);
return state;
}
}
public State correctFacing(World worldIn, BlockPos pos, State state)
{
Facing enumfacing = null;
@ -332,91 +130,6 @@ public class BlockChest extends BlockContainer implements Rotatable
}
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
int i = 0;
BlockPos blockpos = pos.west();
BlockPos blockpos1 = pos.east();
BlockPos blockpos2 = pos.north();
BlockPos blockpos3 = pos.south();
if (worldIn.getState(blockpos).getBlock() == this)
{
if (this.isDoubleChest(worldIn, blockpos))
{
return false;
}
++i;
}
if (worldIn.getState(blockpos1).getBlock() == this)
{
if (this.isDoubleChest(worldIn, blockpos1))
{
return false;
}
++i;
}
if (worldIn.getState(blockpos2).getBlock() == this)
{
if (this.isDoubleChest(worldIn, blockpos2))
{
return false;
}
++i;
}
if (worldIn.getState(blockpos3).getBlock() == this)
{
if (this.isDoubleChest(worldIn, blockpos3))
{
return false;
}
++i;
}
return i <= 1;
}
private boolean isDoubleChest(World worldIn, BlockPos pos)
{
if (worldIn.getState(pos).getBlock() != this)
{
return false;
}
else
{
for (Facing enumfacing : Facing.Plane.HORIZONTAL)
{
if (worldIn.getState(pos.offset(enumfacing)).getBlock() == this)
{
return true;
}
}
return false;
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityChest)
{
tileentity.updateContainingBlockInfo();
}
}
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
@ -438,135 +151,47 @@ public class BlockChest extends BlockContainer implements Rotatable
}
else
{
ILockableContainer ilockablecontainer = this.getLockableContainer(worldIn, pos);
TileEntityChest chest = this.getChest(worldIn, pos);
if (ilockablecontainer != null)
if (chest != null)
{
ItemStack stack = Vars.locking ? playerIn.getHeldItem() : null;
if(stack != null && stack.getItem() == Items.key) {
if(ilockablecontainer.isLocked()) {
if(stack.hasDisplayName() && stack.getDisplayName().equals(ilockablecontainer.getLockCode().code())) {
ilockablecontainer.setLockCode(Passcode.EMPTY_CODE);
// playerIn.triggerAchievement(StatRegistry.chestUnlockedStat);
playerIn.connection.addHotbar(TextColor.BLUE + "%s wurde entriegelt", ilockablecontainer.getCommandName());
if(chest.getLockCode() != null) {
if(stack.hasDisplayName() && stack.getDisplayName().equals(chest.getLockCode())) {
chest.setLockCode(null);
playerIn.connection.addHotbar(TextColor.BLUE + "%s wurde entriegelt", chest.getName());
playerIn.connection.sendPacket(new SPacketSoundEffect(SoundEvent.DOOR, playerIn.posX, playerIn.posY, playerIn.posZ, 1.0F));
return true;
}
}
else if(stack.hasDisplayName()) {
ilockablecontainer.setLockCode(new Passcode(stack.getDisplayName()));
// playerIn.triggerAchievement(StatRegistry.chestLockedStat);
playerIn.connection.addHotbar(TextColor.ORANGE + "%s wurde verriegelt", ilockablecontainer.getCommandName());
else if(stack.hasDisplayName() && !stack.getDisplayName().isEmpty()) {
chest.setLockCode(stack.getDisplayName());
playerIn.connection.addHotbar(TextColor.ORANGE + "%s wurde verriegelt", chest.getName());
playerIn.connection.sendPacket(new SPacketSoundEffect(SoundEvent.DOOR, playerIn.posX, playerIn.posY, playerIn.posZ, 1.0F));
return true;
}
}
playerIn.displayGUIChest(ilockablecontainer);
// if (this.chestType == 0)
// {
// playerIn.triggerAchievement(StatRegistry.chestOpenedStat);
// }
// else if (this.chestType == 1)
// {
// playerIn.triggerAchievement(StatRegistry.trapChestStat);
// }
playerIn.connection.show(chest);
}
return true;
}
}
public ILockableContainer getLockableContainer(World worldIn, BlockPos pos)
public TileEntityChest getChest(World worldIn, BlockPos pos)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (!(tileentity instanceof TileEntityChest))
{
if (!(tileentity instanceof TileEntityChest chest))
return null;
}
else
{
ILockableContainer ilockablecontainer = (TileEntityChest)tileentity;
if (this.isBlocked(worldIn, pos))
{
return null;
}
else
{
for (Facing enumfacing : Facing.Plane.HORIZONTAL)
{
BlockPos blockpos = pos.offset(enumfacing);
Block block = worldIn.getState(blockpos).getBlock();
if (block == this)
{
if (this.isBlocked(worldIn, blockpos))
{
return null;
}
TileEntity tileentity1 = worldIn.getTileEntity(blockpos);
if (tileentity1 instanceof TileEntityChest)
{
if (enumfacing != Facing.WEST && enumfacing != Facing.NORTH)
{
ilockablecontainer = new InventoryLargeChest("Große Truhe", (TileEntityChest)ilockablecontainer, (TileEntityChest)tileentity1);
}
else
{
ilockablecontainer = new InventoryLargeChest("Große Truhe", (TileEntityChest)tileentity1, (TileEntityChest)ilockablecontainer);
}
}
}
}
return ilockablecontainer;
}
}
if (this.isBlocked(worldIn, pos))
return null;
return chest;
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity()
{
return new TileEntityChest();
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return this.chestType == 1;
}
public int getWeakPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side)
{
if (!this.canProvidePower())
{
return 0;
}
else
{
int i = 0;
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityChest)
{
i = ((TileEntityChest)tileentity).numPlayersUsing;
}
return ExtMath.clampi(i, 0, 15);
}
}
public int getStrongPower(IWorldAccess worldIn, BlockPos pos, State state, Facing side)
{
return side == Facing.UP ? this.getWeakPower(worldIn, pos, state, side) : 0;
return new TileEntityChest(this.capacity);
}
private boolean isBlocked(World worldIn, BlockPos pos)
@ -601,7 +226,7 @@ public class BlockChest extends BlockContainer implements Rotatable
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
return Container.calcRedstoneFromInventory(this.getLockableContainer(worldIn, pos));
return Container.calcRedstoneFromInventory(this.getChest(worldIn, pos));
}
protected Property[] getProperties()

View file

@ -110,7 +110,7 @@ public class BlockDispenser extends BlockContainer implements Directional
if (tileentity instanceof TileEntityDispenser)
{
playerIn.displayGUIChest((TileEntityDispenser)tileentity);
playerIn.connection.show((TileEntityDispenser)tileentity);
// if (tileentity instanceof TileEntityDropper)
// {
@ -204,24 +204,6 @@ public class BlockDispenser extends BlockContainer implements Directional
return this.getState().withProperty(FACING, BlockPistonBase.getFacingFromEntity(worldIn, pos, placer)).withProperty(TRIGGERED, Boolean.valueOf(false));
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer, ItemStack stack)
{
worldIn.setState(pos, state.withProperty(FACING, BlockPistonBase.getFacingFromEntity(worldIn, pos, placer)), 2);
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityDispenser)
{
((TileEntityDispenser)tileentity).setCustomName(stack.getDisplayName());
}
}
}
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);

View file

@ -0,0 +1,62 @@
package common.block.tech;
import common.block.Material;
import common.item.CheatTab;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.tileentity.TileEntity;
import common.tileentity.DeviceEffectGenerator;
import common.world.State;
public class BlockEffectGenerator extends BlockMachine {
private static final Model MODEL = ModelProvider.getModelProvider().getModel("glass")
.add(0, 0, 0, 16, 16, 16)
.d().uv(0, 0, 16, 16).noCull()
.u().uv(0, 0, 16, 16).noCull()
.n().uv(0, 0, 16, 16).noCull()
.s().uv(0, 0, 16, 16).noCull()
.w().uv(0, 0, 16, 16).noCull()
.e().uv(0, 0, 16, 16).noCull()
.add(2, 0.1f, 2, 14, 3, 14)
.d("obsidian").uv(2, 2, 14, 14).noCull()
.u("obsidian").uv(2, 2, 14, 14).noCull()
.n("obsidian").uv(2, 13, 14, 16).noCull()
.s("obsidian").uv(2, 13, 14, 16).noCull()
.w("obsidian").uv(2, 13, 14, 16).noCull()
.e("obsidian").uv(2, 13, 14, 16).noCull()
.add(3, 3, 3, 13, 14, 13)
.d("effect_generator").uv(3, 3, 13, 13).noCull()
.u("effect_generator").uv(3, 3, 13, 13).noCull()
.n("effect_generator").uv(3, 2, 13, 13).noCull()
.s("effect_generator").uv(3, 2, 13, 13).noCull()
.w("effect_generator").uv(3, 2, 13, 13).noCull()
.e("effect_generator").uv(3, 2, 13, 13).noCull()
;
public BlockEffectGenerator() {
super(Material.TRANSLUCENT);
this.setHardness(3.0F);
this.setTab(CheatTab.TECHNOLOGY);
}
public TileEntity createNewTileEntity() {
return new DeviceEffectGenerator();
}
public boolean isOpaqueCube() {
return false;
}
public boolean isFullCube() {
return false;
}
public BlockLayer getBlockLayer() {
return BlockLayer.CUTOUT;
}
public Model getModel(ModelProvider provider, String name, State state) {
return MODEL;
}
}

View file

@ -1,23 +1,22 @@
package common.block.tech;
import common.block.BlockContainer;
import common.block.Block;
import common.block.Material;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.inventory.Container;
import common.inventory.ContainerEnchantment;
import common.inventory.InventoryPlayer;
import common.item.CheatTab;
import common.item.ItemStack;
import common.model.Model;
import common.model.ModelProvider;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityEnchantmentTable;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import common.world.World;
public class BlockEnchantmentTable extends BlockContainer
public class BlockEnchantmentTable extends Block
{
private static final Model enchanting_table_base = ModelProvider.getModelProvider().getModel("enchanting_table_bottom")
private static final Model MODEL = ModelProvider.getModelProvider().getModel("enchanting_table_bottom")
.add(0, 0, 0, 16, 12, 16)
.d().uv(0, 0, 16, 16)
.u("enchanting_table_top").uv(0, 0, 16, 16).noCull()
@ -40,68 +39,47 @@ public class BlockEnchantmentTable extends BlockContainer
return false;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity()
{
return new TileEntityEnchantmentTable();
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
{
if (worldIn.client)
if (worldIn.client)
{
return true;
}
else
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityEnchantmentTable)
{
playerIn.displayGui((TileEntityEnchantmentTable)tileentity);
}
playerIn.connection.show(new Enchanter(worldIn, pos));
return true;
}
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer, ItemStack stack)
public Model getModel(ModelProvider provider, String name, State state) {
return MODEL;
}
public class Enchanter implements InteractionObject
{
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
private final World world;
private final BlockPos position;
if (stack.hasDisplayName())
public Enchanter(World worldIn, BlockPos pos)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
this.world = worldIn;
this.position = pos;
}
if (tileentity instanceof TileEntityEnchantmentTable)
{
((TileEntityEnchantmentTable)tileentity).setCustomName(stack.getDisplayName());
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
return new ContainerEnchantment(playerInventory, this.world, this.position);
}
public Block getBlock()
{
return BlockEnchantmentTable.this;
}
}
public Model getModel(ModelProvider provider, String name, State state) {
return enchanting_table_base;
}
}

View file

@ -11,7 +11,6 @@ import common.init.Items;
import common.inventory.Container;
import common.inventory.InventoryHelper;
import common.item.Item;
import common.item.ItemStack;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
@ -131,7 +130,7 @@ public class BlockFurnace extends BlockContainer implements Rotatable
if (tileentity instanceof TileEntityFurnace)
{
playerIn.displayGUIChest((TileEntityFurnace)tileentity);
playerIn.connection.show((TileEntityFurnace)tileentity);
// playerIn.triggerAchievement(StatRegistry.furnaceStat);
}
@ -182,24 +181,6 @@ public class BlockFurnace extends BlockContainer implements Rotatable
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer, ItemStack stack)
{
worldIn.setState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityFurnace)
{
((TileEntityFurnace)tileentity).setCustomInventoryName(stack.getDisplayName());
}
}
}
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
if (!keepInventory)

View file

@ -12,7 +12,6 @@ import common.inventory.Container;
import common.inventory.InventoryHelper;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.item.block.ItemBlock;
import common.model.BlockLayer;
import common.model.Model;
@ -142,24 +141,6 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
return new TileEntityHopper();
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, State state, EntityLiving placer, ItemStack stack)
{
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityHopper)
{
((TileEntityHopper)tileentity).setCustomName(stack.getDisplayName());
}
}
}
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{
this.updateState(worldIn, pos, state);
@ -177,7 +158,7 @@ public class BlockHopper extends BlockContainer implements DirectionalDown
if (tileentity instanceof TileEntityHopper)
{
playerIn.displayGUIChest((TileEntityHopper)tileentity);
playerIn.connection.show((TileEntityHopper)tileentity);
// playerIn.triggerAchievement(StatRegistry.hopperStat);
}

View file

@ -11,7 +11,7 @@ import common.inventory.InventoryHelper;
import common.item.CheatTab;
import common.properties.Property;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityDevice;
import common.tileentity.Device;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
@ -19,12 +19,16 @@ import common.world.World;
import common.world.AWorldServer;
public abstract class BlockMachine extends Block implements Rotatable, ITileEntityProvider {
public BlockMachine() {
super(Material.SOLID);
protected BlockMachine(Material material) {
super(material);
this.hasTile = true;
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
this.setTab(CheatTab.TECHNOLOGY);
}
protected BlockMachine() {
this(Material.SOLID);
}
public abstract TileEntity createNewTileEntity();
@ -37,10 +41,8 @@ public abstract class BlockMachine extends Block implements Rotatable, ITileEnti
if(worldIn.client)
return true;
TileEntity tileentity = worldIn.getTileEntity(pos);
if(tileentity instanceof TileEntityDevice) {
playerIn.displayGUIChest((TileEntityDevice)tileentity);
// playerIn.triggerAchievement(StatList.hopperStat);
}
if(tileentity instanceof Device)
playerIn.connection.show((Device)tileentity);
return true;
}
@ -49,18 +51,12 @@ public abstract class BlockMachine extends Block implements Rotatable, ITileEnti
}
private void updateState(World worldIn, BlockPos pos, State state) {
// boolean flag = !worldIn.isBlockPowered(pos);
//
// if (flag != ((Boolean)state.getValue(ENABLED)).booleanValue())
// {
// worldIn.setBlockState(pos, state.withProperty(ENABLED, Boolean.valueOf(flag)), 4);
// }
}
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state) {
TileEntity tileentity = worldIn.getTileEntity(pos);
if(tileentity instanceof TileEntityDevice) {
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityDevice)tileentity);
if(tileentity instanceof Device) {
InventoryHelper.dropInventoryItems(worldIn, pos, (Device)tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
}
super.onBlockRemoved(worldIn, pos, state);

View file

@ -1,10 +1,10 @@
package common.block.tech;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityMobSpawner;
import common.tileentity.DeviceMobSpawner;
public class BlockMobSpawner extends BlockMachine {
public TileEntity createNewTileEntity() {
return new TileEntityMobSpawner();
return new DeviceMobSpawner();
}
}

View file

@ -6,12 +6,12 @@ import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityTianReactor;
import common.tileentity.DeviceTianReactor;
import common.world.State;
public class BlockTianReactor extends BlockMachine {
public TileEntity createNewTileEntity() {
return new TileEntityTianReactor();
return new DeviceTianReactor();
}
public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -6,7 +6,9 @@ import common.block.Material;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.init.Items;
import common.inventory.InventoryWarpChest;
import common.inventory.Container;
import common.inventory.ContainerChest;
import common.inventory.InventoryPlayer;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
@ -98,11 +100,9 @@ public class BlockWarpChest extends Block implements Rotatable
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
{
InventoryWarpChest inv = playerIn.getWarpChest();
if(inv != null && !worldIn.client) {
inv.setChestTileEntity(pos);
playerIn.displayGUIChest(inv);
// playerIn.triggerAchievement(StatRegistry.warpChestStat);
if(!worldIn.client) {
playerIn.getWarpChest().setWarpChest(pos);
playerIn.connection.show(new WarpChest());
}
return true;
}
@ -137,4 +137,17 @@ public class BlockWarpChest extends Block implements Rotatable
{
return true;
}
public class WarpChest implements InteractionObject
{
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
return new ContainerChest(playerIn.inventory, playerIn.getWarpChest(), playerIn);
}
public Block getBlock()
{
return BlockWarpChest.this;
}
}
}

View file

@ -3,14 +3,12 @@ package common.block.tech;
import common.block.Block;
import common.block.Material;
import common.entity.npc.EntityNPC;
import common.init.BlockRegistry;
import common.inventory.Container;
import common.inventory.ContainerWorkbench;
import common.inventory.InventoryPlayer;
import common.item.CheatTab;
import common.model.Model;
import common.model.ModelProvider;
import common.tileentity.IInteractionObject;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
@ -39,8 +37,7 @@ public class BlockWorkbench extends Block
}
else
{
playerIn.displayGui(new BlockWorkbench.InterfaceCraftingTable(worldIn, pos, this));
// playerIn.triggerAchievement(StatRegistry.craftingTableStat);
playerIn.connection.show(new Crafter(worldIn, pos));
return true;
}
}
@ -50,32 +47,25 @@ public class BlockWorkbench extends Block
.w().e("crafting_table_side");
}
public static class InterfaceCraftingTable implements IInteractionObject
public class Crafter implements InteractionObject
{
private final World world;
private final BlockPos position;
private final BlockWorkbench block;
public InterfaceCraftingTable(World worldIn, BlockPos pos, BlockWorkbench block)
public Crafter(World worldIn, BlockPos pos)
{
this.world = worldIn;
this.position = pos;
this.block = block;
}
public String getCommandName()
{
return this.block.getDisplay();
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
return new ContainerWorkbench(playerInventory, this.world, this.position, this.block);
return new ContainerWorkbench(playerInventory, this.world, this.position, BlockWorkbench.this);
}
public String getGuiID()
public Block getBlock()
{
return BlockRegistry.getName(this.block);
return BlockWorkbench.this;
}
}
}

View file

@ -0,0 +1,11 @@
package common.block.tech;
import common.block.Block;
import common.entity.npc.EntityNPC;
import common.inventory.Container;
import common.inventory.InventoryPlayer;
public interface InteractionObject {
Container createContainer(InventoryPlayer inv, EntityNPC player);
Block getBlock();
}

View file

@ -34,7 +34,7 @@ public class BlockSign extends BlockContainer
if (tileentity instanceof TileEntitySign)
{
playerIn.openEditSign((TileEntitySign)tileentity);
playerIn.connection.show((TileEntitySign)tileentity);
}
}
return true;

View file

@ -23,6 +23,7 @@ import common.init.Blocks;
import common.init.EntityRegistry;
import common.init.ItemRegistry;
import common.init.SoundEvent;
import common.inventory.InventoryBasic;
import common.item.Item;
import common.item.ItemStack;
import common.rng.Random;
@ -2633,4 +2634,8 @@ public abstract class Entity
}
public abstract EntityType getType();
public InventoryBasic getEntityInventory() {
return null;
}
}

View file

@ -22,7 +22,6 @@ import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.init.Items;
import common.init.SoundEvent;
import common.inventory.AnimalChest;
import common.inventory.IInvBasic;
import common.inventory.InventoryBasic;
import common.item.Item;
@ -59,7 +58,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
public int field_110278_bp;
public int field_110279_bq;
protected boolean horseJumping;
private AnimalChest horseChest;
private InventoryBasic horseChest;
private boolean hasReproduced;
/**
@ -448,9 +447,8 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
private void initHorseChest()
{
AnimalChest animalchest = this.horseChest;
this.horseChest = new AnimalChest("HorseChest", this.getChestSize());
this.horseChest.setCustomName(this.getName());
InventoryBasic animalchest = this.horseChest;
this.horseChest = new InventoryBasic(this.getChestSize());
if (animalchest != null)
{
@ -782,10 +780,13 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
{
if (!this.worldObj.client && (this.passenger == null || this.passenger == playerEntity) && this.isTame())
{
this.horseChest.setCustomName(this.getName());
playerEntity.displayEntityGui(this, this.horseChest);
playerEntity.connection.show(this);
}
}
public InventoryBasic getEntityInventory() {
return this.horseChest;
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
@ -1264,7 +1265,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
this.dropChests();
}
private void dropItemsInChest(Entity entityIn, AnimalChest animalChestIn)
private void dropItemsInChest(Entity entityIn, InventoryBasic animalChestIn)
{
if (animalChestIn != null && !this.worldObj.client)
{

View file

@ -4,14 +4,11 @@ import common.block.tech.BlockRailBase;
import common.block.tech.BlockRailPowered;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.EntityType;
import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.init.Items;
import common.item.Item;
import common.item.ItemStack;
import common.tags.TagObject;
import common.tileentity.IWorldNameable;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.ExtMath;
@ -20,7 +17,7 @@ import common.vars.Vars;
import common.world.State;
import common.world.World;
public abstract class EntityCart extends Entity implements IWorldNameable
public abstract class EntityCart extends Entity
{
private boolean isInReverse;
private String entityName;
@ -46,33 +43,6 @@ public abstract class EntityCart extends Entity implements IWorldNameable
this.setSize(0.98F, 0.7F);
}
public static EntityCart getMinecart(World worldIn, double x, double y, double z, EntityCart.EnumMinecartType type)
{
switch (type)
{
case CHEST:
return new EntityChestCart(worldIn, x, y, z);
// case FURNACE:
// return new EntityMinecartFurnace(worldIn, x, y, z);
case TNT:
return new EntityTntCart(worldIn, x, y, z);
// case SPAWNER:
// return new EntityMinecartMobSpawner(worldIn, x, y, z);
case HOPPER:
return new EntityHopperCart(worldIn, x, y, z);
// case COMMAND_BLOCK:
// return new EntityMinecartCommandBlock(worldIn, x, y, z);
default:
return new EntityMinecart(worldIn, x, y, z);
}
}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
* prevent them from trampling crops
@ -772,7 +742,7 @@ public abstract class EntityCart extends Entity implements IWorldNameable
{
if (entityIn != this.passenger)
{
if (entityIn instanceof EntityLiving && /* !(entityIn.isPlayer()) && */ this.getMinecartType() == EntityCart.EnumMinecartType.RIDEABLE && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.01D && this.passenger == null && entityIn.vehicle == null)
if (entityIn instanceof EntityLiving && /* !(entityIn.isPlayer()) && */ this.canRide() && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.01D && this.passenger == null && entityIn.vehicle == null)
{
entityIn.mountEntity(this);
}
@ -930,7 +900,7 @@ public abstract class EntityCart extends Entity implements IWorldNameable
return this.dataWatcher.getWatchableObjectInt(18);
}
public abstract EntityCart.EnumMinecartType getMinecartType();
public abstract boolean canRide();
public State getDisplayTile()
{
@ -1011,29 +981,4 @@ public abstract class EntityCart extends Entity implements IWorldNameable
public boolean isMagnetic() {
return true;
}
public Item getItem() {
switch(this.getMinecartType()) {
case CHEST:
return Items.chest_minecart;
case TNT:
return Items.tnt_minecart;
case HOPPER:
return Items.hopper_minecart;
default:
return Items.minecart;
}
}
public EntityType getType() {
return EntityType.VEHICLE;
}
public static enum EnumMinecartType
{
RIDEABLE,
CHEST,
TNT,
HOPPER;
}
}

View file

@ -1,283 +0,0 @@
package common.entity.item;
import common.collect.Lists;
import common.dimension.Dimension;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.inventory.Container;
import common.inventory.InventoryHelper;
import common.item.ItemStack;
import common.tags.TagObject;
import java.util.List;
import common.tileentity.ILockableContainer;
import common.tileentity.Passcode;
import common.util.BlockPos;
import common.util.PortalType;
import common.vars.Vars;
import common.world.World;
public abstract class EntityCartContainer extends EntityCart implements ILockableContainer
{
private ItemStack[] minecartContainerItems = new ItemStack[36];
/**
* When set to true, the minecart will drop all items when setDead() is called. When false (such as when travelling
* dimensions) it preserves its contents.
*/
private boolean dropContentsWhenDead = true;
public EntityCartContainer(World worldIn)
{
super(worldIn);
}
public EntityCartContainer(World worldIn, double x, double y, double z)
{
super(worldIn, x, y, z);
}
public void killMinecart(DamageSource source)
{
super.killMinecart(source);
if (Vars.objectDrop)
{
InventoryHelper.dropInventoryItems(this.worldObj, this, this);
}
}
/**
* Returns the stack in the given slot.
*/
public ItemStack getStackInSlot(int index)
{
return this.minecartContainerItems[index];
}
/**
* Removes up to a specified number of items from an inventory slot and returns them in a new stack.
*/
public ItemStack decrStackSize(int index, int count)
{
if (this.minecartContainerItems[index] != null)
{
if (this.minecartContainerItems[index].getSize() <= count)
{
ItemStack itemstack1 = this.minecartContainerItems[index];
this.minecartContainerItems[index] = null;
return itemstack1;
}
else
{
ItemStack itemstack = this.minecartContainerItems[index].split(count);
if (this.minecartContainerItems[index].isEmpty())
{
this.minecartContainerItems[index] = null;
}
return itemstack;
}
}
else
{
return null;
}
}
/**
* Removes a stack from the given slot and returns it.
*/
public ItemStack removeStackFromSlot(int index)
{
if (this.minecartContainerItems[index] != null)
{
ItemStack itemstack = this.minecartContainerItems[index];
this.minecartContainerItems[index] = null;
return itemstack;
}
else
{
return null;
}
}
/**
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
*/
public void setInventorySlotContents(int index, ItemStack stack)
{
this.minecartContainerItems[index] = stack;
if (stack != null && stack.getSize() > this.getInventoryStackLimit())
{
stack.setSize(this.getInventoryStackLimit());
}
}
/**
* For tile entities, ensures the chunk containing the tile entity is saved to disk later - the game won't think it
* hasn't changed and skip it.
*/
public void markDirty()
{
}
/**
* Do not make give this method the name canInteractWith because it clashes with Container
*/
public boolean isUseableByPlayer(EntityNPC player)
{
return this.dead ? false : player.getDistanceSqToEntity(this) <= 64.0D;
}
public void openInventory(EntityNPC player)
{
}
public void closeInventory(EntityNPC player)
{
}
/**
* Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
*/
public boolean isItemValidForSlot(int index, ItemStack stack)
{
return true;
}
// /**
// * Get the name of this object. For players this returns their username
// */
// public IChatComponent getTypeName()
// {
// return this.hasCustomName() ? new ChatComponentText(this.getCustomNameTag()) : new ChatComponentTranslation("container.minecart");
// }
/**
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
*/
public int getInventoryStackLimit()
{
return ItemStack.MAX_SIZE;
}
/**
* Teleports the entity to another dimension. Params: Dimension number to teleport to
*/
public Entity travelToDimension(Dimension dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
{
this.dropContentsWhenDead = false;
return super.travelToDimension(dimensionId, pos, yaw, pitch, portal);
}
/**
* Will get destroyed next tick.
*/
public void setDead()
{
if (this.dropContentsWhenDead)
{
InventoryHelper.dropInventoryItems(this.worldObj, this, this);
}
super.setDead();
}
protected void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
List<TagObject> nbttaglist = Lists.newArrayList();
for (int i = 0; i < this.minecartContainerItems.length; ++i)
{
if (this.minecartContainerItems[i] != null)
{
TagObject nbttagcompound = new TagObject();
nbttagcompound.setByte("Slot", (byte)i);
this.minecartContainerItems[i].writeTags(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
}
tagCompound.setList("Items", nbttaglist);
}
protected void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);
List<TagObject> nbttaglist = tagCompund.getList("Items");
this.minecartContainerItems = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.size(); ++i)
{
TagObject nbttagcompound = nbttaglist.get(i);
int j = nbttagcompound.getByte("Slot") & 255;
if (j >= 0 && j < this.minecartContainerItems.length)
{
this.minecartContainerItems[j] = ItemStack.readFromTag(nbttagcompound);
}
}
}
/**
* First layer of player interaction
*/
public boolean interactFirst(EntityNPC playerIn)
{
if (!this.worldObj.client)
{
playerIn.displayGUIChest(this);
}
return true;
}
protected void applyDrag()
{
int i = 15 - Container.calcRedstoneFromInventory(this);
float f = 0.98F + (float)i * 0.001F;
this.motionX *= (double)f;
this.motionY *= 0.0D;
this.motionZ *= (double)f;
}
public int getField(int id)
{
return 0;
}
public void setField(int id, int value)
{
}
public int getFieldCount()
{
return 0;
}
public boolean isLocked()
{
return false;
}
public void setLockCode(Passcode code)
{
}
public Passcode getLockCode()
{
return Passcode.EMPTY_CODE;
}
public void clear()
{
for (int i = 0; i < this.minecartContainerItems.length; ++i)
{
this.minecartContainerItems[i] = null;
}
}
}

View file

@ -1,70 +0,0 @@
package common.entity.item;
import common.block.tech.BlockChest;
import common.entity.DamageSource;
import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.init.Items;
import common.inventory.Container;
import common.inventory.ContainerChest;
import common.inventory.InventoryPlayer;
import common.util.Facing;
import common.vars.Vars;
import common.world.State;
import common.world.World;
public class EntityChestCart extends EntityCartContainer
{
public EntityChestCart(World worldIn)
{
super(worldIn);
}
public EntityChestCart(World worldIn, double x, double y, double z)
{
super(worldIn, x, y, z);
}
public void killMinecart(DamageSource source)
{
super.killMinecart(source);
if (Vars.objectDrop)
{
this.dropItemWithOffset(Items.chest, 1, 0.0F);
}
}
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
{
return 27;
}
public EntityCart.EnumMinecartType getMinecartType()
{
return EntityCart.EnumMinecartType.CHEST;
}
public State getDisplayTile()
{
return Blocks.chest.getState().withProperty(BlockChest.FACING, Facing.NORTH);
}
public int getDisplayTileOffset()
{
return 8;
}
public String getGuiID()
{
return "chest";
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
return new ContainerChest(playerInventory, this, playerIn);
}
}

View file

@ -1,238 +0,0 @@
package common.entity.item;
import java.util.List;
import java.util.function.Predicate;
import common.entity.DamageSource;
import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.init.Items;
import common.inventory.Container;
import common.inventory.ContainerHopper;
import common.inventory.InventoryPlayer;
import common.tags.TagObject;
import common.tileentity.IHopper;
import common.tileentity.TileEntityHopper;
import common.util.BlockPos;
import common.vars.Vars;
import common.world.State;
import common.world.World;
public class EntityHopperCart extends EntityCartContainer implements IHopper
{
/** Whether this hopper minecart is being blocked by an activator rail. */
private boolean isBlocked = true;
private int transferTicker = -1;
private BlockPos field_174900_c = BlockPos.ORIGIN;
public EntityHopperCart(World worldIn)
{
super(worldIn);
}
public EntityHopperCart(World worldIn, double x, double y, double z)
{
super(worldIn, x, y, z);
}
public EntityCart.EnumMinecartType getMinecartType()
{
return EntityCart.EnumMinecartType.HOPPER;
}
public State getDisplayTile()
{
return Blocks.hopper.getState();
}
public int getDisplayTileOffset()
{
return 1;
}
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
{
return 5;
}
/**
* First layer of player interaction
*/
public boolean interactFirst(EntityNPC playerIn)
{
if (!this.worldObj.client)
{
playerIn.displayGUIChest(this);
}
return true;
}
/**
* Called every tick the minecart is on an activator rail. Args: x, y, z, is the rail receiving power
*/
public void onActivatorRailPass(int x, int y, int z, boolean receivingPower)
{
boolean flag = !receivingPower;
if (flag != this.getBlocked())
{
this.setBlocked(flag);
}
}
/**
* Get whether this hopper minecart is being blocked by an activator rail.
*/
public boolean getBlocked()
{
return this.isBlocked;
}
/**
* Set whether this hopper minecart is being blocked by an activator rail.
*/
public void setBlocked(boolean p_96110_1_)
{
this.isBlocked = p_96110_1_;
}
/**
* Returns the worldObj for this tileEntity.
*/
public World getWorld()
{
return this.worldObj;
}
/**
* Gets the world X position for this hopper entity.
*/
public double getXPos()
{
return this.posX;
}
/**
* Gets the world Y position for this hopper entity.
*/
public double getYPos()
{
return this.posY + 0.5D;
}
/**
* Gets the world Z position for this hopper entity.
*/
public double getZPos()
{
return this.posZ;
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
if (!this.worldObj.client && this.isEntityAlive() && this.getBlocked())
{
BlockPos blockpos = new BlockPos(this);
if (blockpos.equals(this.field_174900_c))
{
--this.transferTicker;
}
else
{
this.setTransferTicker(0);
}
if (!this.canTransfer())
{
this.setTransferTicker(0);
if (this.collectItems())
{
this.setTransferTicker(Vars.hopperCartDelay);
this.markDirty();
}
}
}
}
public boolean collectItems()
{
if (TileEntityHopper.captureDroppedItems(this))
{
return true;
}
else
{
List<EntityItem> list = this.worldObj.<EntityItem>getEntitiesWithinAABB(EntityItem.class, this.getEntityBoundingBox().expand(0.25D, 0.0D, 0.25D), new Predicate<EntityItem>() {
public boolean test(EntityItem entity) {
return entity.isEntityAlive();
}
});
if (list.size() > 0)
{
TileEntityHopper.putDropInInventoryAllSlots(this, (EntityItem)list.get(0));
}
return false;
}
}
public void killMinecart(DamageSource source)
{
super.killMinecart(source);
if (Vars.objectDrop)
{
this.dropItemWithOffset(Items.hopper, 1, 0.0F);
}
}
protected void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
tagCompound.setInt("TransferCooldown", this.transferTicker);
}
protected void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);
this.transferTicker = tagCompund.getInt("TransferCooldown");
}
/**
* Sets the transfer ticker, used to determine the delay between transfers.
*/
public void setTransferTicker(int p_98042_1_)
{
this.transferTicker = p_98042_1_;
}
/**
* Returns whether the hopper cart can currently transfer an item.
*/
public boolean canTransfer()
{
return this.transferTicker > 0;
}
public String getGuiID()
{
return "hopper";
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
return new ContainerHopper(playerInventory, this, playerIn);
}
}

View file

@ -1,7 +1,10 @@
package common.entity.item;
import common.entity.Entity;
import common.entity.EntityType;
import common.entity.npc.EntityNPC;
import common.init.Items;
import common.item.Item;
import common.world.World;
public class EntityMinecart extends EntityCart
@ -63,8 +66,16 @@ public class EntityMinecart extends EntityCart
}
}
public EntityCart.EnumMinecartType getMinecartType()
public boolean canRide()
{
return EntityCart.EnumMinecartType.RIDEABLE;
return true;
}
public Item getItem() {
return Items.minecart;
}
public EntityType getType() {
return EntityType.VEHICLE;
}
}

View file

@ -3,10 +3,12 @@ package common.entity.item;
import common.block.tech.BlockRailBase;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.EntityType;
import common.entity.projectile.EntityArrow;
import common.init.Blocks;
import common.init.Items;
import common.init.SoundEvent;
import common.item.Item;
import common.item.ItemStack;
import common.tags.TagObject;
import common.util.BlockPos;
@ -30,9 +32,9 @@ public class EntityTntCart extends EntityCart
super(worldIn, x, y, z);
}
public EntityCart.EnumMinecartType getMinecartType()
public boolean canRide()
{
return EntityCart.EnumMinecartType.TNT;
return false;
}
public State getDisplayTile()
@ -215,4 +217,12 @@ public class EntityTntCart extends EntityCart
super.writeEntity(tagCompound);
tagCompound.setInt("TNTFuse", this.minecartTNTFuse);
}
public Item getItem() {
return Items.tnt_minecart;
}
public EntityType getType() {
return EntityType.EXPLOSIVE;
}
}

View file

@ -56,7 +56,6 @@ import common.init.UniverseRegistry;
import common.init.SpeciesRegistry.ModelType;
import common.inventory.Container;
import common.inventory.ContainerPlayer;
import common.inventory.IInventory;
import common.inventory.InventoryBasic;
import common.inventory.InventoryPlayer;
import common.inventory.InventoryWarpChest;
@ -86,9 +85,6 @@ import common.pathfinding.PathNavigateGround;
import common.rng.Random;
import common.sound.MovingSoundMinecartRiding;
import common.tags.TagObject;
import common.tileentity.IInteractionObject;
import common.tileentity.Passcode;
import common.tileentity.TileEntitySign;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.ExtMath;
@ -250,7 +246,7 @@ public abstract class EntityNPC extends EntityLiving
{
super(worldIn);
this.species = SpeciesRegistry.CLASSES.get(this.getClass());
this.extraInventory = new InventoryBasic("Items", false, 8);
this.extraInventory = new InventoryBasic(8);
// this.setCharacter("");
if(this.species != null)
this.setSize(this.getSpeciesBaseSize() * this.species.renderer.width / this.species.renderer.height, this.getSpeciesBaseSize()); // /* 0.6F, */ 1.8F);
@ -666,7 +662,7 @@ public abstract class EntityNPC extends EntityLiving
if (!this.worldObj.client && this.canTrade() && this.getAttackTarget() == null)
{
this.setTalking(player);
player.connection.displayTradeGui(this);
player.connection.show(this);
}
// player.triggerAchievement(StatRegistry.timesTalkedToNpcStat);
@ -1842,8 +1838,7 @@ public abstract class EntityNPC extends EntityLiving
if (!this.worldObj.client && this.openContainer != null && !this.openContainer.canInteractWith(this))
{
this.closeScreen();
this.openContainer = this.inventoryContainer;
this.connection.show(null);
}
this.prevChasingPosX = this.chasingPosX;
@ -1994,25 +1989,6 @@ public abstract class EntityNPC extends EntityLiving
// }
}
/**
* set current crafting inventory back to the 2x2 square
*/
public void closeScreen()
{
if(this.connection != null)
this.connection.closeScreen();
else
this.openContainer = this.inventoryContainer;
}
public void setScreenClosed() {
if(this.client != null) {
this.client.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_CONTAINER, this.openContainer.windowId));
this.inventory.setItemStack((ItemStack)null);
this.openContainer = this.inventoryContainer;
}
}
protected boolean pushOutOfBlocks(double x, double y, double z)
{
if(this.client == null)
@ -2108,50 +2084,6 @@ public abstract class EntityNPC extends EntityLiving
return (!this.worldObj.client && (Vars.mobTick || this.connection != null)) || this.client != null;
}
public void openEditSign(TileEntitySign signTile)
{
if(this.connection != null)
this.connection.openEditSign(signTile);
}
/**
* Displays the GUI for interacting with a book.
*/
// public void displayGUIBook(ItemStack bookStack)
// {
// if(this.connection != null)
// this.connection.displayGUIBook(bookStack);
// else if(this.sendQueue != null) {
// Item item = bookStack.getItem();
//
// if (item == Items.writable_book)
// {
// this.gm.displayGuiScreen(new GuiBook(bookStack));
// }
// }
// }
/**
* Displays the GUI for interacting with a chest inventory. Args: chestInventory
*/
public void displayGUIChest(IInventory chestInventory)
{
if(this.connection != null)
this.connection.displayGUIChest(chestInventory);
}
public void displayEntityGui(Entity entity, IInventory inventory)
{
if(this.connection != null)
this.connection.displayEntityGui(entity, inventory);
}
public void displayGui(IInteractionObject guiOwner)
{
if(this.connection != null)
this.connection.displayGui(guiOwner);
}
/**
* Called when the player performs a critical hit on the Entity. Args: entity that was hit critically
*/
@ -4203,13 +4135,11 @@ public abstract class EntityNPC extends EntityLiving
return this.isPlayer() ? this.getDataWatcher().getWatchableObjectInt(12) : super.getAbsorptionAmount();
}
public boolean canOpen(Passcode code)
public boolean canOpen(String code)
{
if (code.empty())
return true;
ItemStack stack = this.getCurrentEquippedItem();
return stack != null && stack.getItem() == Items.key &&
stack.hasDisplayName() && stack.getDisplayName().equals(code.code());
stack.hasDisplayName() && stack.getDisplayName().equals(code);
}
// public boolean isWearing(ModelPart part)

View file

@ -94,7 +94,7 @@ import common.block.natural.BlockTintedFire;
import common.block.natural.BlockWeb;
import common.block.tech.BlockActiveDisplay;
import common.block.tech.BlockAnvil;
import common.block.tech.BlockBeacon;
import common.block.tech.BlockEffectGenerator;
import common.block.tech.BlockBrewingStand;
import common.block.tech.BlockButton;
import common.block.tech.BlockCauldron;
@ -617,14 +617,14 @@ public abstract class BlockRegistry {
register("enchanting_table", (new BlockEnchantmentTable()).setHardness(5.0F).setResistance(2000.0F).setDisplay("Zaubertisch"));
register("brewing_stand", (new BlockBrewingStand()).setHardness(0.5F).setLightLevel(0.125F).setDisplay("Braustand"));
register("cauldron", (new BlockCauldron()).setHardness(2.0F).setDisplay("Kessel"));
register("beacon", (new BlockBeacon()).setDisplay("Leuchtfeuer").setLightLevel(1.0F));
register("effect_generator", (new BlockEffectGenerator()).setDisplay("Effektgenerator").setLightLevel(1.0F));
register("noteblock", (new BlockNote()).setHardness(0.8F).setDisplay("Notenblock"));
register("jukebox", (new BlockJukebox()).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Plattenspieler"));
register("construction_table", (new BlockWorkbench(4)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Konstruktionstisch"));
register("assembly_unit", (new BlockWorkbench(5)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Fertigungseinheit"));
register("chest", (new BlockChest(0)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Truhe"));
register("trapped_chest", (new BlockChest(1)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Redstonetruhe"));
register("chest", new BlockChest(1).setDisplay("Truhe"));
register("large_chest", new BlockChest(2).setDisplay("Große Truhe"));
register("warp_chest", (new BlockWarpChest()).setHardness(22.5F).setResistance(1000.0F).setStepSound(SoundType.STONE)
.setDisplay("Warptruhe").setLightLevel(0.5F));

View file

@ -50,7 +50,7 @@ public abstract class Blocks {
public static final BlockOre arsenic_ore = get("arsenic_ore");
public static final Block ash = get("ash");
public static final BlockWorkbench assembly_unit = get("assembly_unit");
public static final BlockBeacon beacon = get("beacon");
public static final BlockEffectGenerator effect_generator = get("effect_generator");
public static final BlockBedrock bedrock = get("bedrock");
public static final BlockDoor birch_door = get("birch_door");
public static final BlockFence birch_fence = get("birch_fence");
@ -543,7 +543,6 @@ public abstract class Blocks {
public static final BlockTNT tnt_7 = get("tnt_7");
public static final BlockTorch torch = get("torch");
public static final BlockTrapDoor trapdoor = get("trapdoor");
public static final BlockChest trapped_chest = get("trapped_chest");
public static final BlockTripWireHook tripwire_hook = get("tripwire_hook");
public static final Block tungsten_block = get("tungsten_block");
public static final BlockOre tungsten_ore = get("tungsten_ore");
@ -595,6 +594,7 @@ public abstract class Blocks {
public static final BlockActiveDisplay display_on = get("display_on");
public static final BlockActiveDisplay display2_on = get("display2_on");
public static final BlockActiveDisplay display4_on = get("display4_on");
public static final BlockChest large_chest = get("large_chest");
private static <T extends Block> T get(String id) {
T block = (T)BlockRegistry.byNameExact(id);

View file

@ -140,10 +140,9 @@ public abstract class CraftingRegistry
add(new ItemStack(Items.pumpkin_stem, 4), "M", 'M', Items.pumpkin);
addShapeless(new ItemStack(Items.pumpkin_pie), Items.pumpkin, Items.sugar, Items.egg);
addShapeless(new ItemStack(Items.fermented_spider_eye), Items.spider_eye, Items.brown_mushroom, Items.sugar);
addShapeless(new ItemStack(Items.blazing_powder, 2), Items.blaze_rod);
addShapeless(new ItemStack(Items.blazing_powder, 2), Items.demon_rod);
addShapeless(new ItemStack(Items.magma_cream), Items.blazing_powder, Items.slime_ball);
add(new ItemStack(Items.trapped_chest), "#-", '#', Items.chest, '-', Items.tripwire_hook);
add(new ItemStack(Items.warp_chest), "###", "#E#", "###", '#', Items.obsidian, 'E', Items.charged_orb);
add(new ItemStack(Items.furnace), "###", "# #", "###", '#', Items.cobblestone);
add(new ItemStack(Items.sandstone), "##", "##", '#', Items.sand);
@ -155,7 +154,7 @@ public abstract class CraftingRegistry
add(new ItemStack(Items.iron_bars, 16), "###", "###", '#', Items.iron_ingot);
add(new ItemStack(Items.glass_pane, 16), "###", "###", '#', Items.glass);
add(new ItemStack(Items.redstone_lamp, 1), " R ", "RGR", " R ", 'R', Items.redstone, 'G', Items.glowstone);
add(new ItemStack(Items.beacon, 1), "GGG", "GSG", "OOO", 'G', Items.glass, 'S', Items.charge_crystal, 'O', Items.obsidian);
add(new ItemStack(Items.effect_generator, 1), "GGG", "GSG", "OOO", 'G', Items.glass, 'S', Items.charge_crystal, 'O', Items.obsidian);
add(new ItemStack(Items.blood_brick, 1), "NN", "NN", 'N', Items.bloodbrick);
add(new ItemStack(Items.coarse_dirt, 4), "DG", "GD", 'D', Items.dirt, 'G', Items.gravel);
@ -283,11 +282,9 @@ public abstract class CraftingRegistry
add(new ItemStack(Items.detector_rail, 6), "X X", "X#X", "XRX", 'X', Items.iron_ingot, 'R', Items.redstone, '#', Items.stone_pressure_plate);
add(new ItemStack(Items.minecart, 1), "# #", "###", '#', Items.iron_ingot);
add(new ItemStack(Items.cauldron, 1), "# #", "# #", "###", '#', Items.iron_ingot);
add(new ItemStack(Items.brewing_stand, 1), " B ", "###", '#', Items.cobblestone, 'B', Items.blaze_rod);
add(new ItemStack(Items.brewing_stand, 1), " B ", "###", '#', Items.cobblestone, 'B', Items.demon_rod);
add(new ItemStack(Items.lit_pumpkin, 1), "A", "B", 'A', Items.pumpkin, 'B', Items.torch);
add(new ItemStack(Items.chest_minecart, 1), "A", "B", 'A', Items.chest, 'B', Items.minecart);
add(new ItemStack(Items.tnt_minecart, 1), "A", "B", 'A', Items.tnt, 'B', Items.minecart);
add(new ItemStack(Items.hopper_minecart, 1), "A", "B", 'A', Items.hopper, 'B', Items.minecart);
add(new ItemStack(Items.bucket, 1), "# #", " # ", '#', Items.iron_ingot);
add(new ItemStack(Items.flowerpot, 1), "# #", " # ", '#', Items.brick);
addShapeless(new ItemStack(Items.flint_and_steel, 1), new ItemStack(Items.iron_ingot, 1), new ItemStack(Items.flint, 1));

View file

@ -18,11 +18,9 @@ import common.entity.animal.EntityRabbit;
import common.entity.animal.EntitySheep;
import common.entity.animal.EntityWolf;
import common.entity.item.EntityBoat;
import common.entity.item.EntityChestCart;
import common.entity.item.EntityCrystal;
import common.entity.item.EntityExplosion;
import common.entity.item.EntityFalling;
import common.entity.item.EntityHopperCart;
import common.entity.item.EntityItem;
import common.entity.item.EntityLeashKnot;
import common.entity.item.EntityMinecart;
@ -252,9 +250,7 @@ public abstract class EntityRegistry {
registerEntity("Fireworks", EntityMissile.class, "Feuerwerk");
registerEntity("Boat", EntityBoat.class, "Boot");
registerEntity("Minecart", EntityMinecart.class, "Lore");
registerEntity("ChestCart", EntityChestCart.class, "Güterlore");
registerEntity("TntCart", EntityTntCart.class, "TNT-Lore");
registerEntity("HopperCart", EntityHopperCart.class, "Trichterlore");
registerEntity("Hook", EntityHook.class, "Angelhaken");
registerEntity("Dynamite", EntityDynamite.class, "Dynamit");
registerEntity("Nuke", EntityNuke.class, "T-17");

View file

@ -20,7 +20,6 @@ import common.color.TextColor;
import common.effect.Effect;
import common.effect.StatusEffect;
import common.enchantment.Enchantment;
import common.entity.item.EntityCart;
import common.entity.npc.CharacterInfo;
import common.entity.npc.SpeciesInfo;
import common.item.CheatTab;
@ -189,10 +188,8 @@ public abstract class ItemRegistry {
register("milk_bucket", (new ItemBucketMilk()).setDisplay("Milch").setContainerItem(bucket));
register("boat", (new ItemBoat()).setDisplay("Boot"));
register("minecart", (new ItemMinecart(EntityCart.EnumMinecartType.RIDEABLE)).setDisplay("Lore"));
register("chest_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.CHEST)).setDisplay("Güterlore"));
register("hopper_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.HOPPER)).setDisplay("Trichterlore"));
register("tnt_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.TNT)).setDisplay("TNT-Lore")
register("minecart", (new ItemMinecart(false)).setDisplay("Lore"));
register("tnt_minecart", (new ItemMinecart(true)).setDisplay("TNT-Lore")
.setColor(TextColor.RED));
for(EntityInfo egg : EntityRegistry.DNA.values()) {
register("dna_sample_" + egg.id().toLowerCase(), (new ItemMobTemplate(egg.id()))
@ -285,7 +282,7 @@ public abstract class ItemRegistry {
register("cooked_chicken", (new ItemFood(6, true)).setDisplay("Gebratenes Hühnchen"));
register("rotten_flesh", (new ItemFood(4, true)).setDisplay("Verrottetes Fleisch"));
register("orb", (new ItemFragile()).setDisplay("Kugel").setTab(CheatTab.MAGIC));
register("blaze_rod", (new ItemRod()).setDisplay("Lohenrute").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL));
register("demon_rod", (new ItemRod()).setDisplay("Dämonenrute").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL));
register("tear", (new ItemTiny()).setDisplay("Träne").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL));
register("gold_nugget", (new ItemNugget()).setDisplay("Goldnugget").setTab(CheatTab.METALS).setMaxAmount(StackSize.XL));
register("glass_bottle", (new ItemGlassBottle()).setDisplay("Glasflasche"));

View file

@ -132,7 +132,7 @@ public abstract class Items {
public static final ItemBlock assembly_unit = get("assembly_unit");
public static final ItemFood baked_potato = get("baked_potato");
public static final ItemBanHammer banhammer = get("banhammer");
public static final ItemBlock beacon = get("beacon");
public static final ItemBlock effect_generator = get("effect_generator");
public static final ItemBlock bedrock = get("bedrock");
public static final ItemFood beef = get("beef");
public static final ItemDoor birch_door = get("birch_door");
@ -191,7 +191,7 @@ public abstract class Items {
public static final ItemSlab blackwood_slab = get("blackwood_slab");
public static final ItemBlock blackwood_stairs = get("blackwood_stairs");
public static final Item blazing_powder = get("blazing_powder");
public static final ItemRod blaze_rod = get("blaze_rod");
public static final ItemRod demon_rod = get("demon_rod");
public static final ItemBlock blood_brick = get("blood_brick");
public static final ItemFence blood_brick_fence = get("blood_brick_fence");
public static final ItemSlab blood_brick_slab = get("blood_brick_slab");
@ -264,7 +264,6 @@ public abstract class Items {
public static final ItemSlab cherry_slab = get("cherry_slab");
public static final ItemBlock cherry_stairs = get("cherry_stairs");
public static final ItemChest chest = get("chest");
public static final ItemMinecart chest_minecart = get("chest_minecart");
public static final ItemMagnet chick_magnet = get("chick_magnet");
public static final ItemFood chicken = get("chicken");
public static final ItemMetalBlock chrome_block = get("chrome_block");
@ -434,7 +433,6 @@ public abstract class Items {
public static final ItemPressurePlate heavy_weighted_pressure_plate = get("heavy_weighted_pressure_plate");
public static final ItemBlock hellrock = get("hellrock");
public static final ItemBlock hopper = get("hopper");
public static final ItemMinecart hopper_minecart = get("hopper_minecart");
public static final ItemBlock houstonia = get("houstonia");
public static final ItemBucket hydrogen_bucket = get("hydrogen_bucket");
public static final ItemBlock ice = get("ice");
@ -831,7 +829,6 @@ public abstract class Items {
public static final ItemMinecart tnt_minecart = get("tnt_minecart");
public static final ItemBlock torch = get("torch");
public static final ItemBlock trapdoor = get("trapdoor");
public static final ItemChest trapped_chest = get("trapped_chest");
public static final ItemBlock tripwire_hook = get("tripwire_hook");
public static final ItemMetalBlock tungsten_block = get("tungsten_block");
public static final ItemMetal tungsten_ingot = get("tungsten_ingot");
@ -1006,6 +1003,7 @@ public abstract class Items {
public static final ItemPotion potion_weakness = get("potion_weakness");
public static final ItemPotion potion_weakness_base = get("potion_weakness_base");
public static final ItemPotion potion_weakness_extended = get("potion_weakness_extended");
public static final ItemChest large_chest = get("large_chest");
private static <T extends Item> T get(String id) {
T item = (T)ItemRegistry.byName(id);

View file

@ -1,14 +0,0 @@
package common.inventory;
public class AnimalChest extends InventoryBasic
{
public AnimalChest(String inventoryName, int slotCount)
{
super(inventoryName, false, slotCount);
}
public AnimalChest(String invTitle, boolean customName, int slotCount)
{
super(invTitle, customName, slotCount);
}
}

View file

@ -5,12 +5,12 @@ import common.item.ItemStack;
public class ContainerChest extends Container
{
private IInventory lowerChestInventory;
private IInventory chest;
private int numRows;
public ContainerChest(IInventory playerInventory, IInventory chestInventory, EntityNPC player)
{
this.lowerChestInventory = chestInventory;
this.chest = chestInventory;
this.numRows = chestInventory.getSizeInventory() / 9;
chestInventory.openInventory(player);
int i = (this.numRows - 4) * 18;
@ -39,7 +39,7 @@ public class ContainerChest extends Container
public boolean canInteractWith(EntityNPC playerIn)
{
return this.lowerChestInventory.isUseableByPlayer(playerIn);
return this.chest.isUseableByPlayer(playerIn);
}
/**
@ -86,14 +86,11 @@ public class ContainerChest extends Container
public void onContainerClosed(EntityNPC playerIn)
{
super.onContainerClosed(playerIn);
this.lowerChestInventory.closeInventory(playerIn);
this.chest.closeInventory(playerIn);
}
/**
* Return this chest container's lower chest inventory.
*/
public IInventory getLowerChestInventory()
public IInventory getChestInventory()
{
return this.lowerChestInventory;
return this.chest;
}
}

View file

@ -33,7 +33,7 @@ public class ContainerEnchantment extends Container
public ContainerEnchantment(InventoryPlayer playerInv, World worldIn, BlockPos pos)
{
this.table = new InventoryBasic("Enchant", true, 1)
this.table = new InventoryBasic(1)
{
public int getInventoryStackLimit()
{

View file

@ -32,7 +32,7 @@ public class ContainerRepair extends Container
public ContainerRepair(InventoryPlayer playerInventory, final World worldIn, final BlockPos blockPosIn)
{
this.outputSlot = new InventoryCraftResult();
this.inputSlots = new InventoryBasic("Repair", true, 2)
this.inputSlots = new InventoryBasic(2)
{
public void markDirty()
{

View file

@ -3,18 +3,18 @@ package common.inventory;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
import common.network.IPlayer;
import common.tileentity.TileEntityDevice;
import common.tileentity.TileEntityDevice.Status;
import common.tileentity.Device;
import common.tileentity.Device.Status;
public class ContainerTile extends Container
{
private final IInventory tileInv;
private final TileEntityDevice tile;
private final Device tile;
private int temperature;
private Status status = Status.OFF;
private final int[] resources;
public ContainerTile(InventoryPlayer playerInv, TileEntityDevice tile, IInventory tileInv, EntityNPC player)
public ContainerTile(InventoryPlayer playerInv, Device tile, IInventory tileInv, EntityNPC player)
{
this.tileInv = tileInv;
this.tile = tile;

View file

@ -2,9 +2,8 @@ package common.inventory;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
import common.tileentity.IWorldNameable;
public interface IInventory extends IWorldNameable
public interface IInventory
{
/**
* Returns the number of slots in the inventory.

View file

@ -8,26 +8,16 @@ import common.item.ItemStack;
public class InventoryBasic implements IInventory
{
private String inventoryTitle;
private String inventoryComp;
private int slotsCount;
private ItemStack[] inventoryContents;
private List<IInvBasic> changeListeners;
private boolean hasCustomName;
public InventoryBasic(String title, boolean customName, int slotCount)
public InventoryBasic(int slotCount)
{
this.inventoryTitle = title;
this.hasCustomName = customName;
this.slotsCount = slotCount;
this.inventoryContents = new ItemStack[slotCount];
}
public InventoryBasic(String title, int slotCount)
{
this(title, true, slotCount);
}
/**
* Add a listener that will be notified when any item in this inventory is modified.
*
@ -174,46 +164,6 @@ public class InventoryBasic implements IInventory
return this.slotsCount;
}
/**
* Get the name of this object. For players this returns their username
*/
public String getName()
{
return this.inventoryTitle;
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return this.hasCustomName;
}
/**
* Sets the name of this inventory. This is displayed to the client on opening.
*/
// public void setCustomName(String inventoryTitleIn)
// {
// this.hasCustomName = true;
// this.inventoryTitle = inventoryTitleIn;
// }
public void setCustomName(String inventoryCompIn)
{
this.hasCustomName = true;
this.inventoryComp = inventoryCompIn;
}
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public String getCommandName()
{
return this.inventoryComp != null ? this.inventoryComp : this.getName();
// ((TextComponent)(this.hasCustomName() ? new TextComponent(this.getName()) : new TextComponent(this.getName())));
}
/**
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
*/

View file

@ -24,30 +24,6 @@ public class InventoryCraftResult implements IInventory
return this.stackResult[0];
}
/**
* Get the name of this object. For players this returns their username
*/
public String getName()
{
return "Result";
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return false;
}
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public String getCommandName()
{
return this.getName(); // (TextComponent)(this.hasCustomName() ? new TextComponent(this.getName()) : new TextComponent(this.getName()));
}
/**
* Removes up to a specified number of items from an inventory slot and returns them in a new stack.
*/

View file

@ -50,30 +50,6 @@ public class InventoryCrafting implements IInventory
return row >= 0 && row < this.inventoryWidth && column >= 0 && column <= this.inventoryHeight ? this.getStackInSlot(row + column * this.inventoryWidth) : null;
}
/**
* Get the name of this object. For players this returns their username
*/
public String getName()
{
return "Handwerk";
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return false;
}
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public String getCommandName()
{
return this.getName(); // (TextComponent)(this.hasCustomName() ? new TextComponent(this.getName()) : new TextComponent(this.getName()));
}
/**
* Removes a stack from the given slot and returns it.
*/

View file

@ -1,217 +0,0 @@
package common.inventory;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
import common.tileentity.ILockableContainer;
import common.tileentity.Passcode;
import common.tileentity.TileEntityChest;
public class InventoryLargeChest implements ILockableContainer
{
/** Name of the chest. */
private String name;
/** Inventory object corresponding to double chest upper part */
private TileEntityChest upperChest;
/** Inventory object corresponding to double chest lower part */
private TileEntityChest lowerChest;
public InventoryLargeChest(String nameIn, TileEntityChest upperChestIn, TileEntityChest lowerChestIn)
{
this.name = nameIn;
if (upperChestIn == null)
{
upperChestIn = lowerChestIn;
}
if (lowerChestIn == null)
{
lowerChestIn = upperChestIn;
}
this.upperChest = upperChestIn;
this.lowerChest = lowerChestIn;
if (upperChestIn.isLocked())
{
lowerChestIn.setLockCode(upperChestIn.getLockCode());
}
else if (lowerChestIn.isLocked())
{
upperChestIn.setLockCode(lowerChestIn.getLockCode());
}
}
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
{
return this.upperChest.getSizeInventory() + this.lowerChest.getSizeInventory();
}
/**
* Return whether the given inventory is part of this large chest.
*/
public boolean isPartOfLargeChest(IInventory inventoryIn)
{
return this.upperChest == inventoryIn || this.lowerChest == inventoryIn;
}
/**
* Get the name of this object. For players this returns their username
*/
public String getName()
{
return this.upperChest.hasCustomName() ? this.upperChest.getName() : (this.lowerChest.hasCustomName() ? this.lowerChest.getName() : this.name);
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return this.upperChest.hasCustomName() || this.lowerChest.hasCustomName();
}
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public String getCommandName()
{
return this.getName(); // (TextComponent)(this.hasCustomName() ? new TextComponent(this.getName()) : new TextComponent(this.getName()));
}
/**
* Returns the stack in the given slot.
*/
public ItemStack getStackInSlot(int index)
{
return index >= this.upperChest.getSizeInventory() ? this.lowerChest.getStackInSlot(index - this.upperChest.getSizeInventory()) : this.upperChest.getStackInSlot(index);
}
/**
* Removes up to a specified number of items from an inventory slot and returns them in a new stack.
*/
public ItemStack decrStackSize(int index, int count)
{
return index >= this.upperChest.getSizeInventory() ? this.lowerChest.decrStackSize(index - this.upperChest.getSizeInventory(), count) : this.upperChest.decrStackSize(index, count);
}
/**
* Removes a stack from the given slot and returns it.
*/
public ItemStack removeStackFromSlot(int index)
{
return index >= this.upperChest.getSizeInventory() ? this.lowerChest.removeStackFromSlot(index - this.upperChest.getSizeInventory()) : this.upperChest.removeStackFromSlot(index);
}
/**
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
*/
public void setInventorySlotContents(int index, ItemStack stack)
{
if (index >= this.upperChest.getSizeInventory())
{
this.lowerChest.setInventorySlotContents(index - this.upperChest.getSizeInventory(), stack);
}
else
{
this.upperChest.setInventorySlotContents(index, stack);
}
}
/**
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
*/
public int getInventoryStackLimit()
{
return this.upperChest.getInventoryStackLimit();
}
/**
* For tile entities, ensures the chunk containing the tile entity is saved to disk later - the game won't think it
* hasn't changed and skip it.
*/
public void markDirty()
{
this.upperChest.markDirty();
this.lowerChest.markDirty();
}
/**
* Do not make give this method the name canInteractWith because it clashes with Container
*/
public boolean isUseableByPlayer(EntityNPC player)
{
return this.upperChest.isUseableByPlayer(player) && this.lowerChest.isUseableByPlayer(player);
}
public void openInventory(EntityNPC player)
{
this.upperChest.openInventory(player);
this.lowerChest.openInventory(player);
}
public void closeInventory(EntityNPC player)
{
this.upperChest.closeInventory(player);
this.lowerChest.closeInventory(player);
}
/**
* Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
*/
public boolean isItemValidForSlot(int index, ItemStack stack)
{
return true;
}
public int getField(int id)
{
return 0;
}
public void setField(int id, int value)
{
}
public int getFieldCount()
{
return 0;
}
public boolean isLocked()
{
return this.upperChest.isLocked() || this.lowerChest.isLocked();
}
public void setLockCode(Passcode code)
{
this.upperChest.setLockCode(code);
this.lowerChest.setLockCode(code);
}
public Passcode getLockCode()
{
return this.upperChest.getLockCode();
}
public String getGuiID()
{
return this.upperChest.getGuiID();
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
return new ContainerChest(playerInventory, this, playerIn);
}
public void clear()
{
this.upperChest.clear();
this.lowerChest.clear();
}
}

View file

@ -137,30 +137,6 @@ public class InventoryMerchant implements IInventory
}
}
// /**
// * Get the name of this object. For players this returns their username
// */
// public String getName()
// {
// return "entity.NPC.name";
// }
//
// /**
// * Returns true if this thing is named
// */
// public boolean hasCustomName()
// {
// return false;
// }
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public String getCommandName()
{
return "NSC"; // (TextComponent)(this.hasCustomName() ? new TextComponent(this.getName()) : new Translation(this.getName()));
}
/**
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
*/

View file

@ -505,30 +505,6 @@ public class InventoryPlayer implements IInventory
return aitemstack[index];
}
/**
* Get the name of this object. For players this returns their username
*/
public String getName()
{
return "Inventar";
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return false;
}
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public String getCommandName()
{
return this.getName(); //(TextComponent)(this.hasCustomName() ? new TextComponent(this.getName()) : new TextComponent(this.getName()));
}
/**
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
*/

View file

@ -14,10 +14,10 @@ public class InventoryWarpChest extends InventoryBasic
public InventoryWarpChest()
{
super("Warptruhe", false, 27);
super(27);
}
public void setChestTileEntity(BlockPos chestTileEntity)
public void setWarpChest(BlockPos chestTileEntity)
{
this.associatedChest = chestTileEntity;
}

View file

@ -76,7 +76,7 @@ public class ItemSign extends Item
if (tileentity instanceof TileEntitySign)
{
playerIn.openEditSign((TileEntitySign)tileentity);
playerIn.connection.show((TileEntitySign)tileentity);
}
return true;

View file

@ -2,7 +2,8 @@ package common.item.spawner;
import common.block.tech.BlockRailBase;
import common.entity.item.EntityCart;
import common.entity.item.EntityCart.EnumMinecartType;
import common.entity.item.EntityMinecart;
import common.entity.item.EntityTntCart;
import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.item.CheatTab;
@ -17,14 +18,18 @@ import common.world.World;
public class ItemMinecart extends Item
{
private final EntityCart.EnumMinecartType minecartType;
public ItemMinecart(EntityCart.EnumMinecartType type)
private final boolean tnt;
public ItemMinecart(boolean tnt)
{
this.setUnstackable();
this.minecartType = type;
this.setTab(type == EnumMinecartType.TNT ? CheatTab.EXPLOSIVES : CheatTab.VEHICLES);
// if(type != EntityMinecart.EnumMinecartType.COMMAND_BLOCK)
this.tnt = tnt;
this.setTab(tnt ? CheatTab.EXPLOSIVES : CheatTab.VEHICLES);
}
private EntityCart getMinecart(World worldIn, double x, double y, double z)
{
return this.tnt ? new EntityTntCart(worldIn, x, y, z) : new EntityMinecart(worldIn, x, y, z);
}
/**
@ -55,7 +60,7 @@ public class ItemMinecart extends Item
d0 = 0.5D;
}
EntityCart entityminecart = EntityCart.getMinecart(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D, this.minecartType);
EntityCart entityminecart = this.getMinecart(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D);
if (stack.hasDisplayName())
{
@ -120,7 +125,7 @@ public class ItemMinecart extends Item
}
}
EntityCart entityminecart = EntityCart.getMinecart(world, d0, d1 + d3, d2, this.minecartType);
EntityCart entityminecart = this.getMinecart(world, d0, d1 + d3, d2);
if (stack.hasDisplayName())
{

View file

@ -117,7 +117,7 @@ public interface IClientPlayer extends NetHandler {
void handleSignEditorOpen(SPacketSignEditorOpen packet);
void handleUpdateSign(SPacketUpdateSign packet);
void handleUpdateDisplay(SPacketUpdateDisplay packet);
void handleUpdateTileEntity(SPacketUpdateDevice packet);
void handleUpdateDevice(SPacketUpdateDevice packet);
void handleWindowProperty(SPacketWindowProperty packet);
void handleEntityEquipment(SPacketEntityEquipment packet);
void handleCloseWindow(SPacketCloseWindow packet);

View file

@ -24,8 +24,6 @@ import common.packet.CPacketPlace;
import common.packet.CPacketPlayer;
import common.packet.CPacketSign;
import common.packet.CPacketSkin;
import common.tileentity.IInteractionObject;
import common.tileentity.TileEntitySign;
import common.util.BlockPos;
import common.util.CharValidator;
import common.util.ChunkPos;
@ -68,7 +66,6 @@ public interface IPlayer extends NetHandler {
int getLatency();
boolean isAdmin();
void addToPlayerScore(EntityLiving entity);
void displayTradeGui(EntityNPC entity);
void setPlayerHealthUpdated();
void removeEntity(Entity entity);
void sendPlayerAbilities();
@ -81,11 +78,7 @@ public interface IPlayer extends NetHandler {
void teleport(double x, double y, double z, float yaw, float pitch, Dimension dimension);
void onItemPickup(Entity entity, int amount);
void mountEntity(Entity entity);
void openEditSign(TileEntitySign signTile);
void displayGui(IInteractionObject guiOwner);
void displayGUIChest(IInventory chestInventory);
void displayEntityGui(Entity entity, IInventory inventory);
void closeScreen();
void show(Object object);
void onItemUseFinish();
void onNewEffect(StatusEffect id);
void onChangedEffect(StatusEffect id, boolean added);

View file

@ -6,100 +6,48 @@ import common.network.IPlayer;
import common.network.Packet;
import common.network.PacketBuffer;
public class CPacketAction implements Packet<IPlayer>
{
private Action action;
private int auxData;
public class CPacketAction implements Packet<IPlayer> {
private Action action;
private int auxData;
public CPacketAction()
{
}
public CPacketAction() {
}
public CPacketAction(Action action)
{
this(action, 0);
}
public CPacketAction(Action action) {
this(action, 0);
}
public CPacketAction(Action action, int auxData)
{
this.action = action;
this.auxData = auxData;
}
public void readPacketData(PacketBuffer buf) throws IOException
{
this.action = buf.readEnumValue(Action.class);
this.auxData = buf.readVarInt();
}
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeEnumValue(this.action);
buf.writeVarInt(this.auxData);
}
public void processPacket(IPlayer handler)
{
handler.processAction(this);
}
public CPacketAction(Action action, int auxData) {
this.action = action;
this.auxData = auxData;
}
public Action getAction()
{
return this.action;
}
public void readPacketData(PacketBuffer buf) throws IOException {
this.action = buf.readEnumValue(Action.class);
this.auxData = buf.readVarInt();
}
public int getAuxData()
{
return this.auxData;
}
public void writePacketData(PacketBuffer buf) throws IOException {
buf.writeEnumValue(this.action);
buf.writeVarInt(this.auxData);
}
public static enum Action
{
OPEN_EDITOR,
CLOSE_EDITOR,
CANCEL_EDITOR,
SELECT_CHARACTER,
DELETE_CHARACTER,
SWING_ARM,
SET_ITEMSLOT,
START_SNEAKING,
STOP_SNEAKING,
// STOP_SLEEPING,
START_SPRINTING,
STOP_SPRINTING,
START_HOVER,
STOP_HOVER,
RIDING_JUMP,
OPEN_INVENTORY,
START_FLYING,
STOP_FLYING,
PERFORM_RESPAWN,
// REQUEST_STATS,
// SET_MODELPARTS,
SET_HEIGHT,
SET_SPECIES,
SET_CLASS,
SELECT_TRADE,
// SET_BEACON,
INTERACT,
ATTACK,
CLOSE_CONTAINER,
CONFIRM_TRANSACTION,
ENCHANT_ITEM,
SET_ALIGN,
ITEM_ACTION,
GOD,
NOCLIP,
SPEED,
HEAL,
REPAIR,
PERF,
MAGNET,
// SET_VIEWDIST,
WARP_MODE,
START_PROFILING,
STOP_PROFILING,
CRAFT_ITEM;
// SHUTDOWN;
}
public void processPacket(IPlayer handler) {
handler.processAction(this);
}
public Action getAction() {
return this.action;
}
public int getAuxData() {
return this.auxData;
}
public static enum Action {
OPEN_EDITOR, CLOSE_EDITOR, CANCEL_EDITOR, SELECT_CHARACTER, DELETE_CHARACTER, SWING_ARM, SET_ITEMSLOT, START_SNEAKING, STOP_SNEAKING,
START_SPRINTING, STOP_SPRINTING, START_HOVER, STOP_HOVER, RIDING_JUMP, OPEN_INVENTORY, START_FLYING, STOP_FLYING, PERFORM_RESPAWN, SET_HEIGHT,
SET_SPECIES, SET_CLASS, SELECT_TRADE, INTERACT, ATTACK, CLOSE_CONTAINER, CONFIRM_TRANSACTION, ENCHANT_ITEM, SET_ALIGN, ITEM_ACTION, GOD,
NOCLIP, SPEED, HEAL, REPAIR, PERF, MAGNET, WARP_MODE, START_PROFILING, STOP_PROFILING, CRAFT_ITEM;
}
}

View file

@ -2,93 +2,79 @@ package common.packet;
import java.io.IOException;
import common.block.Block;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.network.IClientPlayer;
import common.network.Packet;
import common.network.PacketBuffer;
import common.util.BlockPos;
import common.world.State;
public class SPacketOpenWindow implements Packet<IClientPlayer>
{
private int windowId;
private String inventoryType;
private Block type;
private String windowTitle;
private int slotCount;
private int entityId;
private int entityId = -1;
private BlockPos tilePos;
public SPacketOpenWindow()
{
}
public SPacketOpenWindow(int incomingWindowId, String incomingWindowTitle, String windowTitleIn)
{
this(incomingWindowId, incomingWindowTitle, windowTitleIn, 0);
}
public SPacketOpenWindow(int windowIdIn, String guiId, String windowTitleIn, int slotCountIn)
public SPacketOpenWindow(int windowIdIn, Block guiId, String windowTitleIn, int slotCountIn)
{
this.windowId = windowIdIn;
this.inventoryType = guiId;
this.type = guiId;
this.windowTitle = windowTitleIn;
this.slotCount = slotCountIn;
}
public SPacketOpenWindow(int windowIdIn, String guiId, String windowTitleIn, int slotCountIn, int incomingEntityId)
public SPacketOpenWindow(int windowIdIn, int incomingEntityId, String windowTitleIn, int slotCountIn)
{
this(windowIdIn, guiId, windowTitleIn, slotCountIn);
this(windowIdIn, (Block)null, windowTitleIn, slotCountIn);
this.entityId = incomingEntityId;
}
public SPacketOpenWindow(int windowIdIn, String guiId, String windowTitleIn, int slotCountIn, BlockPos incomingTilePos)
public SPacketOpenWindow(int windowIdIn, BlockPos incomingTilePos, String windowTitleIn, int slotCountIn)
{
this(windowIdIn, guiId, windowTitleIn, slotCountIn);
this(windowIdIn, (Block)null, windowTitleIn, slotCountIn);
this.tilePos = incomingTilePos;
}
/**
* Passes this Packet on to the NetHandler for processing.
*/
public void processPacket(IClientPlayer handler)
{
handler.handleOpenWindow(this);
}
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
this.windowId = buf.readUnsignedByte();
this.inventoryType = buf.readString(32);
int type = buf.readVarInt();
if(type == -2)
this.entityId = buf.readInt();
else if(type == -1)
this.tilePos = buf.readBlockPos();
else if(type > 0) {
State state = BlockRegistry.byId(type);
this.type = state == null ? Blocks.air : state.getBlock();
}
this.windowTitle = buf.readString(256);
this.slotCount = buf.readUnsignedByte();
if (this.inventoryType.equals("entity"))
{
this.entityId = buf.readInt();
}
else if(this.inventoryType.equals("tile")) {
this.tilePos = buf.readBlockPos();
}
}
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeByte(this.windowId);
buf.writeString(this.inventoryType);
buf.writeVarInt(this.entityId != -1 ? -2 : (this.tilePos != null ? -1 : (this.type == null ? 0 : BlockRegistry.getId(this.type.getState()))));
if(this.entityId != -1)
buf.writeInt(this.entityId);
else if(this.tilePos != null)
buf.writeBlockPos(this.tilePos);
buf.writeString(this.windowTitle);
buf.writeByte(this.slotCount);
if (this.inventoryType.equals("entity"))
{
buf.writeInt(this.entityId);
}
else if(this.inventoryType.equals("tile")) {
buf.writeBlockPos(this.tilePos);
}
}
public int getWindowId()
@ -96,9 +82,9 @@ public class SPacketOpenWindow implements Packet<IClientPlayer>
return this.windowId;
}
public String getGuiId()
public Block getGuiId()
{
return this.inventoryType;
return this.type;
}
public String getWindowTitle()

View file

@ -12,64 +12,46 @@ import common.tileentity.TileEntity;
import common.util.BlockPos;
import common.world.State;
public class SPacketUpdateDevice implements Packet<IClientPlayer>
{
private BlockPos blockPos;
private Block type;
private TagObject tag;
public class SPacketUpdateDevice implements Packet<IClientPlayer> {
private BlockPos position;
private Block type;
private TagObject tag;
public SPacketUpdateDevice()
{
}
public SPacketUpdateDevice() {
}
public SPacketUpdateDevice(TileEntity tile)
{
this.blockPos = tile.getPos();
this.type = tile.getBlockType();
tile.writeTags(this.tag = new TagObject());
}
public SPacketUpdateDevice(TileEntity tile) {
this.position = tile.getPos();
this.type = tile.getBlockType();
tile.writeTags(this.tag = new TagObject());
}
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
this.blockPos = buf.readBlockPos();
State state = BlockRegistry.byId(buf.readVarInt());
this.type = state == null ? null : state.getBlock();
this.tag = buf.readTag();
}
public void readPacketData(PacketBuffer buf) throws IOException {
this.position = buf.readBlockPos();
State state = BlockRegistry.byId(buf.readVarInt());
this.type = state == null ? null : state.getBlock();
this.tag = buf.readTag();
}
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeBlockPos(this.blockPos);
buf.writeVarInt(BlockRegistry.getId(this.type.getState()));
buf.writeTag(this.tag);
}
public void writePacketData(PacketBuffer buf) throws IOException {
buf.writeBlockPos(this.position);
buf.writeVarInt(BlockRegistry.getId(this.type.getState()));
buf.writeTag(this.tag);
}
/**
* Passes this Packet on to the NetHandler for processing.
*/
public void processPacket(IClientPlayer handler)
{
handler.handleUpdateTileEntity(this);
}
public void processPacket(IClientPlayer handler) {
handler.handleUpdateDevice(this);
}
public BlockPos getPos()
{
return this.blockPos;
}
public BlockPos getPos() {
return this.position;
}
public boolean isTileEntityType(TileEntity tile)
{
return this.type == tile.getBlockType();
}
public Block getType() {
return this.type;
}
public TagObject getTags()
{
return this.tag;
}
public TagObject getTag() {
return this.tag;
}
}

View file

@ -3,9 +3,8 @@ package common.tileentity;
import common.collect.Lists;
import common.color.TextColor;
import common.entity.npc.EntityNPC;
import common.inventory.Container;
import common.inventory.ContainerTile;
import common.inventory.InventoryPlayer;
import common.inventory.IInventory;
import common.item.ItemStack;
import common.network.Packet;
import common.packet.SPacketUpdateDevice;
@ -14,7 +13,7 @@ import common.tags.TagObject;
import java.util.List;
import common.util.ExtMath;
public abstract class TileEntityDevice extends TileEntityLockable implements IHopper, ITickable {
public abstract class Device extends TileEntity implements IInventory, ITickable {
public static enum Status {
OFF(TextColor.DGRAY, "Inaktiv"),
COOLING(TextColor.YELLOW, "Abkühlen ..."),
@ -37,7 +36,7 @@ public abstract class TileEntityDevice extends TileEntityLockable implements IHo
protected int temperature;
protected Status status = Status.OFF;
protected TileEntityDevice(int slots, MachineResource ... resources) {
protected Device(int slots, MachineResource ... resources) {
this.inventory = new ItemStack[slots];
this.resources = resources;
}
@ -181,10 +180,6 @@ public abstract class TileEntityDevice extends TileEntityLockable implements IHo
}
}
public boolean hasCustomName() {
return false;
}
public int getInventoryStackLimit() {
return ItemStack.MAX_SIZE;
}
@ -303,10 +298,6 @@ public abstract class TileEntityDevice extends TileEntityLockable implements IHo
return (double)this.pos.getZ() + 0.5D;
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn) {
return new ContainerTile(playerInventory, this, this, playerIn);
}
public int getField(int id) {
return 0;
}
@ -324,8 +315,7 @@ public abstract class TileEntityDevice extends TileEntityLockable implements IHo
}
}
public Packet getDescriptionPacket()
{
public Packet getDescriptionPacket() {
return new SPacketUpdateDevice(this);
}

View file

@ -0,0 +1,53 @@
package common.tileentity;
import java.util.List;
import common.effect.StatusEffect;
import common.entity.types.EntityLiving;
import common.init.Items;
import common.inventory.ContainerTile;
import common.item.ItemStack;
import common.item.tool.ItemPotion;
import common.util.BoundingBox;
import common.world.World;
public class DeviceEffectGenerator extends Device {
public DeviceEffectGenerator() {
super(2);
}
public boolean isItemValidForSlot(int index, ItemStack stack) {
return index == 0 ? stack.getItem() instanceof ItemPotion : (index == 1 ? stack.getItem() == Items.blazing_powder : false);
}
protected boolean executeFunction() {
if(!this.hasAmount(0, 1) || !this.hasAmount(1, 1) || !(this.getStackInSlot(0).getItem() instanceof ItemPotion potion))
return false;
StatusEffect effect = potion.getEffect();
if(effect == null)
return false;
int levels = 4; // TODO: energy + selector (MachineControl)
double r = (double)(levels * 10 + 10);
double x = this.pos.getX();
double y = this.pos.getY();
double z = this.pos.getZ();
BoundingBox bb = new BoundingBox(x + 0.5 - r, y - 16.0, z + 0.5 - r, x + 0.5 + r, (double)World.MAX_SIZE_Y, z + 0.5 + r);
List<EntityLiving> list = this.worldObj.<EntityLiving>getEntitiesWithinAABB(EntityLiving.class, bb);
for(EntityLiving entity : list) {
entity.addEffect(new StatusEffect(effect.getPotion(), 180, effect.getAmplifier()));
}
return true;
}
public int getColor() {
return 0x7f00ff;
}
public String formatDisplay(ContainerTile inv) {
ItemStack stack = inv.getSlot(0).getStack();
if(stack == null)
return "Kein Trank vorhanden";
return String.format("Effekt: %s",
stack.getItem() instanceof ItemPotion potion ? (potion.getEffect() != null ? potion.getEffect().getEffectName() : "Keiner") : "<?>");
}
}

View file

@ -9,9 +9,9 @@ import common.item.spawner.ItemCharTemplate;
import common.tags.TagObject;
import common.vars.Vars;
public class TileEntityMobSpawner extends TileEntityDevice implements ITickable
public class DeviceMobSpawner extends Device implements ITickable
{
public TileEntityMobSpawner() {
public DeviceMobSpawner() {
super(1);
}
@ -23,14 +23,6 @@ public class TileEntityMobSpawner extends TileEntityDevice implements ITickable
public boolean isItemValidForSlot(int index, ItemStack stack) {
return index == 0 ? stack.getItem() instanceof ItemMobTemplate || stack.getItem() instanceof ItemCharTemplate : false;
}
public String getName() {
return "Mob-Spawner";
}
public String getGuiID() {
return "mob_spawner";
}
public String formatDisplay(ContainerTile inv) {
ItemStack stack = inv.getSlot(0).getStack();

View file

@ -5,8 +5,8 @@ import common.inventory.ContainerTile;
import common.item.ItemStack;
import common.tileentity.MachineResource.Type;
public class TileEntityTianReactor extends TileEntityDevice {
public TileEntityTianReactor() {
public class DeviceTianReactor extends Device {
public DeviceTianReactor() {
super(2, new MachineResource(Type.OUTPUT, "output.energy", 1024, 0, 0));
}
@ -37,14 +37,6 @@ public class TileEntityTianReactor extends TileEntityDevice {
return 8200;
}
public String getName() {
return "Tianreaktor";
}
public String getGuiID() {
return "tian_reactor";
}
public String formatDisplay(ContainerTile inv) {
return String.format("Gespeicherte Energie: %d TF", this.getResource(0).getValue());
}

View file

@ -1,27 +0,0 @@
package common.tileentity;
import common.inventory.IInventory;
import common.world.World;
public interface IHopper extends IInventory
{
/**
* Returns the worldObj for this tileEntity.
*/
World getWorld();
/**
* Gets the world X position for this hopper entity.
*/
double getXPos();
/**
* Gets the world Y position for this hopper entity.
*/
double getYPos();
/**
* Gets the world Z position for this hopper entity.
*/
double getZPos();
}

View file

@ -1,12 +0,0 @@
package common.tileentity;
import common.entity.npc.EntityNPC;
import common.inventory.Container;
import common.inventory.InventoryPlayer;
public interface IInteractionObject extends IWorldNameable
{
Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn);
String getGuiID();
}

View file

@ -1,12 +0,0 @@
package common.tileentity;
import common.inventory.IInventory;
public interface ILockableContainer extends IInventory, IInteractionObject
{
boolean isLocked();
void setLockCode(Passcode code);
Passcode getLockCode();
}

View file

@ -1,6 +0,0 @@
package common.tileentity;
public interface IWorldNameable
{
String getCommandName();
}

View file

@ -1,19 +0,0 @@
package common.tileentity;
import common.tags.TagObject;
public record Passcode(String code) {
public static final Passcode EMPTY_CODE = new Passcode("");
public boolean empty() {
return this.code == null || this.code.isEmpty();
}
public void toTag(TagObject tag) {
tag.setString("Lock", this.code);
}
public static Passcode fromTag(TagObject tag) {
return tag.hasString("Lock") ? new Passcode(tag.getString("Lock")) : EMPTY_CODE;
}
}

View file

@ -1,296 +0,0 @@
package common.tileentity;
import java.util.List;
import common.block.Block;
import common.block.artificial.BlockStainedGlass;
import common.block.artificial.BlockStainedGlassPane;
import common.effect.Effect;
import common.effect.StatusEffect;
import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.tags.TagObject;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class TileEntityBeacon extends TileEntity implements ITickable
{
private static final Effect[][] effectsList = new Effect[][] {{Effect.SPEED, Effect.HASTE}, {Effect.RESISTANCE, Effect.JUMP}, {Effect.STRENGTH}, {Effect.REGENERATION}};
private boolean isComplete;
private int levels = -1;
private Effect primaryEffect;
private Effect secondaryEffect;
/**
* Like the old updateEntity(), except more generic.
*/
public void update()
{
if (!this.worldObj.client && ((AWorldServer)this.worldObj).getTime() % 80L == 0L)
{
this.updateBeacon();
}
// else if (this.worldObj.client && this.worldObj.getDayTime() % 20L == 0L)
// {
// this.updateBeacon();
// }
}
public void updateBeacon()
{
if(!this.worldObj.client)
// this.updateSegmentColors();
// else
this.updateSegment();
}
private void addEffectsToPlayers()
{
if (this.isComplete && this.levels > 0 && this.primaryEffect != null)
{
double d0 = (double)(this.levels * 10 + 10);
int i = 0;
if (this.levels >= 4 && this.primaryEffect == this.secondaryEffect)
{
i = 1;
}
int j = this.pos.getX();
int k = this.pos.getY();
int l = this.pos.getZ();
BoundingBox axisalignedbb = (new BoundingBox((double)j, (double)k, (double)l, (double)(j + 1), (double)(k + 1), (double)(l + 1))).expand(d0, d0, d0).addCoord(0.0D, (double)World.MAX_SIZE_Y, 0.0D);
List<EntityLiving> list = this.worldObj.<EntityLiving>getEntitiesWithinAABB(EntityLiving.class, axisalignedbb);
for (EntityLiving entityplayer : list)
{
entityplayer.addEffect(new StatusEffect(this.primaryEffect, 180, i));
}
if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect != null)
{
for (EntityLiving entityplayer1 : list)
{
entityplayer1.addEffect(new StatusEffect(this.secondaryEffect, 180, 0));
}
}
}
}
private void calculateLevels() {
int j = this.pos.getX();
int k = this.pos.getY();
int l = this.pos.getZ();
if (this.isComplete)
{
for (int l1 = 1; l1 <= 4; this.levels = l1++)
{
int i2 = k - l1;
if (i2 < 0)
{
break;
}
boolean flag1 = true;
for (int j1 = j - l1; j1 <= j + l1 && flag1; ++j1)
{
for (int k1 = l - l1; k1 <= l + l1; ++k1)
{
Block block = this.worldObj.getState(new BlockPos(j1, i2, k1)).getBlock();
if (block != Blocks.emerald_block && block != Blocks.gold_block && block != Blocks.diamond_block && block != Blocks.iron_block)
{
flag1 = false;
break;
}
}
}
if (!flag1)
{
break;
}
}
if (this.levels == 0)
{
this.isComplete = false;
}
}
}
private void updateSegment()
{
// int i = this.levels;
int j = this.pos.getX();
int k = this.pos.getY();
int l = this.pos.getZ();
this.levels = 0;
this.isComplete = true;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int i1 = k + 1; i1 < 512; ++i1)
{
State iblockstate = this.worldObj.getState(blockpos$mutableblockpos.set(j, i1, l));
if (!(iblockstate.getBlock() instanceof BlockStainedGlass) && !(iblockstate.getBlock() instanceof BlockStainedGlassPane)
&& iblockstate.getBlock().getLightOpacity() >= 15 && iblockstate.getBlock() != Blocks.bedrock) {
this.isComplete = false;
break;
}
}
this.calculateLevels();
// if (this.levels == 4 && i < this.levels)
// {
// for (EntityNPC entityplayer : this.worldObj.getEntitiesWithinAABB(EntityNPC.class, (new AxisAlignedBB((double)j, (double)k, (double)l, (double)j, (double)(k - 4), (double)l)).expand(10.0D, 5.0D, 10.0D)))
// {
// entityplayer.triggerAchievement(AchievementList.fullBeacon);
// }
// }
this.addEffectsToPlayers();
}
// private void updateSegmentColors()
// {
// int i = this.levels;
// int j = this.pos.getX();
// int k = this.pos.getY();
// int l = this.pos.getZ();
// this.levels = 0;
// this.beamSegments.clear();
// this.isComplete = true;
// TileEntityBeacon.BeamSegment tileentitybeacon$beamsegment = new TileEntityBeacon.BeamSegment(EntitySheep.getDyeRgb(DyeColor.WHITE));
// this.beamSegments.add(tileentitybeacon$beamsegment);
// boolean flag = true;
// BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
//
// for (int i1 = k + 1; i1 < 512; ++i1)
// {
// State iblockstate = this.worldObj.getState(blockpos$mutableblockpos.set(j, i1, l));
// float[] afloat;
//
// if (iblockstate.getBlock() == Blocks.stained_glass)
// {
// afloat = EntitySheep.getDyeRgb((DyeColor)iblockstate.getValue(BlockStainedGlass.COLOR));
// }
// else
// {
// if (iblockstate.getBlock() != Blocks.stained_glass_pane)
// {
// if (iblockstate.getBlock().getLightOpacity() >= 15 && iblockstate.getBlock() != Blocks.bedrock)
// {
// this.isComplete = false;
// this.beamSegments.clear();
// break;
// }
//
// tileentitybeacon$beamsegment.incrementHeight();
// continue;
// }
//
// afloat = EntitySheep.getDyeRgb((DyeColor)iblockstate.getValue(BlockStainedGlassPane.COLOR));
// }
//
// if (!flag)
// {
// afloat = new float[] {(tileentitybeacon$beamsegment.getColors()[0] + afloat[0]) / 2.0F, (tileentitybeacon$beamsegment.getColors()[1] + afloat[1]) / 2.0F, (tileentitybeacon$beamsegment.getColors()[2] + afloat[2]) / 2.0F};
// }
//
// if (Arrays.equals(afloat, tileentitybeacon$beamsegment.getColors()))
// {
// tileentitybeacon$beamsegment.incrementHeight();
// }
// else
// {
// tileentitybeacon$beamsegment = new TileEntityBeacon.BeamSegment(afloat);
// this.beamSegments.add(tileentitybeacon$beamsegment);
// }
//
// flag = false;
// }
//
// this.calculateLevels();
// }
// public List<TileEntityBeacon.BeamSegment> getBeamSegments()
// {
// return this.beamSegments;
// }
// public float shouldBeamRender()
// {
// if (!this.isComplete)
// {
// return 0.0F;
// }
// else
// {
// int delta = (int)(this.worldObj.getTime() - this.lastRenderUpdate);
// this.lastRenderUpdate = this.worldObj.getTime();
//
// if (delta > 1)
// {
// this.charge -= (float)delta / 40.0F;
//
// if (this.charge < 0.0F)
// {
// this.charge = 0.0F;
// }
// }
//
// this.charge += 0.025F;
//
// if (this.charge > 1.0F)
// {
// this.charge = 1.0F;
// }
//
// return this.charge;
// return 1.0F;
// }
// }
private Effect getEffect(String id)
{
Effect potion = Effect.getByName(id);
// if (potion != null)
// {
return potion != Effect.SPEED && potion != Effect.HASTE && potion != Effect.RESISTANCE && potion != Effect.JUMP && potion != Effect.STRENGTH && potion != Effect.REGENERATION ? null : potion;
// }
// else
// {
// return null;
// }
}
public void readTags(TagObject compound)
{
super.readTags(compound);
this.primaryEffect = compound.hasString("Primary") ? this.getEffect(compound.getString("Primary")) : null;
this.secondaryEffect = compound.hasString("Secondary") ? this.getEffect(compound.getString("Secondary")) : null;
this.levels = compound.getInt("Levels");
}
public void writeTags(TagObject compound)
{
super.writeTags(compound);
if(this.primaryEffect != null)
compound.setString("Primary", this.primaryEffect.getName());
if(this.secondaryEffect != null)
compound.setString("Secondary", this.secondaryEffect.getName());
compound.setInt("Levels", this.levels);
}
public int getColor() {
return 0xff00ff;
}
}

View file

@ -20,7 +20,7 @@ import common.tags.TagObject;
import common.util.Facing;
import common.world.State;
public class TileEntityBrewingStand extends TileEntityLockable implements ITickable, ISidedInventory
public class TileEntityBrewingStand extends TileEntityInventory implements ITickable, ISidedInventory
{
/** an array of the input slot indices */
private static final int[] inputSlots = new int[] {3};
@ -41,28 +41,6 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
* used to check if the current ingredient has been removed from the brewing stand during brewing
*/
private Item ingredientID;
private String customName;
/**
* Get the name of this object. For players this returns their username
*/
public String getName()
{
return this.hasCustomName() ? this.customName : "Braustand";
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return this.customName != null && this.customName.length() > 0;
}
public void setName(String name)
{
this.customName = name;
}
/**
* Returns the number of slots in the inventory.
@ -228,11 +206,6 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
}
this.brewTime = compound.getShort("BrewTime");
if (compound.hasString("CustomName"))
{
this.customName = compound.getString("CustomName");
}
}
public void writeTags(TagObject compound)
@ -253,11 +226,6 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
}
compound.setList("Items", nbttaglist);
if (this.hasCustomName())
{
compound.setString("CustomName", this.customName);
}
}
/**
@ -383,11 +351,6 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
return true;
}
public String getGuiID()
{
return "brewing_stand";
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
return new ContainerBrewingStand(playerInventory, this);

View file

@ -1,63 +1,32 @@
package common.tileentity;
import common.block.Block;
import common.block.tech.BlockChest;
import common.collect.Lists;
import common.entity.npc.EntityNPC;
import common.init.SoundEvent;
import common.inventory.Container;
import common.inventory.ContainerChest;
import common.inventory.IInventory;
import common.inventory.InventoryLargeChest;
import common.inventory.InventoryPlayer;
import common.item.ItemStack;
import common.tags.TagObject;
import java.util.List;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
public class TileEntityChest extends TileEntityLockable implements ITickable, IInventory
public class TileEntityChest extends TileEntity implements ITickable, IInventory
{
private ItemStack[] chestContents = new ItemStack[27];
private final int capacity;
private ItemStack[] chestContents;
private String code;
/** Determines if the check for adjacent chests has taken place. */
public boolean adjacentChestChecked;
/** Contains the chest tile located adjacent to this one (if any) */
public TileEntityChest adjacentChestZNeg;
/** Contains the chest tile located adjacent to this one (if any) */
public TileEntityChest adjacentChestXPos;
/** Contains the chest tile located adjacent to this one (if any) */
public TileEntityChest adjacentChestXNeg;
/** Contains the chest tile located adjacent to this one (if any) */
public TileEntityChest adjacentChestZPos;
/** The current angle of the lid (between 0 and 1) */
public float lidAngle;
/** The angle of the lid last tick */
public float prevLidAngle;
/** The number of players currently using this chest */
public int numPlayersUsing;
/** Server sync counter (once per 20 ticks) */
private int ticksSinceSync;
private int cachedChestType;
private String customName;
public TileEntityChest()
{
this.cachedChestType = -1;
}
public TileEntityChest(int chestType)
{
this.cachedChestType = chestType;
public TileEntityChest(int capacity) {
this.capacity = capacity;
this.chestContents = new ItemStack[this.capacity];
}
/**
@ -65,7 +34,7 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
*/
public int getSizeInventory()
{
return 27;
return this.capacity;
}
/**
@ -141,20 +110,9 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
this.markDirty();
}
/**
* Get the name of this object. For players this returns their username
*/
public String getName()
{
return this.hasCustomName() ? this.customName : "Truhe";
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return this.customName != null && this.customName.length() > 0;
return this.customName != null && !this.customName.isEmpty() ? this.customName : this.getBlockType().getDisplay();
}
public void setCustomName(String name)
@ -165,6 +123,8 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
public void readTags(TagObject compound)
{
super.readTags(compound);
this.code = compound.hasString("Lock") ? compound.getString("Lock") : null;
this.code = this.code != null && this.code.isEmpty() ? null : this.code;
List<TagObject> nbttaglist = compound.getList("Items");
this.chestContents = new ItemStack[this.getSizeInventory()];
@ -188,6 +148,8 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
public void writeTags(TagObject compound)
{
super.writeTags(compound);
if(this.code != null)
compound.setString("Lock", this.code);
List<TagObject> nbttaglist = Lists.newArrayList();
for (int i = 0; i < this.chestContents.length; ++i)
@ -203,7 +165,7 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
compound.setList("Items", nbttaglist);
if (this.hasCustomName())
if (this.customName != null && !this.customName.isEmpty())
{
compound.setString("CustomName", this.customName);
}
@ -225,109 +187,11 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
return this.worldObj.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
}
public void updateContainingBlockInfo()
{
super.updateContainingBlockInfo();
this.adjacentChestChecked = false;
}
private void func_174910_a(TileEntityChest chestTe, Facing side)
{
if (chestTe.isInvalid())
{
this.adjacentChestChecked = false;
}
else if (this.adjacentChestChecked)
{
switch (side)
{
case NORTH:
if (this.adjacentChestZNeg != chestTe)
{
this.adjacentChestChecked = false;
}
break;
case SOUTH:
if (this.adjacentChestZPos != chestTe)
{
this.adjacentChestChecked = false;
}
break;
case EAST:
if (this.adjacentChestXPos != chestTe)
{
this.adjacentChestChecked = false;
}
break;
case WEST:
if (this.adjacentChestXNeg != chestTe)
{
this.adjacentChestChecked = false;
}
}
}
}
/**
* Performs the check for adjacent chests to determine if this chest is double or not.
*/
public void checkForAdjacentChests()
{
if (!this.adjacentChestChecked)
{
this.adjacentChestChecked = true;
this.adjacentChestXNeg = this.getAdjacentChest(Facing.WEST);
this.adjacentChestXPos = this.getAdjacentChest(Facing.EAST);
this.adjacentChestZNeg = this.getAdjacentChest(Facing.NORTH);
this.adjacentChestZPos = this.getAdjacentChest(Facing.SOUTH);
}
}
protected TileEntityChest getAdjacentChest(Facing side)
{
BlockPos blockpos = this.pos.offset(side);
if (this.isChestAt(blockpos))
{
TileEntity tileentity = this.worldObj.getTileEntity(blockpos);
if (tileentity instanceof TileEntityChest)
{
TileEntityChest tileentitychest = (TileEntityChest)tileentity;
tileentitychest.func_174910_a(this, side.getOpposite());
return tileentitychest;
}
}
return null;
}
private boolean isChestAt(BlockPos posIn)
{
if (this.worldObj == null)
{
return false;
}
else
{
Block block = this.worldObj.getState(posIn).getBlock();
return block instanceof BlockChest && ((BlockChest)block).chestType == this.getChestType();
}
}
/**
* Like the old updateEntity(), except more generic.
*/
public void update()
{
this.checkForAdjacentChests();
int i = this.pos.getX();
int j = this.pos.getY();
int k = this.pos.getZ();
@ -342,9 +206,9 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
{
if (entityplayer.isPlayer() && entityplayer.openContainer instanceof ContainerChest)
{
IInventory iinventory = ((ContainerChest)entityplayer.openContainer).getLowerChestInventory();
IInventory iinventory = ((ContainerChest)entityplayer.openContainer).getChestInventory();
if (iinventory == this || iinventory instanceof InventoryLargeChest && ((InventoryLargeChest)iinventory).isPartOfLargeChest(this))
if (iinventory == this)
{
++this.numPlayersUsing;
}
@ -355,21 +219,11 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
this.prevLidAngle = this.lidAngle;
float f1 = 0.1F;
if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null)
if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F)
{
double d1 = (double)i + 0.5D;
double d2 = (double)k + 0.5D;
if (this.adjacentChestZPos != null)
{
d2 += 0.5D;
}
if (this.adjacentChestXPos != null)
{
d1 += 0.5D;
}
this.worldObj.playSound(SoundEvent.CHESTOPEN, d1, (double)j + 0.5D, d2, 0.5F);
}
@ -393,21 +247,11 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
float f3 = 0.5F;
if (this.lidAngle < f3 && f2 >= f3 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null)
if (this.lidAngle < f3 && f2 >= f3)
{
double d3 = (double)i + 0.5D;
double d0 = (double)k + 0.5D;
if (this.adjacentChestZPos != null)
{
d0 += 0.5D;
}
if (this.adjacentChestXPos != null)
{
d3 += 0.5D;
}
this.worldObj.playSound(SoundEvent.CHESTCLOSED, d3, (double)j + 0.5D, d0, 0.5F);
}
@ -466,41 +310,6 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
return true;
}
/**
* invalidates a tile entity
*/
public void invalidate()
{
super.invalidate();
this.updateContainingBlockInfo();
this.checkForAdjacentChests();
}
public int getChestType()
{
if (this.cachedChestType == -1)
{
if (this.worldObj == null || !(this.getBlockType() instanceof BlockChest))
{
return 0;
}
this.cachedChestType = ((BlockChest)this.getBlockType()).chestType;
}
return this.cachedChestType;
}
public String getGuiID()
{
return "chest";
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
return new ContainerChest(playerInventory, this, playerIn);
}
public int getField(int id)
{
return 0;
@ -526,4 +335,14 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II
public int getColor() {
return 0xffff00;
}
public String getLockCode()
{
return this.code;
}
public void setLockCode(String code)
{
this.code = code;
}
}

View file

@ -4,18 +4,16 @@ import common.collect.Lists;
import common.entity.npc.EntityNPC;
import common.inventory.Container;
import common.inventory.ContainerDispenser;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.item.ItemStack;
import common.rng.Random;
import common.tags.TagObject;
import java.util.List;
public class TileEntityDispenser extends TileEntityLockable implements IInventory
public class TileEntityDispenser extends TileEntityInventory
{
private static final Random RNG = new Random();
private ItemStack[] stacks = new ItemStack[9];
protected String customName;
/**
* Returns the number of slots in the inventory.
@ -132,27 +130,6 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor
return -1;
}
/**
* Get the name of this object. For players this returns their username
*/
public String getName()
{
return this.hasCustomName() ? this.customName : "Werfer";
}
public void setCustomName(String customName)
{
this.customName = customName;
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return this.customName != null;
}
public void readTags(TagObject compound)
{
super.readTags(compound);
@ -169,11 +146,6 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor
this.stacks[j] = ItemStack.readFromTag(nbttagcompound);
}
}
if (compound.hasString("CustomName"))
{
this.customName = compound.getString("CustomName");
}
}
public void writeTags(TagObject compound)
@ -193,11 +165,6 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor
}
compound.setList("Items", nbttaglist);
if (this.hasCustomName())
{
compound.setString("CustomName", this.customName);
}
}
/**
@ -232,11 +199,6 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor
return true;
}
public String getGuiID()
{
return "dispenser";
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
return new ContainerDispenser(playerInventory, this);

View file

@ -2,16 +2,4 @@ package common.tileentity;
public class TileEntityDropper extends TileEntityDispenser
{
/**
* Get the name of this object. For players this returns their username
*/
public String getName()
{
return this.hasCustomName() ? this.customName : "Spender";
}
public String getGuiID()
{
return "dropper";
}
}

View file

@ -1,168 +0,0 @@
package common.tileentity;
import common.entity.npc.EntityNPC;
import common.inventory.Container;
import common.inventory.ContainerEnchantment;
import common.inventory.InventoryPlayer;
import common.rng.Random;
import common.tags.TagObject;
import common.util.ExtMath;
public class TileEntityEnchantmentTable extends TileEntity implements ITickable, IInteractionObject
{
public int tickCount;
public float pageFlip;
public float pageFlipPrev;
public float field_145932_k;
public float field_145929_l;
public float bookSpread;
public float bookSpreadPrev;
public float bookRotation;
public float bookRotationPrev;
public float field_145924_q;
private static Random rand = new Random();
private String customName;
public void writeTags(TagObject compound)
{
super.writeTags(compound);
if (this.hasCustomName())
{
compound.setString("CustomName", this.customName);
}
}
public void readTags(TagObject compound)
{
super.readTags(compound);
if (compound.hasString("CustomName"))
{
this.customName = compound.getString("CustomName");
}
}
/**
* Like the old updateEntity(), except more generic.
*/
public void update()
{
this.bookSpreadPrev = this.bookSpread;
this.bookRotationPrev = this.bookRotation;
EntityNPC entityplayer = this.worldObj.getClosestPlayer((double)((float)this.pos.getX() + 0.5F), (double)((float)this.pos.getY() + 0.5F), (double)((float)this.pos.getZ() + 0.5F), 3.0D);
if (entityplayer != null)
{
double d0 = entityplayer.posX - (double)((float)this.pos.getX() + 0.5F);
double d1 = entityplayer.posZ - (double)((float)this.pos.getZ() + 0.5F);
this.field_145924_q = (float)ExtMath.atan2(d1, d0);
this.bookSpread += 0.1F;
if (this.bookSpread < 0.5F || rand.zrange(40) == 0)
{
float f1 = this.field_145932_k;
while (true)
{
this.field_145932_k += (float)(rand.zrange(4) - rand.zrange(4));
if (f1 != this.field_145932_k)
{
break;
}
}
}
}
else
{
this.field_145924_q += 0.02F;
this.bookSpread -= 0.1F;
}
while (this.bookRotation >= (float)Math.PI)
{
this.bookRotation -= ((float)Math.PI * 2F);
}
while (this.bookRotation < -(float)Math.PI)
{
this.bookRotation += ((float)Math.PI * 2F);
}
while (this.field_145924_q >= (float)Math.PI)
{
this.field_145924_q -= ((float)Math.PI * 2F);
}
while (this.field_145924_q < -(float)Math.PI)
{
this.field_145924_q += ((float)Math.PI * 2F);
}
float f2;
for (f2 = this.field_145924_q - this.bookRotation; f2 >= (float)Math.PI; f2 -= ((float)Math.PI * 2F))
{
;
}
while (f2 < -(float)Math.PI)
{
f2 += ((float)Math.PI * 2F);
}
this.bookRotation += f2 * 0.4F;
this.bookSpread = ExtMath.clampf(this.bookSpread, 0.0F, 1.0F);
++this.tickCount;
this.pageFlipPrev = this.pageFlip;
float f = (this.field_145932_k - this.pageFlip) * 0.4F;
float f3 = 0.2F;
f = ExtMath.clampf(f, -f3, f3);
this.field_145929_l += (f - this.field_145929_l) * 0.9F;
this.pageFlip += this.field_145929_l;
}
/**
* Get the name of this object. For players this returns their username
*/
public String getName()
{
return this.hasCustomName() ? this.customName : "Verzaubern";
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return this.customName != null && this.customName.length() > 0;
}
public void setCustomName(String customNameIn)
{
this.customName = customNameIn;
}
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public String getCommandName()
{
return this.getName(); // (TextComponent)(this.hasCustomName() ? new TextComponent(this.getName()) : new TextComponent(this.getName()));
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
return new ContainerEnchantment(playerInventory, this.worldObj, this.pos);
}
public String getGuiID()
{
return "enchanting_table";
}
public int getColor() {
return 0xbf00ff;
}
}

View file

@ -29,7 +29,7 @@ import java.util.List;
import common.util.ExtMath;
import common.util.Facing;
public class TileEntityFurnace extends TileEntityLockable implements ITickable, ISidedInventory
public class TileEntityFurnace extends TileEntityInventory implements ITickable, ISidedInventory
{
private static final int[] slotsTop = new int[] {0};
private static final int[] slotsBottom = new int[] {2, 1};
@ -49,7 +49,6 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable,
private int currentItemBurnTime;
private int cookTime;
private int totalCookTime;
private String furnaceCustomName;
/**
* Returns the number of slots in the inventory.
@ -136,27 +135,6 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable,
}
}
/**
* Get the name of this object. For players this returns their username
*/
public String getName()
{
return this.hasCustomName() ? this.furnaceCustomName : "Ofen";
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return this.furnaceCustomName != null && this.furnaceCustomName.length() > 0;
}
public void setCustomInventoryName(String p_145951_1_)
{
this.furnaceCustomName = p_145951_1_;
}
public void readTags(TagObject compound)
{
super.readTags(compound);
@ -178,11 +156,6 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable,
this.cookTime = compound.getShort("CookTime");
this.totalCookTime = compound.getShort("CookTimeTotal");
this.currentItemBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);
if (compound.hasString("CustomName"))
{
this.furnaceCustomName = compound.getString("CustomName");
}
}
public void writeTags(TagObject compound)
@ -205,11 +178,6 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable,
}
compound.setList("Items", nbttaglist);
if (this.hasCustomName())
{
compound.setString("CustomName", this.furnaceCustomName);
}
}
/**
@ -398,7 +366,7 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable,
(item instanceof ItemBucket && ((ItemBucket)item).getLiquid() != null &&
((ItemBucket)item).getLiquid().getMaterial() == Material.LAVA ? 20000 :
(item.getBlock() instanceof BlockSapling ? 100 :
(item == Items.blaze_rod ? 2400 : 0))))))));
(item == Items.demon_rod ? 2400 : 0))))))));
}
}
@ -464,11 +432,6 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable,
return true;
}
public String getGuiID()
{
return "furnace";
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
return new ContainerFurnace(playerInventory, this);

View file

@ -25,10 +25,9 @@ import common.vars.Vars;
import common.world.State;
import common.world.World;
public class TileEntityHopper extends TileEntityLockable implements IHopper, ITickable
public class TileEntityHopper extends TileEntityInventory implements ITickable
{
private ItemStack[] inventory = new ItemStack[5];
private String customName;
private int transferCooldown = -1;
public void readTags(TagObject compound)
@ -37,11 +36,6 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
List<TagObject> nbttaglist = compound.getList("Items");
this.inventory = new ItemStack[this.getSizeInventory()];
if (compound.hasString("CustomName"))
{
this.customName = compound.getString("CustomName");
}
this.transferCooldown = compound.getInt("TransferCooldown");
for (int i = 0; i < nbttaglist.size(); ++i)
@ -74,11 +68,6 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
compound.setList("Items", nbttaglist);
compound.setInt("TransferCooldown", this.transferCooldown);
if (this.hasCustomName())
{
compound.setString("CustomName", this.customName);
}
}
/**
@ -167,27 +156,6 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
}
}
/**
* Get the name of this object. For players this returns their username
*/
public String getName()
{
return this.hasCustomName() ? this.customName : "Trichter";
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return this.customName != null && this.customName.length() > 0;
}
public void setCustomName(String customNameIn)
{
this.customName = customNameIn;
}
/**
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
*/
@ -413,7 +381,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
return true;
}
public static boolean captureDroppedItems(IHopper p_145891_0_)
public static boolean captureDroppedItems(TileEntityHopper p_145891_0_)
{
IInventory iinventory = getHopperInventory(p_145891_0_);
@ -470,7 +438,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
* Pulls from the specified slot in the inventory and places in any available slot in the hopper. Returns true if
* the entire stack was moved
*/
public static boolean pullItemFromSlot(IHopper hopper, IInventory inventoryIn, int index, Facing direction)
public static boolean pullItemFromSlot(TileEntityHopper hopper, IInventory inventoryIn, int index, Facing direction)
{
ItemStack itemstack = inventoryIn.getStackInSlot(index);
@ -631,7 +599,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
/**
* Returns the IInventory for the specified hopper
*/
public static IInventory getHopperInventory(IHopper hopper)
public static IInventory getHopperInventory(TileEntityHopper hopper)
{
return getInventoryAtPosition(hopper.getWorld(), hopper.getXPos(), hopper.getYPos() + 1.0D, hopper.getZPos());
}
@ -667,7 +635,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
if (iinventory instanceof TileEntityChest && block instanceof BlockChest)
{
iinventory = ((BlockChest)block).getLockableContainer(worldIn, blockpos);
iinventory = ((BlockChest)block).getChest(worldIn, blockpos);
}
}
}
@ -733,11 +701,6 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi
return this.transferCooldown <= 1;
}
public String getGuiID()
{
return "hopper";
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
return new ContainerHopper(playerInventory, this, playerIn);

View file

@ -0,0 +1,10 @@
package common.tileentity;
import common.entity.npc.EntityNPC;
import common.inventory.Container;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
public abstract class TileEntityInventory extends TileEntity implements IInventory {
public abstract Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn);
}

View file

@ -1,50 +0,0 @@
package common.tileentity;
import common.tags.TagObject;
public abstract class TileEntityLockable extends TileEntity implements IInteractionObject, ILockableContainer
{
private Passcode code = Passcode.EMPTY_CODE;
public void readTags(TagObject compound)
{
super.readTags(compound);
this.code = Passcode.fromTag(compound);
}
public void writeTags(TagObject compound)
{
super.writeTags(compound);
if (this.code != null)
{
this.code.toTag(compound);
}
}
public boolean isLocked()
{
return this.code != null && !this.code.empty();
}
public Passcode getLockCode()
{
return this.code;
}
public void setLockCode(Passcode code)
{
this.code = code;
}
public abstract String getName();
public abstract boolean hasCustomName();
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public String getCommandName()
{
return this.getName(); // (TextComponent)(this.hasCustomName() ? new TextComponent(this.getName()) : new TextComponent(this.getName()));
}
}