1
0
Fork 0

device fixes, prepare for pipes

This commit is contained in:
Sen 2025-08-12 00:45:13 +02:00
parent 08acee12b7
commit 43b097eac3
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
93 changed files with 716 additions and 2628 deletions

View file

@ -1,32 +0,0 @@
package client.gui.container;
import common.init.Blocks;
import common.inventory.ContainerBrewingStand;
import common.inventory.IInventory;
import common.entity.npc.EntityNPC;
public class GuiBrewing extends GuiContainer {
private final EntityNPC playerInv;
private final IInventory brewer;
public GuiBrewing(EntityNPC player, IInventory brewer) {
super(new ContainerBrewingStand(player, brewer));
this.playerInv = player;
this.brewer = brewer;
}
public void draw() {
super.draw();
int progress = this.brewer.getField(0);
if(progress > 0) {
int value = (int)(28.0F * (1.0F - (float)progress / 400.0F));
if(value > 0)
this.rect(97, 16, 9, value, 0xffff20);
}
}
public void addElements() {
this.label(Blocks.brewing_stand.getDisplay(), 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
}
}

View file

@ -1,20 +0,0 @@
package client.gui.container;
import common.block.tech.BlockDispenser;
import common.inventory.ContainerDispenser;
import common.inventory.IInventory;
import common.entity.npc.EntityNPC;
public class GuiDispenser extends GuiContainer {
private final BlockDispenser block;
public GuiDispenser(EntityNPC playerInv, IInventory dispenser, BlockDispenser block) {
super(new ContainerDispenser(playerInv, dispenser));
this.block = block;
}
public void addElements() {
this.label(this.block.getDisplay(), 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
}
}

View file

@ -1,19 +0,0 @@
package client.gui.container;
import client.Client;
import common.init.Blocks;
import common.inventory.ContainerHopper;
import common.inventory.IInventory;
import common.entity.npc.EntityNPC;
public class GuiHopper extends GuiContainer {
public GuiHopper(EntityNPC playerInv, IInventory hopper) {
super(new ContainerHopper(playerInv, hopper, Client.CLIENT.player));
this.ySize = 133;
}
public void addElements() {
this.label(Blocks.hopper.getDisplay(), 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
}
}

View file

@ -7,12 +7,9 @@ import client.gui.Gui;
import client.gui.GuiConsole;
import client.gui.character.GuiChar;
import client.gui.character.GuiCharacters;
import client.gui.container.GuiBrewing;
import client.gui.container.GuiChest;
import client.gui.container.GuiCrafting;
import client.gui.container.GuiDispenser;
import client.gui.container.GuiEnchant;
import client.gui.container.GuiHopper;
import client.gui.container.GuiEntity;
import client.gui.container.GuiDevice;
import client.gui.container.GuiMerchant;
@ -26,7 +23,6 @@ import client.world.ChunkClient;
import common.block.Block;
import common.block.tech.BlockAnvil;
import common.block.tech.BlockChest;
import common.block.tech.BlockDispenser;
import common.block.tech.BlockWorkbench;
import common.dimension.DimType;
import common.dimension.Dimension;
@ -1073,7 +1069,7 @@ public class ClientPlayer implements IClientPlayer
TileEntity tile = this.world.getTileEntity(packet.getTilePos());
if(!(tile instanceof Device dev))
return;
this.gm.show(new GuiDevice(player, new LocalContainer(slots), dev));
this.gm.show(new GuiDevice(player, new InventoryBasic(slots), dev));
}
else if (packet.getEntityId() != -1)
{
@ -1088,34 +1084,22 @@ public class ClientPlayer implements IClientPlayer
else if (block == Blocks.warp_chest)
{
this.gm.show(new GuiChest(player, new InventoryWarpChest(), block));
}
else if (block == Blocks.enchanting_table)
{
this.gm.show(new GuiEnchant(player, player.worldObj));
}
else if (block instanceof BlockAnvil)
{
this.gm.show(new GuiRepair(player, player.worldObj));
}
else if (block instanceof BlockChest)
{
this.gm.show(new GuiChest(player, new InventoryBasic(slots), block));
}
else if (block == Blocks.hopper)
{
this.gm.show(new GuiHopper(player, new InventoryBasic(slots)));
}
else if (block == Blocks.brewing_stand)
{
this.gm.show(new GuiBrewing(player, new LocalContainer(slots)));
}
else if (block instanceof BlockDispenser dispenser)
{
this.gm.show(new GuiDispenser(player, new InventoryBasic(slots), dispenser));
}
else if(block instanceof BlockWorkbench bench) {
this.gm.show(new GuiCrafting(player, player.worldObj, bench));
}
else if (block instanceof BlockAnvil)
{
this.gm.show(new GuiRepair(player, player.worldObj));
}
else if (block == Blocks.enchanting_table)
{
this.gm.show(new GuiEnchant(player, player.worldObj));
}
else {
return;
}

View file

@ -1,27 +0,0 @@
package client.network;
import java.util.Map;
import common.collect.Maps;
import common.inventory.IInventory;
import common.inventory.InventoryBasic;
public class LocalContainer extends InventoryBasic implements IInventory {
private Map<Integer, Integer> fields = Maps.<Integer, Integer>newHashMap();
public LocalContainer(int slotCount) {
super(slotCount);
}
public int getField(int id) {
return this.fields.containsKey(Integer.valueOf(id)) ? ((Integer)this.fields.get(Integer.valueOf(id))).intValue() : 0;
}
public void setField(int id, int value) {
this.fields.put(Integer.valueOf(id), Integer.valueOf(value));
}
public int getFieldCount() {
return this.fields.size();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

View file

Before

Width:  |  Height:  |  Size: 495 B

After

Width:  |  Height:  |  Size: 495 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 749 B

View file

Before

Width:  |  Height:  |  Size: 713 B

After

Width:  |  Height:  |  Size: 713 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

View file

Before

Width:  |  Height:  |  Size: 422 B

After

Width:  |  Height:  |  Size: 422 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 531 B

After

Width:  |  Height:  |  Size: 531 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 406 B

After

Width:  |  Height:  |  Size: 406 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

View file

@ -2,16 +2,12 @@ package common.block.tech;
import java.util.List;
import common.block.Block;
import common.block.ITileEntityProvider;
import common.block.Material;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.model.Model;
import common.model.Model.ModelProvider;
import common.rng.Random;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityBrewingStand;
import common.tileentity.DeviceBrewer;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Clientside;
@ -19,96 +15,41 @@ import common.util.Facing;
import common.util.ParticleType;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockBrewingStand extends Block implements ITileEntityProvider
{
public BlockBrewingStand()
{
super(Material.SOLID);
}
public class BlockBrewingStand extends BlockMachine {
public boolean isFullCube() {
return false;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isOpaqueCube() {
return false;
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity()
{
return new TileEntityBrewingStand();
}
public TileEntity createNewTileEntity() {
return new DeviceBrewer();
}
public boolean isFullCube()
{
return false;
}
public void getCollisionBoxes(World worldIn, BlockPos pos, State state, BoundingBox mask, List<BoundingBox> list, Entity collidingEntity) {
this.setBlockBounds(0.4375F, 0.0F, 0.4375F, 0.5625F, 0.875F, 0.5625F);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
}
/**
* Add all collision boxes of this Block to the list that intersect with the given mask.
*/
public void getCollisionBoxes(World worldIn, BlockPos pos, State state, BoundingBox mask, List<BoundingBox> list, Entity collidingEntity)
{
this.setBlockBounds(0.4375F, 0.0F, 0.4375F, 0.5625F, 0.875F, 0.5625F);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
}
@Clientside
public void displayTick(World worldIn, BlockPos pos, State state, Random rand) {
double d0 = (double)((float)pos.getX() + 0.4F + rand.floatv() * 0.2F);
double d1 = (double)((float)pos.getY() + 0.7F + rand.floatv() * 0.3F);
double d2 = (double)((float)pos.getZ() + 0.4F + rand.floatv() * 0.2F);
worldIn.clientParticle(ParticleType.SMOKE, d0, d1, d2);
}
public boolean onUse(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 TileEntityBrewingStand)
{
playerIn.connection.show((TileEntityBrewingStand)tileentity);
// playerIn.triggerAchievement(StatRegistry.brewingStat);
}
return true;
}
}
public void displayTick(World worldIn, BlockPos pos, State state, Random rand)
{
double d0 = (double)((float)pos.getX() + 0.4F + rand.floatv() * 0.2F);
double d1 = (double)((float)pos.getY() + 0.7F + rand.floatv() * 0.3F);
double d2 = (double)((float)pos.getZ() + 0.4F + rand.floatv() * 0.2F);
worldIn.clientParticle(ParticleType.SMOKE, d0, d1, d2);
}
public void onRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityBrewingStand)
{
dropItems(worldIn, pos, (TileEntityBrewingStand)tileentity);
}
super.onRemoved(worldIn, pos, state);
}
@Clientside
public boolean hasTransparency() {
@Clientside
public boolean hasTransparency() {
return true;
}
public boolean isMagnetic() {
return true;
}
@Clientside
public Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel("brewing_stand")
.add(7, 0, 7, 9, 14, 9)

View file

@ -183,6 +183,12 @@ public class BlockChest extends Block implements ITileEntityProvider, Rotatable
chest.setCustomName(stack.getDisplayName());
return true;
}
if(chest.getLockCode() != null && !playerIn.canOpen(chest.getLockCode())) {
playerIn.connection.addHotbar(Color.RED + "%s ist verschlossen!", chest.getName());
playerIn.connection.sendPacket(new SPacketSoundEffect(SoundEvent.DOOR, playerIn.posX, playerIn.posY, playerIn.posZ, 1.0F));
return true;
}
chest.onOpened();
playerIn.connection.show(chest);
}

View file

@ -1,178 +1,46 @@
package common.block.tech;
import common.block.Block;
import common.block.Directional;
import common.block.ITileEntityProvider;
import common.block.Material;
import common.entity.item.EntityItem;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.item.CheatTab;
import common.item.ItemStack;
import common.model.Model;
import common.model.Model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.rng.Random;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityDispenser;
import common.tileentity.DeviceDispenser;
import common.util.BlockPos;
import common.util.Facing;
import common.util.Vec3;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockDispenser extends Block implements ITileEntityProvider, Directional
{
protected Random rand = new Random();
public static void dispense(AWorldServer world, double speed, Facing facing, Vec3 position, ItemStack stack)
{
EntityItem entity = new EntityItem(world, position.xCoord, position.yCoord - (facing.getAxis() == Facing.Axis.Y ? 0.125 : 0.15625), position.zCoord, stack);
double velo = world.rand.doublev() * 0.1 + 0.2;
entity.motionX = (double)facing.getFrontOffsetX() * velo + world.rand.gaussian() * 0.0075 * speed;
entity.motionY = 0.2 + world.rand.gaussian() * 0.0075 * speed;
entity.motionZ = (double)facing.getFrontOffsetZ() * velo + world.rand.gaussian() * 0.0075 * speed;
world.spawnEntityInWorld(entity);
}
public class BlockDispenser extends BlockMachine {
private final boolean dropItems;
public BlockDispenser()
{
super(Material.SOLID);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
this.setTab(CheatTab.TECHNOLOGY);
}
public static void dispense(AWorldServer world, double speed, Facing facing, Vec3 position, ItemStack stack) {
EntityItem entity = new EntityItem(world, position.xCoord, position.yCoord - (facing.getAxis() == Facing.Axis.Y ? 0.125 : 0.15625), position.zCoord, stack);
double velo = world.rand.doublev() * 0.1 + 0.2;
entity.motionX = (double)facing.getFrontOffsetX() * velo + world.rand.gaussian() * 0.0075 * speed;
entity.motionY = 0.2 + world.rand.gaussian() * 0.0075 * speed;
entity.motionZ = (double)facing.getFrontOffsetZ() * velo + world.rand.gaussian() * 0.0075 * speed;
world.spawnEntityInWorld(entity);
}
/**
* How many world ticks before ticking
*/
public int tickRate(World worldIn, BlockPos pos)
{
return 4;
}
public static Vec3 getDispensePosition(BlockPos pos, Facing facing) {
double d0 = pos.getX() + 0.5 + 0.7D * (double)facing.getFrontOffsetX();
double d1 = pos.getY() + 0.5 + 0.7D * (double)facing.getFrontOffsetY();
double d2 = pos.getZ() + 0.5 + 0.7D * (double)facing.getFrontOffsetZ();
return new Vec3(d0, d1, d2);
}
public void onAdded(AWorldServer worldIn, BlockPos pos, State state)
{
super.onAdded(worldIn, pos, state);
this.setDefaultDirection(worldIn, pos, state);
}
public BlockDispenser(boolean dropItems) {
this.dropItems = dropItems;
}
private void setDefaultDirection(World worldIn, BlockPos pos, State state)
{
if (!worldIn.client)
{
Facing enumfacing = (Facing)state.getValue(FACING);
boolean flag = worldIn.getState(pos.north()).getBlock().isFullBlock();
boolean flag1 = worldIn.getState(pos.south()).getBlock().isFullBlock();
public TileEntity createNewTileEntity() {
return new DeviceDispenser(this.dropItems);
}
if (enumfacing == Facing.NORTH && flag && !flag1)
{
enumfacing = Facing.SOUTH;
}
else if (enumfacing == Facing.SOUTH && flag1 && !flag)
{
enumfacing = Facing.NORTH;
}
else
{
boolean flag2 = worldIn.getState(pos.west()).getBlock().isFullBlock();
boolean flag3 = worldIn.getState(pos.east()).getBlock().isFullBlock();
if (enumfacing == Facing.WEST && flag2 && !flag3)
{
enumfacing = Facing.EAST;
}
else if (enumfacing == Facing.EAST && flag3 && !flag2)
{
enumfacing = Facing.WEST;
}
}
worldIn.setState(pos, state.withProperty(FACING, enumfacing), 2);
}
}
public boolean onUse(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 TileEntityDispenser)
{
playerIn.connection.show((TileEntityDispenser)tileentity);
// if (tileentity instanceof TileEntityDropper)
// {
// playerIn.triggerAchievement(StatRegistry.dropperStat);
// }
// else
// {
// playerIn.triggerAchievement(StatRegistry.dispenserStat);
// }
}
return true;
}
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity()
{
return new TileEntityDispenser();
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public State getPlacedState(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{
return this.getState().withProperty(FACING, BlockPistonBase.getFacingFromEntity(worldIn, pos, placer));
}
public void onRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityDispenser)
{
dropItems(worldIn, pos, (TileEntityDispenser)tileentity);
}
super.onRemoved(worldIn, pos, state);
}
public static Vec3 getDispensePosition(BlockPos pos, Facing facing)
{
double d0 = pos.getX() + 0.5 + 0.7D * (double)facing.getFrontOffsetX();
double d1 = pos.getY() + 0.5 + 0.7D * (double)facing.getFrontOffsetY();
double d2 = pos.getZ() + 0.5 + 0.7D * (double)facing.getFrontOffsetZ();
return new Vec3(d0, d1, d2);
}
protected Property[] getProperties()
{
return new Property[] {FACING};
}
public boolean isMagnetic() {
return true;
}
public Model getModel(ModelProvider provider, String name, State state) {
if(state.getValue(FACING) == Facing.DOWN || state.getValue(FACING) == Facing.UP)
return provider.getModel("dispenser_top").add().dnswe().u(name + "_front_vertical")
.rotate(state.getValue(FACING) == Facing.DOWN ? ModelRotation.X180_Y0 : ModelRotation.X0_Y0);
else
return provider.getModel(name + "_front_horizontal").add().du("dispenser_top").n()
.s("dispenser_side").we("dispenser_side").rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
public Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel(name + "_front").add().du("dispenser_top").n().s("dispenser_side").we("dispenser_side").rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
}

View file

@ -1,12 +0,0 @@
package common.block.tech;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityDropper;
public class BlockDropper extends BlockDispenser
{
public TileEntity createNewTileEntity()
{
return new TileEntityDropper();
}
}

View file

@ -3,7 +3,6 @@ package common.block.tech;
import java.util.List;
import common.block.Block;
import common.block.Material;
import common.block.SoundType;
import common.entity.npc.EntityNPC;
import common.item.Item;
@ -33,7 +32,6 @@ public class BlockFurnace extends BlockMachine {
private BlockFurnace other;
private BlockFurnace(boolean isBurning, int burnTime, int fuelEfficiency) {
super(Material.SOLID);
this.isBurning = isBurning;
this.burnTime = burnTime;
this.fuelEfficiency = fuelEfficiency;
@ -121,13 +119,14 @@ public class BlockFurnace extends BlockMachine {
}
public void setState(boolean active, World worldIn, BlockPos pos) {
BlockFurnace block = this.isBurning == active ? this : this.other;
State iblockstate = worldIn.getState(pos);
if(iblockstate.getBlock() != this || ((BlockFurnace)iblockstate.getBlock()).isBurning == active)
if(iblockstate.getBlock() == block)
return;
TileEntity tileentity = worldIn.getTileEntity(pos);
keepInventory = true;
worldIn.setState(pos, this.other.getState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
worldIn.setState(pos, this.other.getState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
worldIn.setState(pos, block.getState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
worldIn.setState(pos, block.getState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
keepInventory = false;
if(tileentity != null) {
tileentity.validate();

View file

@ -1,248 +0,0 @@
package common.block.tech;
import java.util.List;
import common.block.Block;
import common.block.Directional;
import common.block.ITileEntityProvider;
import common.block.Material;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.item.CheatTab;
import common.model.Model;
import common.model.Model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityHopper;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Clientside;
import common.util.Facing;
import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockHopper extends Block implements ITileEntityProvider, Directional
{
public BlockHopper()
{
super(Material.SOLID);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.DOWN));
this.setTab(CheatTab.TECHNOLOGY);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void setBlockBounds(IWorldAccess worldIn, BlockPos pos)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
/**
* Add all collision boxes of this Block to the list that intersect with the given mask.
*/
public void getCollisionBoxes(World worldIn, BlockPos pos, State state, BoundingBox mask, List<BoundingBox> list, Entity collidingEntity)
{
boolean flip = state.getBlock() == this && state.getValue(FACING) == Facing.UP;
this.setBlockBounds(0.0F, flip ? 0.375f : 0.0F, 0.0F, 1.0F, flip ? 1.0f : 0.625F, 1.0F);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
float f = 0.125F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public State getPlacedState(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{
return this.getState().withProperty(FACING, facing.getOpposite());
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity()
{
return new TileEntityHopper();
}
public boolean onUse(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 TileEntityHopper)
{
playerIn.connection.show((TileEntityHopper)tileentity);
}
return true;
}
}
public void onRemoved(AWorldServer worldIn, BlockPos pos, State state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityHopper)
{
dropItems(worldIn, pos, (TileEntityHopper)tileentity);
}
super.onRemoved(worldIn, pos, state);
}
public boolean isFullCube()
{
return false;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean canRender(IWorldAccess worldIn, BlockPos pos, Facing side)
{
return true;
}
@Clientside
public boolean hasTransparency() {
return true;
}
protected Property[] getProperties()
{
return new Property[] {FACING};
}
public boolean isMagnetic() {
return true;
}
public Model getModel(ModelProvider provider, String name, State state) {
if(state.getValue(FACING).getAxis().isVertical())
return provider.getModel("hopper_outside")
.add(0, 10, 0, 16, 11, 16)
.d().uv(0, 0, 16, 16).noCull()
.u("hopper_inside").uv(0, 0, 16, 16).noCull()
.n().uv(0, 5, 16, 6).noCull()
.s().uv(0, 5, 16, 6).noCull()
.w().uv(0, 5, 16, 6).noCull()
.e().uv(0, 5, 16, 6).noCull()
.add(0, 11, 0, 2, 16, 16)
.d().uv(0, 0, 2, 16).noCull()
.u("hopper_top").uv(0, 0, 2, 16).noCull()
.n().uv(0, 0, 2, 5).noCull()
.s().uv(0, 0, 2, 5).noCull()
.w().uv(0, 0, 16, 5).noCull()
.e().uv(0, 0, 16, 5).noCull()
.add(14, 11, 0, 16, 16, 16)
.d().uv(14, 0, 16, 16).noCull()
.u("hopper_top").uv(14, 0, 16, 16).noCull()
.n().uv(14, 0, 16, 5).noCull()
.s().uv(14, 0, 16, 5).noCull()
.w().uv(0, 0, 16, 5).noCull()
.e().uv(0, 0, 16, 5).noCull()
.add(2, 11, 0, 14, 16, 2)
.d().uv(2, 0, 14, 2).noCull()
.u("hopper_top").uv(2, 0, 14, 2).noCull()
.n().uv(2, 0, 14, 5).noCull()
.s().uv(2, 0, 14, 5).noCull()
.w().uv(0, 0, 2, 5).noCull()
.e().uv(0, 0, 2, 5).noCull()
.add(2, 11, 14, 14, 16, 16)
.d().uv(2, 14, 14, 16).noCull()
.u("hopper_top").uv(2, 14, 14, 16).noCull()
.n().uv(2, 0, 14, 5).noCull()
.s().uv(2, 0, 14, 5).noCull()
.w().uv(14, 0, 16, 5).noCull()
.e().uv(14, 0, 16, 5).noCull()
.add(4, 4, 4, 12, 10, 12)
.d().uv(4, 4, 12, 12).noCull()
.u().uv(4, 4, 12, 12).noCull()
.n().uv(4, 6, 12, 12).noCull()
.s().uv(4, 6, 12, 12).noCull()
.w().uv(4, 6, 12, 12).noCull()
.e().uv(4, 6, 12, 12).noCull()
.add(6, 0, 6, 10, 4, 10)
.d().uv(6, 6, 10, 10).noCull()
.u().uv(6, 6, 10, 10).noCull()
.n().uv(6, 12, 10, 16).noCull()
.s().uv(6, 12, 10, 16).noCull()
.w().uv(6, 12, 10, 16).noCull()
.e().uv(6, 12, 10, 16).noCull().rotate(state.getValue(FACING) == Facing.UP ? ModelRotation.X180_Y0 : ModelRotation.X0_Y0);
else
return provider.getModel("hopper_outside")
.add(0, 10, 0, 16, 11, 16)
.d().uv(0, 0, 16, 16).noCull()
.u("hopper_inside").uv(0, 0, 16, 16).noCull()
.n().uv(0, 5, 16, 6).noCull()
.s().uv(0, 5, 16, 6).noCull()
.w().uv(0, 5, 16, 6).noCull()
.e().uv(0, 5, 16, 6).noCull()
.add(0, 11, 0, 2, 16, 16)
.d().uv(0, 0, 2, 16).noCull()
.u("hopper_top").uv(0, 0, 2, 16).noCull()
.n().uv(0, 0, 2, 5).noCull()
.s().uv(0, 0, 2, 5).noCull()
.w().uv(0, 0, 16, 5).noCull()
.e().uv(0, 0, 16, 5).noCull()
.add(14, 11, 0, 16, 16, 16)
.d().uv(14, 0, 16, 16).noCull()
.u("hopper_top").uv(14, 0, 16, 16).noCull()
.n().uv(14, 0, 16, 5).noCull()
.s().uv(14, 0, 16, 5).noCull()
.w().uv(0, 0, 16, 5).noCull()
.e().uv(0, 0, 16, 5).noCull()
.add(2, 11, 0, 14, 16, 2)
.d().uv(2, 0, 14, 2).noCull()
.u("hopper_top").uv(2, 0, 14, 2).noCull()
.n().uv(2, 0, 14, 5).noCull()
.s().uv(2, 0, 14, 5).noCull()
.w().uv(0, 0, 2, 5).noCull()
.e().uv(0, 0, 2, 5).noCull()
.add(2, 11, 14, 14, 16, 16)
.d().uv(2, 14, 14, 16).noCull()
.u("hopper_top").uv(2, 14, 14, 16).noCull()
.n().uv(2, 0, 14, 5).noCull()
.s().uv(2, 0, 14, 5).noCull()
.w().uv(14, 0, 16, 5).noCull()
.e().uv(14, 0, 16, 5).noCull()
.add(4, 4, 4, 12, 10, 12)
.d().uv(4, 4, 12, 12).noCull()
.u().uv(4, 4, 12, 12).noCull()
.n().uv(4, 6, 12, 12).noCull()
.s().uv(4, 6, 12, 12).noCull()
.w().uv(4, 6, 12, 12).noCull()
.e().uv(4, 6, 12, 12).noCull()
.add(6, 4, 0, 10, 8, 4)
.d().uv(6, 0, 10, 4).noCull()
.u().uv(6, 0, 10, 4).noCull()
.n().uv(6, 8, 10, 12).noCull()
.s().uv(6, 8, 10, 12).noCull()
.w().uv(0, 8, 4, 12).noCull()
.e().uv(0, 8, 4, 12).noCull()
.rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
}

View file

@ -29,10 +29,6 @@ public abstract class BlockMachine extends Block implements Rotatable, ITileEnti
public abstract TileEntity createNewTileEntity();
public void onAdded(AWorldServer worldIn, BlockPos pos, State state) {
this.updateState(worldIn, pos, state);
}
public boolean onUse(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY,
float hitZ) {
if(worldIn.client)
@ -43,13 +39,6 @@ public abstract class BlockMachine extends Block implements Rotatable, ITileEnti
return true;
}
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock) {
this.updateState(worldIn, pos, state);
}
private void updateState(World worldIn, BlockPos pos, State state) {
}
public void onRemoved(AWorldServer worldIn, BlockPos pos, State state) {
TileEntity tileentity = worldIn.getTileEntity(pos);
if(tileentity instanceof Device) {

View file

@ -0,0 +1,221 @@
package common.block.tech;
import java.util.List;
import common.block.Block;
import common.block.Directional;
import common.block.ITileEntityProvider;
import common.block.Material;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.item.CheatTab;
import common.model.Model;
import common.model.Model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityPipe;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Clientside;
import common.util.Facing;
import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockPipe extends Block implements ITileEntityProvider, Directional {
public BlockPipe() {
super(Material.SOLID);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.DOWN));
this.setTab(CheatTab.TECHNOLOGY);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void setBlockBounds(IWorldAccess worldIn, BlockPos pos) {
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void getCollisionBoxes(World worldIn, BlockPos pos, State state, BoundingBox mask, List<BoundingBox> list, Entity collidingEntity) {
boolean flip = state.getBlock() == this && state.getValue(FACING) == Facing.UP;
this.setBlockBounds(0.0F, flip ? 0.375f : 0.0F, 0.0F, 1.0F, flip ? 1.0f : 0.625F, 1.0F);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
float f = 0.125F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public State getPlacedState(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer) {
return this.getState().withProperty(FACING, facing.getOpposite());
}
public TileEntity createNewTileEntity() {
return new TileEntityPipe();
}
public boolean onUse(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 TileEntityPipe) {
// TODO: edit direction
}
return true;
}
}
public void onRemoved(AWorldServer worldIn, BlockPos pos, State state) {
TileEntity tileentity = worldIn.getTileEntity(pos);
if(tileentity instanceof TileEntityPipe) {
dropItems(worldIn, pos, (TileEntityPipe)tileentity);
}
super.onRemoved(worldIn, pos, state);
}
public boolean isFullCube() {
return false;
}
public boolean isOpaqueCube() {
return false;
}
@Clientside
public boolean canRender(IWorldAccess worldIn, BlockPos pos, Facing side) {
return true;
}
@Clientside
public boolean hasTransparency() {
return true;
}
protected Property[] getProperties() {
return new Property[] {FACING};
}
public boolean isMagnetic() {
return true;
}
@Clientside
public Model getModel(ModelProvider provider, String name, State state) {
if(state.getValue(FACING).getAxis().isVertical())
return provider.getModel("pipe_outside")
.add(0, 10, 0, 16, 11, 16)
.d().uv(0, 0, 16, 16).noCull()
.u("pipe_inside").uv(0, 0, 16, 16).noCull()
.n().uv(0, 5, 16, 6).noCull()
.s().uv(0, 5, 16, 6).noCull()
.w().uv(0, 5, 16, 6).noCull()
.e().uv(0, 5, 16, 6).noCull()
.add(0, 11, 0, 2, 16, 16)
.d().uv(0, 0, 2, 16).noCull()
.u("pipe_top").uv(0, 0, 2, 16).noCull()
.n().uv(0, 0, 2, 5).noCull()
.s().uv(0, 0, 2, 5).noCull()
.w().uv(0, 0, 16, 5).noCull()
.e().uv(0, 0, 16, 5).noCull()
.add(14, 11, 0, 16, 16, 16)
.d().uv(14, 0, 16, 16).noCull()
.u("pipe_top").uv(14, 0, 16, 16).noCull()
.n().uv(14, 0, 16, 5).noCull()
.s().uv(14, 0, 16, 5).noCull()
.w().uv(0, 0, 16, 5).noCull()
.e().uv(0, 0, 16, 5).noCull()
.add(2, 11, 0, 14, 16, 2)
.d().uv(2, 0, 14, 2).noCull()
.u("pipe_top").uv(2, 0, 14, 2).noCull()
.n().uv(2, 0, 14, 5).noCull()
.s().uv(2, 0, 14, 5).noCull()
.w().uv(0, 0, 2, 5).noCull()
.e().uv(0, 0, 2, 5).noCull()
.add(2, 11, 14, 14, 16, 16)
.d().uv(2, 14, 14, 16).noCull()
.u("pipe_top").uv(2, 14, 14, 16).noCull()
.n().uv(2, 0, 14, 5).noCull()
.s().uv(2, 0, 14, 5).noCull()
.w().uv(14, 0, 16, 5).noCull()
.e().uv(14, 0, 16, 5).noCull()
.add(4, 4, 4, 12, 10, 12)
.d().uv(4, 4, 12, 12).noCull()
.u().uv(4, 4, 12, 12).noCull()
.n().uv(4, 6, 12, 12).noCull()
.s().uv(4, 6, 12, 12).noCull()
.w().uv(4, 6, 12, 12).noCull()
.e().uv(4, 6, 12, 12).noCull()
.add(6, 0, 6, 10, 4, 10)
.d().uv(6, 6, 10, 10).noCull()
.u().uv(6, 6, 10, 10).noCull()
.n().uv(6, 12, 10, 16).noCull()
.s().uv(6, 12, 10, 16).noCull()
.w().uv(6, 12, 10, 16).noCull()
.e().uv(6, 12, 10, 16).noCull().rotate(state.getValue(FACING) == Facing.UP ? ModelRotation.X180_Y0 : ModelRotation.X0_Y0);
else
return provider.getModel("pipe_outside")
.add(0, 10, 0, 16, 11, 16)
.d().uv(0, 0, 16, 16).noCull()
.u("pipe_inside").uv(0, 0, 16, 16).noCull()
.n().uv(0, 5, 16, 6).noCull()
.s().uv(0, 5, 16, 6).noCull()
.w().uv(0, 5, 16, 6).noCull()
.e().uv(0, 5, 16, 6).noCull()
.add(0, 11, 0, 2, 16, 16)
.d().uv(0, 0, 2, 16).noCull()
.u("pipe_top").uv(0, 0, 2, 16).noCull()
.n().uv(0, 0, 2, 5).noCull()
.s().uv(0, 0, 2, 5).noCull()
.w().uv(0, 0, 16, 5).noCull()
.e().uv(0, 0, 16, 5).noCull()
.add(14, 11, 0, 16, 16, 16)
.d().uv(14, 0, 16, 16).noCull()
.u("pipe_top").uv(14, 0, 16, 16).noCull()
.n().uv(14, 0, 16, 5).noCull()
.s().uv(14, 0, 16, 5).noCull()
.w().uv(0, 0, 16, 5).noCull()
.e().uv(0, 0, 16, 5).noCull()
.add(2, 11, 0, 14, 16, 2)
.d().uv(2, 0, 14, 2).noCull()
.u("pipe_top").uv(2, 0, 14, 2).noCull()
.n().uv(2, 0, 14, 5).noCull()
.s().uv(2, 0, 14, 5).noCull()
.w().uv(0, 0, 2, 5).noCull()
.e().uv(0, 0, 2, 5).noCull()
.add(2, 11, 14, 14, 16, 16)
.d().uv(2, 14, 14, 16).noCull()
.u("pipe_top").uv(2, 14, 14, 16).noCull()
.n().uv(2, 0, 14, 5).noCull()
.s().uv(2, 0, 14, 5).noCull()
.w().uv(14, 0, 16, 5).noCull()
.e().uv(14, 0, 16, 5).noCull()
.add(4, 4, 4, 12, 10, 12)
.d().uv(4, 4, 12, 12).noCull()
.u().uv(4, 4, 12, 12).noCull()
.n().uv(4, 6, 12, 12).noCull()
.s().uv(4, 6, 12, 12).noCull()
.w().uv(4, 6, 12, 12).noCull()
.e().uv(4, 6, 12, 12).noCull()
.add(6, 4, 0, 10, 8, 4)
.d().uv(6, 0, 10, 4).noCull()
.u().uv(6, 0, 10, 4).noCull()
.n().uv(6, 8, 10, 12).noCull()
.s().uv(6, 8, 10, 12).noCull()
.w().uv(0, 8, 4, 12).noCull()
.e().uv(0, 8, 4, 12).noCull()
.rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
}

View file

@ -90,7 +90,7 @@ public class BlockWarpChest extends Block implements Rotatable
public boolean onUse(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
{
if(!worldIn.client) {
playerIn.getWarpChest().setWarpChest(pos);
playerIn.getWarpChest().setPosition(pos);
playerIn.connection.show(new WarpChest());
}
return true;

View file

@ -2561,7 +2561,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
{
for (int i = 0; i < this.getInventoryCapacity(); ++i)
{
if (this.getInventory()[i] != null && this.getInventory()[i].getItem() == itemStackIn.getItem() && this.getInventory()[i].isStackable() && !this.getInventory()[i].isFull() && this.getInventory()[i].getSize() < this.getInventoryStackLimit() && ItemStack.dataEquals(this.getInventory()[i], itemStackIn))
if (this.getInventory()[i] != null && this.getInventory()[i].getItem() == itemStackIn.getItem() && this.getInventory()[i].isStackable() && !this.getInventory()[i].isFull() && ItemStack.dataEquals(this.getInventory()[i], itemStackIn))
{
return i;
}
@ -2614,11 +2614,6 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
k = this.getInventory()[j].getMaxStackSize() - this.getInventory()[j].getSize();
}
if (k > this.getInventoryStackLimit() - this.getInventory()[j].getSize())
{
k = this.getInventoryStackLimit() - this.getInventory()[j].getSize();
}
if (k == 0)
{
return i;
@ -2715,7 +2710,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
if (ItemStack.itemEquals(itemstack1, itemstack))
{
int j = Math.min(this.getInventoryStackLimit(), itemstack1.getMaxStackSize());
int j = itemstack1.getMaxStackSize();
int k = Math.min(itemstack.getSize(), j - itemstack1.getSize());
if (k > 0)
@ -4594,47 +4589,11 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
return aitemstack[index];
}
public int getInventoryStackLimit()
{
return ItemStack.MAX_SIZE;
}
public void markDirty()
{
}
public boolean isUseableByPlayer(EntityNPC player)
{
return this.dead ? false : player.getDistanceSqToEntity(this) <= 64.0D;
}
public void openInventory(EntityNPC player)
{
}
public void closeInventory(EntityNPC player)
{
}
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 void clear()
{
for (int i = 0; i < this.getInventoryCapacity(); ++i)

View file

@ -590,9 +590,9 @@ public abstract class BlockRegistry {
register("sticky_piston", (new BlockPistonBase(true)).setDisplay("Klebriger Kolben"));
register("piston_head", (new BlockPistonHead(false)).setDisplay("Kolben"));
register("sticky_piston_head", (new BlockPistonHead(true)).setDisplay("Klebriger Kolben"));
register("dispenser", (new BlockDispenser()).setHardness(3.5F).setSound(SoundType.STONE).setDisplay("Werfer"));
register("dropper", (new BlockDropper()).setHardness(3.5F).setSound(SoundType.STONE).setDisplay("Spender"));
register("hopper", (new BlockHopper()).setHardness(3.0F).setResistance(8.0F).setSound(SoundType.STONE).setDisplay("Trichter"));
register("dispenser", (new BlockDispenser(false)).setHardness(3.5F).setSound(SoundType.STONE).setDisplay("Werfer"));
register("dropper", (new BlockDispenser(true)).setHardness(3.5F).setSound(SoundType.STONE).setDisplay("Spender"));
register("pipe", (new BlockPipe()).setHardness(3.0F).setResistance(8.0F).setSound(SoundType.STONE).setDisplay("Rohr"));
register("tian_reactor", (new BlockTianReactor()).setHardness(3.0F).setResistance(8.0F).setSound(SoundType.STONE).setDisplay("Tianreaktor"));
register("rail", (new BlockRail()).setHardness(0.7F).setSound(SoundType.STONE).setDisplay("Schiene").setMiningTool(Equipment.PICKAXE, 0));

View file

@ -191,7 +191,7 @@ public abstract class Blocks {
public static final Block dirt = get("dirt");
public static final BlockDispenser dispenser = get("dispenser");
public static final BlockDragonEgg dragon_egg = get("dragon_egg");
public static final BlockDropper dropper = get("dropper");
public static final BlockDispenser dropper = get("dropper");
public static final BlockDryLeaves dry_leaves = get("dry_leaves");
public static final BlockOre emerald_ore = get("emerald_ore");
public static final BlockEnchantmentTable enchanting_table = get("enchanting_table");
@ -251,7 +251,6 @@ public abstract class Blocks {
public static final BlockHay hay_block = get("hay_block");
public static final BlockPressurePlateWeighted heavy_weighted_pressure_plate = get("heavy_weighted_pressure_plate");
public static final BlockHellRock hellrock = get("hellrock");
public static final BlockHopper hopper = get("hopper");
public static final BlockFlower houstonia = get("houstonia");
public static final BlockStaticLiquid hydrogen = get("hydrogen");
public static final BlockIce ice = get("ice");
@ -868,6 +867,7 @@ public abstract class Blocks {
public static final BlockFurnace neptunium_furnace = get("neptunium_furnace");
public static final BlockFurnace plutonium_furnace = get("plutonium_furnace");
public static final BlockFurnace titanium_furnace = get("titanium_furnace");
public static final BlockPipe pipe = get("pipe");
private static <T extends Block> T get(String id) {
T block = (T)BlockRegistry.byNameExact(id);

View file

@ -255,7 +255,7 @@ public abstract class CraftingRegistry
addShapeless(new ItemStack(Items.charged_orb, 1), Items.orb, Items.blazing_powder);
addShapeless(new ItemStack(Items.fireball, 3), Items.gunpowder, Items.blazing_powder, Items.coal);
addShapeless(new ItemStack(Items.fireball, 3), Items.gunpowder, Items.blazing_powder, Items.charcoal);
add(new ItemStack(Items.hopper), "I I", "ICI", " I ", 'I', Items.iron_ingot, 'C', Items.wood_chest);
add(new ItemStack(Items.pipe), "I I", "ICI", "I I", 'I', Items.iron_ingot, 'C', Items.wood_chest);
add(new ItemStack(Items.stone_chest), "III", "ICI", "III", 'I', Items.cobblestone, 'C', Items.wood_chest);
add(new ItemStack(Items.iron_chest), "III", "ICI", "III", 'I', Items.iron_ingot, 'C', Items.stone_chest);

View file

@ -391,7 +391,6 @@ public abstract class Items {
public static final Item hay_block = get("hay_block");
public static final Item heavy_weighted_pressure_plate = get("heavy_weighted_pressure_plate");
public static final Item hellrock = get("hellrock");
public static final Item hopper = get("hopper");
public static final Item houstonia = get("houstonia");
public static final ItemBucket hydrogen_bucket = get("hydrogen_bucket");
public static final Item ice = get("ice");
@ -1245,6 +1244,7 @@ public abstract class Items {
public static final Item neptunium_furnace = get("neptunium_furnace");
public static final Item plutonium_furnace = get("plutonium_furnace");
public static final Item titanium_furnace = get("titanium_furnace");
public static final Item pipe = get("pipe");
private static <T extends Item> T get(String id) {
T item = (T)ItemRegistry.byName(id);

View file

@ -1,211 +0,0 @@
package common.inventory;
import common.entity.npc.EntityNPC;
import common.init.BrewingRegistry;
import common.init.Items;
import common.item.ItemStack;
import common.item.consumable.ItemPotion;
import common.network.IPlayer;
public class ContainerBrewingStand extends Container
{
private IInventory tileBrewingStand;
/** Instance of Slot. */
private final Slot theSlot;
private int brewTime;
public ContainerBrewingStand(EntityNPC playerInventory, IInventory tileBrewingStandIn)
{
this.tileBrewingStand = tileBrewingStandIn;
this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory, tileBrewingStandIn, 0, 56, 46));
this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory, tileBrewingStandIn, 1, 79, 53));
this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory, tileBrewingStandIn, 2, 102, 46));
this.theSlot = this.addSlotToContainer(new ContainerBrewingStand.Ingredient(tileBrewingStandIn, 3, 79, 17));
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (int k = 0; k < 9; ++k)
{
this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
}
}
public void onCraftGuiOpened(IPlayer listener)
{
super.onCraftGuiOpened(listener);
listener.sendProperties(this, this.tileBrewingStand);
}
/**
* Looks for changes made in the container, sends them to every listener.
*/
public void detectAndSendChanges()
{
super.detectAndSendChanges();
for (int i = 0; i < this.crafters.size(); ++i)
{
IPlayer icrafting = (IPlayer)this.crafters.get(i);
if (this.brewTime != this.tileBrewingStand.getField(0))
{
icrafting.sendProperty(this, 0, this.tileBrewingStand.getField(0));
}
}
this.brewTime = this.tileBrewingStand.getField(0);
}
public void updateProgressBar(int id, int data)
{
this.tileBrewingStand.setField(id, data);
}
public boolean canInteractWith(EntityNPC playerIn)
{
return this.tileBrewingStand.isUseableByPlayer(playerIn);
}
/**
* Take a stack from the specified inventory slot.
*/
public ItemStack transferStackInSlot(EntityNPC playerIn, int index)
{
ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if ((index < 0 || index > 2) && index != 3)
{
if (!this.theSlot.getHasStack() && this.theSlot.isItemValid(itemstack1))
{
if (!this.mergeItemStack(itemstack1, 3, 4, false))
{
return null;
}
}
else if (ContainerBrewingStand.Potion.canHoldPotion(itemstack))
{
if (!this.mergeItemStack(itemstack1, 0, 3, false))
{
return null;
}
}
else if (index >= 4 && index < 31)
{
if (!this.mergeItemStack(itemstack1, 31, 40, false))
{
return null;
}
}
else if (index >= 31 && index < 40)
{
if (!this.mergeItemStack(itemstack1, 4, 31, false))
{
return null;
}
}
else if (!this.mergeItemStack(itemstack1, 4, 40, false))
{
return null;
}
}
else
{
if (!this.mergeItemStack(itemstack1, 4, 40, true))
{
return null;
}
slot.onSlotChange(itemstack1, itemstack);
}
if (itemstack1.isEmpty())
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.getSize() == itemstack.getSize())
{
return null;
}
slot.onPickupFromSlot(playerIn, itemstack1);
}
return itemstack;
}
class Ingredient extends Slot
{
public Ingredient(IInventory inventoryIn, int index, int xPosition, int yPosition)
{
super(inventoryIn, index, xPosition, yPosition);
}
public boolean isItemValid(ItemStack stack)
{
return stack != null ? BrewingRegistry.isIngredient(stack) : false;
}
public int getSlotStackLimit()
{
return ItemStack.MAX_SIZE;
}
}
static class Potion extends Slot
{
private EntityNPC player;
public Potion(EntityNPC playerIn, IInventory inventoryIn, int index, int xPosition, int yPosition)
{
super(inventoryIn, index, xPosition, yPosition);
this.player = playerIn;
}
public boolean isItemValid(ItemStack stack)
{
return canHoldPotion(stack);
}
public int getSlotStackLimit()
{
return 1;
}
public boolean canCheatItem() {
return false;
}
// public void onPickupFromSlot(EntityNPC playerIn, ItemStack stack)
// {
// if (stack.getItem() == Items.potion && stack.getMetadata() > 0)
// {
// this.player.triggerAchievement(AchievementList.potion);
// }
//
// super.onPickupFromSlot(playerIn, stack);
// }
public static boolean canHoldPotion(ItemStack stack)
{
return stack != null && (stack.getItem() instanceof ItemPotion || stack.getItem() == Items.bottle);
}
}
}

View file

@ -3,6 +3,7 @@ package common.inventory;
import common.block.tech.BlockChest;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
import common.tileentity.TileEntityChest;
public class ContainerChest extends Container
{
@ -15,7 +16,6 @@ public class ContainerChest extends Container
{
this.chest = chest;
this.chestSize = chest.getSizeInventory();
chest.openInventory(player);
BlockChest block = BlockChest.getChest(this.chestSize);
this.width = block.getInventoryWidth();
this.height = block.getInventoryHeight();
@ -87,7 +87,10 @@ public class ContainerChest extends Container
public void onContainerClosed(EntityNPC player)
{
super.onContainerClosed(player);
this.chest.closeInventory(player);
if(this.chest instanceof TileEntityChest chest)
chest.onClosed();
else if(this.chest instanceof InventoryWarpChest wchest)
wchest.setPosition(null);
}
public IInventory getChestInventory()

View file

@ -1,85 +0,0 @@
package common.inventory;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
public class ContainerDispenser extends Container
{
private IInventory dispenserInventory;
public ContainerDispenser(IInventory playerInventory, IInventory dispenserInventoryIn)
{
this.dispenserInventory = dispenserInventoryIn;
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 3; ++j)
{
this.addSlotToContainer(new Slot(dispenserInventoryIn, j + i * 3, 62 + j * 18, 17 + i * 18));
}
}
for (int k = 0; k < 3; ++k)
{
for (int i1 = 0; i1 < 9; ++i1)
{
this.addSlotToContainer(new Slot(playerInventory, i1 + k * 9 + 9, 8 + i1 * 18, 84 + k * 18));
}
}
for (int l = 0; l < 9; ++l)
{
this.addSlotToContainer(new Slot(playerInventory, l, 8 + l * 18, 142));
}
}
public boolean canInteractWith(EntityNPC playerIn)
{
return this.dispenserInventory.isUseableByPlayer(playerIn);
}
/**
* Take a stack from the specified inventory slot.
*/
public ItemStack transferStackInSlot(EntityNPC playerIn, int index)
{
ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index < 9)
{
if (!this.mergeItemStack(itemstack1, 9, 45, true))
{
return null;
}
}
else if (!this.mergeItemStack(itemstack1, 0, 9, false))
{
return null;
}
if (itemstack1.isEmpty())
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.getSize() == itemstack.getSize())
{
return null;
}
slot.onPickupFromSlot(playerIn, itemstack1);
}
return itemstack;
}
}

View file

@ -35,10 +35,6 @@ public class ContainerEnchantment extends Container
{
this.table = new InventoryBasic(1)
{
public int getInventoryStackLimit()
{
return ItemStack.MAX_SIZE;
}
public void markDirty()
{
super.markDirty();
@ -57,9 +53,9 @@ public class ContainerEnchantment extends Container
{
return true;
}
public int getSlotStackLimit()
public boolean canStackItems()
{
return 1;
return false;
}
public boolean canEditItem() {

View file

@ -16,7 +16,6 @@ public class ContainerEntityInventory extends Container
this.entityInventory = entityInv;
this.entity = entity;
int i = 3;
entityInv.openInventory(player);
int j = (i - 4) * 18;
if(this.entity instanceof EntityHorse) {
final EntityHorse horse = (EntityHorse)this.entity;
@ -120,13 +119,4 @@ public class ContainerEntityInventory extends Container
return itemstack;
}
/**
* Called when the container is closed.
*/
public void onContainerClosed(EntityNPC playerIn)
{
super.onContainerClosed(playerIn);
this.entityInventory.closeInventory(playerIn);
}
}

View file

@ -1,86 +0,0 @@
package common.inventory;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
public class ContainerHopper extends Container
{
private final IInventory hopperInventory;
public ContainerHopper(EntityNPC playerInventory, IInventory hopperInventoryIn, EntityNPC player)
{
this.hopperInventory = hopperInventoryIn;
hopperInventoryIn.openInventory(player);
int i = 51;
for (int j = 0; j < hopperInventoryIn.getSizeInventory(); ++j)
{
this.addSlotToContainer(new Slot(hopperInventoryIn, j, 44 + j * 18, 20));
}
for (int l = 0; l < 3; ++l)
{
for (int k = 0; k < 9; ++k)
{
this.addSlotToContainer(new Slot(playerInventory, k + l * 9 + 9, 8 + k * 18, l * 18 + i));
}
}
for (int i1 = 0; i1 < 9; ++i1)
{
this.addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 58 + i));
}
}
public boolean canInteractWith(EntityNPC playerIn)
{
return this.hopperInventory.isUseableByPlayer(playerIn);
}
/**
* Take a stack from the specified inventory slot.
*/
public ItemStack transferStackInSlot(EntityNPC playerIn, int index)
{
ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index < this.hopperInventory.getSizeInventory())
{
if (!this.mergeItemStack(itemstack1, this.hopperInventory.getSizeInventory(), this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(itemstack1, 0, this.hopperInventory.getSizeInventory(), false))
{
return null;
}
if (itemstack1.isEmpty())
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
}
return itemstack;
}
/**
* Called when the container is closed.
*/
public void onContainerClosed(EntityNPC playerIn)
{
super.onContainerClosed(playerIn);
this.hopperInventory.closeInventory(playerIn);
}
}

View file

@ -38,9 +38,9 @@ public class ContainerPlayer extends Container {
final Equipment type = slot;
this.addSlotToContainer(new Slot(player, 27 + 9 + slot.getIndex(), 8 + (slot.getIndex() / 4) * 18, 8 + (slot.getIndex() % 4) * 18)
{
public int getSlotStackLimit()
public boolean canStackItems()
{
return 1;
return false;
}
public boolean isItemValid(ItemStack stack)
{

View file

@ -14,14 +14,21 @@ public class ContainerTile extends Container
private int progress;
private int total;
private Status status = Status.OFF;
private final int[] resources;
private final int[] resourceValues;
private final int[] resourceCapacities;
private final int[] resourceOvercharges;
private final int[] resourceUndercharges;
private final int[] resourceEntropies;
public ContainerTile(EntityNPC player, Device tile, IInventory tileInv)
{
this.tileInv = tileInv;
this.tile = tile;
this.resources = new int[tile.getNumResources()];
tileInv.openInventory(player);
this.resourceValues = new int[tile.getNumResources()];
this.resourceCapacities = new int[tile.getNumResources()];
this.resourceOvercharges = new int[tile.getNumResources()];
this.resourceUndercharges = new int[tile.getNumResources()];
this.resourceEntropies = new int[tile.getNumResources()];
int i = 112;
int input = 0;
@ -102,37 +109,43 @@ public class ContainerTile extends Container
return itemstack;
}
public void onContainerClosed(EntityNPC playerIn)
{
super.onContainerClosed(playerIn);
this.tileInv.closeInventory(playerIn);
}
public void onCraftGuiOpened(IPlayer listener)
{
super.onCraftGuiOpened(listener);
listener.sendProperty(this, this.resources.length, this.tile.getTemperature());
listener.sendProperty(this, this.resources.length + 1, this.tile.getProgress());
listener.sendProperty(this, this.resources.length + 2, this.tile.getTotal());
listener.sendProperty(this, this.resources.length + 3, this.tile.getStatus().ordinal());
for(int z = 0; z < this.resources.length; z++) {
listener.sendProperty(this, this.resourceValues.length * 5, this.tile.getTemperature());
listener.sendProperty(this, this.resourceValues.length * 5 + 1, this.tile.getProgress());
listener.sendProperty(this, this.resourceValues.length * 5 + 2, this.tile.getTotal());
listener.sendProperty(this, this.resourceValues.length * 5 + 3, this.tile.getStatus().ordinal());
for(int z = 0; z < this.resourceValues.length; z++) {
listener.sendProperty(this, z, this.tile.getResource(z).getValue());
listener.sendProperty(this, this.resourceValues.length + z, this.tile.getResource(z).getCapacity());
listener.sendProperty(this, this.resourceValues.length * 2 + z, this.tile.getResource(z).getOvercharge());
listener.sendProperty(this, this.resourceValues.length * 3 + z, this.tile.getResource(z).getUndercharge());
listener.sendProperty(this, this.resourceValues.length * 4 + z, this.tile.getResource(z).getEntropy());
}
}
public void updateProgressBar(int id, int data)
{
if(id == this.resources.length)
if(id == this.resourceValues.length * 5)
this.tile.setTemperature(data);
else if(id == this.resources.length + 1)
else if(id == this.resourceValues.length * 5 + 1)
this.tile.setProgress(data);
else if(id == this.resources.length + 2)
else if(id == this.resourceValues.length * 5 + 2)
this.tile.setTotal(data);
else if(id == this.resources.length + 3)
else if(id == this.resourceValues.length * 5 + 3)
this.tile.setStatus(Status.values()[data % Status.values().length]);
else
this.tile.getResource(id).setValue(data);
else if(id / this.resourceValues.length == 0)
this.tile.getResource(id % this.resourceValues.length).setValue(data);
else if(id / this.resourceValues.length == 1)
this.tile.getResource(id % this.resourceValues.length).setCapacity(data);
else if(id / this.resourceValues.length == 2)
this.tile.getResource(id % this.resourceValues.length).setOvercharge(data);
else if(id / this.resourceValues.length == 3)
this.tile.getResource(id % this.resourceValues.length).setUndercharge(data);
else if(id / this.resourceValues.length == 4)
this.tile.getResource(id % this.resourceValues.length).setEntropy(data);
}
public void detectAndSendChanges()
@ -143,16 +156,24 @@ public class ContainerTile extends Container
{
IPlayer listener = this.crafters.get(i);
if(this.temperature != this.tile.getTemperature())
listener.sendProperty(this, this.resources.length, this.tile.getTemperature());
listener.sendProperty(this, this.resourceValues.length * 5, this.tile.getTemperature());
if(this.progress != this.tile.getProgress())
listener.sendProperty(this, this.resources.length + 1, this.tile.getProgress());
listener.sendProperty(this, this.resourceValues.length * 5 + 1, this.tile.getProgress());
if(this.total != this.tile.getTotal())
listener.sendProperty(this, this.resources.length + 2, this.tile.getTotal());
listener.sendProperty(this, this.resourceValues.length * 5 + 2, this.tile.getTotal());
if(this.status != this.tile.getStatus())
listener.sendProperty(this, this.resources.length + 3, this.tile.getStatus().ordinal());
for(int z = 0; z < this.resources.length; z++) {
if(this.resources[z] != this.tile.getResource(z).getValue())
listener.sendProperty(this, this.resourceValues.length * 5 + 3, this.tile.getStatus().ordinal());
for(int z = 0; z < this.resourceValues.length; z++) {
if(this.resourceValues[z] != this.tile.getResource(z).getValue())
listener.sendProperty(this, z, this.tile.getResource(z).getValue());
if(this.resourceCapacities[z] != this.tile.getResource(z).getCapacity())
listener.sendProperty(this, this.resourceValues.length + z, this.tile.getResource(z).getCapacity());
if(this.resourceOvercharges[z] != this.tile.getResource(z).getOvercharge())
listener.sendProperty(this, this.resourceValues.length * 2 + z, this.tile.getResource(z).getOvercharge());
if(this.resourceUndercharges[z] != this.tile.getResource(z).getUndercharge())
listener.sendProperty(this, this.resourceValues.length * 3 + z, this.tile.getResource(z).getUndercharge());
if(this.resourceEntropies[z] != this.tile.getResource(z).getEntropy())
listener.sendProperty(this, this.resourceValues.length * 4 + z, this.tile.getResource(z).getEntropy());
}
}
@ -160,8 +181,12 @@ public class ContainerTile extends Container
this.progress = this.tile.getProgress();
this.total = this.tile.getTotal();
this.status = this.tile.getStatus();
for(int z = 0; z < this.resources.length; z++) {
this.resources[z] = this.tile.getResource(z).getValue();
for(int z = 0; z < this.resourceValues.length; z++) {
this.resourceValues[z] = this.tile.getResource(z).getValue();
this.resourceCapacities[z] = this.tile.getResource(z).getCapacity();
this.resourceOvercharges[z] = this.tile.getResource(z).getOvercharge();
this.resourceUndercharges[z] = this.tile.getResource(z).getUndercharge();
this.resourceEntropies[z] = this.tile.getResource(z).getEntropy();
}
}
}

View file

@ -1,5 +0,0 @@
package common.inventory;
public interface ICfarsfadtfdwgfdgdvgs
{
}

View file

@ -3,63 +3,22 @@ package common.inventory;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
public interface IInventory
{
/**
* Returns the number of slots in the inventory.
*/
public interface IInventory {
int getSizeInventory();
/**
* Returns the stack in the given slot.
*/
ItemStack getStackInSlot(int index);
/**
* Removes up to a specified number of items from an inventory slot and returns them in a new stack.
*/
ItemStack decrStackSize(int index, int count);
/**
* Removes a stack from the given slot and returns it.
*/
ItemStack removeStackFromSlot(int index);
/**
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
*/
void setInventorySlotContents(int index, ItemStack stack);
/**
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
*/
int 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.
*/
void markDirty();
/**
* Do not make give this method the name canInteractWith because it clashes with Container
*/
boolean isUseableByPlayer(EntityNPC player);
void openInventory(EntityNPC player);
void closeInventory(EntityNPC player);
/**
* Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
*/
boolean isItemValidForSlot(int index, ItemStack stack);
int getField(int id);
void setField(int id, int value);
int getFieldCount();
void clear();
default boolean isUseableByPlayer(EntityNPC player) {
return true;
}
default void markDirty() {
}
default boolean isItemValidForSlot(int index, ItemStack stack) {
return true;
}
}

View file

@ -3,19 +3,8 @@ package common.inventory;
import common.item.ItemStack;
import common.util.Facing;
public interface ISidedInventory extends IInventory
{
int[] getSlotsForFace(Facing side);
/**
* Returns true if automation can insert the given item in the given slot from the given side. Args: slot, item,
* side
*/
boolean canInsertItem(int index, ItemStack itemStackIn, Facing direction);
/**
* Returns true if automation can extract the given item in the given slot from the given side. Args: slot, item,
* side
*/
boolean canExtractItem(int index, ItemStack stack, Facing direction);
public interface ISidedInventory extends IInventory {
int[] getSlotsForFace(Facing side);
boolean canInsertItem(int index, ItemStack stack, Facing side);
boolean canExtractItem(int index, ItemStack stack, Facing side);
}

View file

@ -3,7 +3,6 @@ package common.inventory;
import java.util.List;
import common.collect.Lists;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
public class InventoryBasic implements IInventory
@ -107,12 +106,6 @@ public class InventoryBasic implements IInventory
public void setInventorySlotContents(int index, ItemStack stack)
{
this.inventoryContents[index] = stack;
if (stack != null && stack.getSize() > this.getInventoryStackLimit())
{
stack.setSize(this.getInventoryStackLimit());
}
this.markDirty();
}
@ -124,14 +117,6 @@ public class InventoryBasic implements IInventory
return this.slotsCount;
}
/**
* 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;
}
/**
* 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.
@ -147,44 +132,6 @@ public class InventoryBasic implements IInventory
}
}
/**
* Do not make give this method the name canInteractWith because it clashes with Container
*/
public boolean isUseableByPlayer(EntityNPC player)
{
return true;
}
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;
}
public int getField(int id)
{
return 0;
}
public void setField(int id, int value)
{
}
public int getFieldCount()
{
return 0;
}
public void clear()
{
for (int i = 0; i < this.inventoryContents.length; ++i)

View file

@ -1,6 +1,5 @@
package common.inventory;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
public class InventoryCraftResult implements IInventory
@ -66,60 +65,6 @@ public class InventoryCraftResult implements IInventory
this.stackResult[0] = stack;
}
/**
* 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;
}
/**
* 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 true;
}
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;
}
public int getField(int id)
{
return 0;
}
public void setField(int id, int value)
{
}
public int getFieldCount()
{
return 0;
}
public void clear()
{
for (int i = 0; i < this.stackResult.length; ++i)

View file

@ -1,6 +1,5 @@
package common.inventory;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
public class InventoryCrafting implements IInventory
@ -109,60 +108,6 @@ public class InventoryCrafting implements IInventory
this.eventHandler.onCraftMatrixChanged(this);
}
/**
* 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;
}
/**
* 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 true;
}
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;
}
public int getField(int id)
{
return 0;
}
public void setField(int id, int value)
{
}
public int getFieldCount()
{
return 0;
}
public void clear()
{
for (int i = 0; i < this.stackList.length; ++i)

View file

@ -125,26 +125,12 @@ public class InventoryMerchant implements IInventory
public void setInventorySlotContents(int index, ItemStack stack)
{
this.theInventory[index] = stack;
if (stack != null && stack.getSize() > this.getInventoryStackLimit())
{
stack.setSize(this.getInventoryStackLimit());
}
if (this.inventoryResetNeededOnSlotChange(index))
{
this.resetRecipeAndSlots();
}
}
/**
* 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;
}
/**
* Do not make give this method the name canInteractWith because it clashes with Container
*/
@ -153,22 +139,6 @@ public class InventoryMerchant implements IInventory
return this.theMerchant == null || this.theMerchant.getTalking() == player;
}
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;
}
/**
* 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.
@ -243,20 +213,6 @@ public class InventoryMerchant implements IInventory
this.resetRecipeAndSlots();
}
public int getField(int id)
{
return 0;
}
public void setField(int id, int value)
{
}
public int getFieldCount()
{
return 0;
}
public void clear()
{
for (int i = 0; i < this.theInventory.length; ++i)

View file

@ -10,16 +10,16 @@ import common.util.BlockPos;
public class InventoryWarpChest extends InventoryBasic
{
private BlockPos associatedChest;
private BlockPos position;
public InventoryWarpChest()
{
super(27);
}
public void setWarpChest(BlockPos chestTileEntity)
public void setPosition(BlockPos pos)
{
this.associatedChest = chestTileEntity;
this.position = pos;
}
public void readTags(List<TagObject> list)
@ -63,27 +63,6 @@ public class InventoryWarpChest extends InventoryBasic
public boolean isUseableByPlayer(EntityNPC player)
{
return (this.associatedChest == null || (player.worldObj.getState(this.associatedChest).getBlock() == Blocks.warp_chest && player.getDistanceSq((double)this.associatedChest.getX() + 0.5D, (double)this.associatedChest.getY() + 0.5D, (double)this.associatedChest.getZ() + 0.5D) <= 64.0D)) && super.isUseableByPlayer(player);
}
// public void openInventory(EntityNPC player)
// {
// if (this.associatedChest != null)
// {
// this.associatedChest.openChest();
// }
//
// super.openInventory(player);
// }
public void closeInventory(EntityNPC player)
{
// if (this.associatedChest != null)
// {
// this.associatedChest.closeChest();
// }
super.closeInventory(player);
this.associatedChest = null;
return this.position == null || (player.worldObj.getState(this.position).getBlock() == Blocks.warp_chest && player.getDistanceSq((double)this.position.getX() + 0.5D, (double)this.position.getY() + 0.5D, (double)this.position.getZ() + 0.5D) <= 64.0D);
}
}

View file

@ -108,18 +108,14 @@ public class Slot
this.inventory.markDirty();
}
/**
* Returns the maximum stack size for a given slot (usually the same as getInventoryStackLimit(), but 1 in the case
* of armor slots)
*/
public int getSlotStackLimit()
public boolean canStackItems()
{
return this.inventory.getInventoryStackLimit();
return true;
}
public int getItemStackLimit(ItemStack stack)
{
return this.getSlotStackLimit();
return this.canStackItems() ? 1000000000 : 1;
}
public String getTexture()

View file

@ -21,8 +21,6 @@ import common.util.Color;
import common.util.Equipment;
public final class ItemStack {
public static final int MAX_SIZE = 67108864;
private Item item;
private int size;
private String name;

View file

@ -6,7 +6,6 @@ import common.inventory.IInventory;
import common.rng.Random;
import common.rng.RngItem;
import common.rng.WeightedList;
import common.tileentity.TileEntityDispenser;
public class RngLoot extends RngItem
{
@ -57,27 +56,6 @@ public class RngLoot extends RngItem
}
}
public static void generateDispenserContents(Random random, WeightedList<RngLoot> list, TileEntityDispenser dispenser, int max)
{
for (int i = 0; i < max; ++i)
{
RngLoot loot = (RngLoot)list.pick(random);
int j = loot.minStackSize + random.zrange(loot.maxStackSize - loot.minStackSize + 1);
if (loot.item.getMaxStackSize() >= j)
{
dispenser.setInventorySlotContents(random.zrange(dispenser.getSizeInventory()), loot.item.copy(j));
}
else
{
for (int k = 0; k < j; ++k)
{
dispenser.setInventorySlotContents(random.zrange(dispenser.getSizeInventory()), loot.item.copy(1));
}
}
}
}
public static WeightedList<RngLoot> addToList(WeightedList<RngLoot> items, RngLoot... add)
{
WeightedList<RngLoot> list = new WeightedList(items);

View file

@ -24,7 +24,7 @@ import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityDispenser;
import common.tileentity.DeviceDispenser;
import common.util.BlockPos;
import common.util.Clientside;
import common.util.Facing;
@ -358,7 +358,7 @@ public class ItemBucket extends Item
stack.setItem(item);
stack.setSize(1);
}
else if (source instanceof TileEntityDispenser dispenser && dispenser.addItemStack(new ItemStack(item)) < 0)
else if (source instanceof DeviceDispenser dispenser && dispenser.addItemStack(new ItemStack(item)) < 0)
{
super.dispenseStack(world, source, position, blockpos, facing, new ItemStack(item));
}

View file

@ -9,7 +9,6 @@ import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.init.SoundEvent;
import common.inventory.Container;
import common.inventory.IInventory;
import common.item.ItemStack;
import common.packet.CPacketAction;
import common.packet.CPacketBreak;
@ -100,7 +99,6 @@ public interface IPlayer extends NetHandler {
void sendContainer(Container container, List<ItemStack> items);
void sendSlot(Container container, int index, ItemStack stack);
void sendProperty(Container container, int variable, int value);
void sendProperties(Container container, IInventory inventory);
void processKeepAlive(CPacketKeepAlive packet);
void processMessage(CPacketMessage packet);

View file

@ -37,8 +37,8 @@ public class SPacketWindowProperty implements Packet<IClientPlayer>
public void readPacketData(PacketBuffer buf) throws IOException
{
this.windowId = buf.readUnsignedByte();
this.varIndex = buf.readShort();
this.varValue = buf.readShort();
this.varIndex = buf.readVarInt();
this.varValue = buf.readVarInt();
}
/**
@ -47,8 +47,8 @@ public class SPacketWindowProperty implements Packet<IClientPlayer>
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeByte(this.windowId);
buf.writeShort(this.varIndex);
buf.writeShort(this.varValue);
buf.writeVarInt(this.varIndex);
buf.writeVarInt(this.varValue);
}
public int getWindowId()

View file

@ -217,14 +217,6 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
public void setInventorySlotContents(int index, ItemStack stack) {
this.inventory[index] = stack;
if(stack != null && stack.getSize() > this.getInventoryStackLimit()) {
stack.setSize(this.getInventoryStackLimit());
}
}
public int getInventoryStackLimit() {
return ItemStack.MAX_SIZE;
}
public boolean isUseableByPlayer(EntityNPC player) {
@ -232,12 +224,6 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
: player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
}
public void openInventory(EntityNPC player) {
}
public void closeInventory(EntityNPC player) {
}
public boolean isItemValidForSlot(int index, ItemStack stack) {
return index < this.inputs;
}
@ -322,17 +308,6 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
return this.inventory[slot - this.inputs] != null && this.inventory[slot - this.inputs].isFull();
}
public int getField(int id) {
return 0;
}
public void setField(int id, int value) {
}
public int getFieldCount() {
return 0;
}
public void clear() {
for(int i = 0; i < this.inventory.length; ++i) {
this.inventory[i] = null;

View file

@ -0,0 +1,108 @@
package common.tileentity;
import common.effect.StatusEffect;
import common.init.BrewingRegistry;
import common.init.Items;
import common.item.Item;
import common.item.ItemStack;
import common.item.consumable.ItemPotion;
public class DeviceBrewer extends Device {
private Item lastItem;
public DeviceBrewer() {
super(2, 1);
}
public boolean hasProgress() {
return true;
}
public boolean executeFunction() {
if(this.getTotal() > 0) {
if(this.addProgress(1)) {
this.setTotal(0);
this.setProgress(-1);
this.brewPotions();
this.markDirty();
}
else if(!this.canBrew()) {
this.setTotal(0);
this.setProgress(-1);
this.markDirty();
}
else if(this.lastItem != this.getStackInSlot(1).getItem()) {
this.setTotal(0);
this.setProgress(-1);
this.markDirty();
}
}
else if(this.canBrew()) {
this.setTotal(400);
this.setProgress(0);
this.lastItem = this.getStackInSlot(1).getItem();
this.markDirty();
}
return this.canBrew();
}
private boolean canBrew() {
if(this.getStackInSlot(1) != null && !this.getStackInSlot(1).isEmpty() && this.getStackInSlot(2) == null) {
ItemStack itemstack = this.getStackInSlot(1);
if(!BrewingRegistry.isIngredient(itemstack)) {
return false;
}
else {
if(this.getStackInSlot(0) != null && this.getStackInSlot(0).getItem() instanceof ItemPotion potion) {
ItemPotion result = this.getPotionResult(potion, itemstack);
StatusEffect list = potion.getEffect();
StatusEffect list1 = result.getEffect();
if((potion.getType() == null || list != list1) && (list == null || !list.equals(list1) && list1 != null) && potion != result) {
return true;
}
}
}
}
return false;
}
private void brewPotions() {
if(this.canBrew()) {
ItemStack itemstack = this.getStackInSlot(1);
if(this.getStackInSlot(0) != null && this.getStackInSlot(0).getItem() instanceof ItemPotion potion) {
ItemPotion result = this.getPotionResult(potion, itemstack);
StatusEffect list = potion.getEffect();
StatusEffect list1 = result.getEffect();
if(potion.getType() != null && list == list1 || list != null && (list.equals(list1) || list1 == null)) {
}
else if(potion != result) {
if(this.getStackInSlot(0).decrSize())
this.setInventorySlotContents(0, null);
this.setInventorySlotContents(2, new ItemStack(result));
}
}
if(itemstack.getItem().hasContainerItem()) {
this.setInventorySlotContents(1, new ItemStack(itemstack.getItem().getContainerItem()));
}
else {
if(this.getStackInSlot(1).decrSize()) {
this.setInventorySlotContents(1, null);
}
}
}
}
private ItemPotion getPotionResult(ItemPotion potion, ItemStack stack) {
return stack == null ? potion : (BrewingRegistry.isIngredient(stack) ? BrewingRegistry.applyIngredient(potion, stack) : potion);
}
public boolean isItemValidForSlot(int index, ItemStack stack) {
return index == 1 ? BrewingRegistry.isIngredient(stack) : (index == 0 ? stack.getItem() instanceof ItemPotion || stack.getItem() == Items.bottle : false);
}
}

View file

@ -0,0 +1,125 @@
package common.tileentity;
import common.block.tech.BlockDispenser;
import common.item.ItemStack;
import common.rng.Random;
import common.tags.TagObject;
import common.util.BlockPos;
import common.util.Facing;
import common.vars.Vars;
import common.world.AWorldServer;
import common.world.State;
public class DeviceDispenser extends Device
{
private static final Random RNG = new Random();
private final boolean dropItems;
private int cooldown = 0;
public DeviceDispenser(boolean dropItems) {
super(9, 0);
this.dropItems = dropItems;
}
public int getDispenseSlot()
{
int i = -1;
int j = 1;
for (int k = 0; k < this.getSizeInventory(); ++k)
{
if (this.getStackInSlot(k) != null && RNG.zrange(j++) == 0)
{
i = k;
}
}
return i;
}
public int addItemStack(ItemStack stack)
{
for (int i = 0; i < this.getSizeInventory(); ++i)
{
if (this.getStackInSlot(i) == null)
{
this.setInventorySlotContents(i, stack);
return i;
}
}
return -1;
}
public void readTags(TagObject compound)
{
super.readTags(compound);
this.cooldown = compound.getInt("Cooldown");
}
public void writeTags(TagObject compound)
{
super.writeTags(compound);
compound.setInt("Cooldown", this.cooldown);
}
private ItemStack dispenseStack(ItemStack stack, AWorldServer world, BlockPos pos)
{
Facing facing = world.getState(pos).getValue(BlockDispenser.FACING);
if(this.dropItems) {
BlockDispenser.dispense(world, 6.0, facing, BlockDispenser.getDispensePosition(pos, facing), stack.split(1));
world.playEffect(1000, pos, 0);
world.playEffect(2000, pos, facing.getFrontOffsetX() + 1 + (facing.getFrontOffsetZ() + 1) * 3);
return stack;
}
ItemStack nstack = stack.getItem().dispenseStack(world, world.getTileEntity(pos), BlockDispenser.getDispensePosition(pos, facing), pos, facing, stack);
int id = stack.getItem().getDispenseSoundId();
if(id != 0)
world.playEffect(id, pos, 0);
world.playEffect(2000, pos, facing.getFrontOffsetX() + 1 + (facing.getFrontOffsetZ() + 1) * 3);
return nstack;
}
private boolean dispense(AWorldServer worldIn, BlockPos pos)
{
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof DeviceDispenser tileentitydispenser)
{
int i = tileentitydispenser.getDispenseSlot();
if (i < 0)
{
return false;
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
if(itemstack != null) {
ItemStack itemstack1 = this.dispenseStack(itemstack, worldIn, pos);
tileentitydispenser.setInventorySlotContents(i, itemstack1 != null && itemstack1.isEmpty() ? null : itemstack1);
}
}
return true;
}
return false;
}
public boolean executeFunction() {
if (this.cooldown <= 0)
{
State state = this.getBlockState();
if(!(state.getBlock() instanceof BlockDispenser) /* || !this.decrPower() */) //TODO: energy
return false;
boolean flag = this.dispense((AWorldServer)this.worldObj, this.pos);
this.cooldown = Vars.dispenserDelay;
return flag;
}
else {
this.cooldown--;
return true;
}
}
}

View file

@ -108,10 +108,12 @@ public class DeviceFurnace extends Device implements ISidedInventory
else
{
this.setProgress(0);
this.setTotal(0);
}
}
else if (!this.isBurning() && this.getProgress() > 0)
{
flag1 = true;
this.setProgress(ExtMath.clampi(this.getProgress() - 2, 0, this.getTotal()));
}
@ -132,7 +134,7 @@ public class DeviceFurnace extends Device implements ISidedInventory
public int getCookTime(ItemStack stack)
{
return this.burnTime;
return stack == null || stack.isEmpty() ? 0 : this.burnTime;
}
private boolean canSmelt()
@ -145,7 +147,7 @@ public class DeviceFurnace extends Device implements ISidedInventory
{
ItemStack itemstack = SmeltingRegistry.getResult(this.getStackInSlot(0));
ItemStack out = this.getStackInSlot(2);
return itemstack == null ? false : (out == null ? true : (!out.itemEquals(itemstack) ? false : (out.getSize() < this.getInventoryStackLimit() && !out.isFull() ? true : out.getSize() < itemstack.getMaxStackSize())));
return itemstack == null ? false : (out == null ? true : (!out.itemEquals(itemstack) ? false : (!out.isFull() ? true : out.getSize() < itemstack.getMaxStackSize())));
}
}

View file

@ -55,6 +55,10 @@ public class MachineResource {
this.capacity = value;
}
public void setEntropy(int value) {
this.entropy = value;
}
public boolean take(int value, boolean over) {
if((over ? this.undercharge : 0) + this.amount < value)
return false;

View file

@ -1,351 +0,0 @@
package common.tileentity;
import java.util.List;
import common.collect.Lists;
import common.effect.StatusEffect;
import common.entity.npc.EntityNPC;
import common.init.BrewingRegistry;
import common.init.Items;
import common.inventory.Container;
import common.inventory.ContainerBrewingStand;
import common.inventory.ISidedInventory;
import common.item.Item;
import common.item.ItemStack;
import common.item.consumable.ItemPotion;
import common.tags.TagObject;
import common.util.Facing;
public class TileEntityBrewingStand extends TileEntityInventory implements ITickable, ISidedInventory
{
/** an array of the input slot indices */
private static final int[] inputSlots = new int[] {3};
/** an array of the output slot indices */
private static final int[] outputSlots = new int[] {0, 1, 2};
/** The ItemStacks currently placed in the slots of the brewing stand */
private ItemStack[] brewingItemStacks = new ItemStack[4];
private int brewTime;
/**
* used to check if the current ingredient has been removed from the brewing stand during brewing
*/
private Item ingredientID;
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
{
return this.brewingItemStacks.length;
}
/**
* Like the old updateEntity(), except more generic.
*/
public void update()
{
if (this.brewTime > 0)
{
--this.brewTime;
if (this.brewTime == 0)
{
this.brewPotions();
this.markDirty();
}
else if (!this.canBrew())
{
this.brewTime = 0;
this.markDirty();
}
else if (this.ingredientID != this.brewingItemStacks[3].getItem())
{
this.brewTime = 0;
this.markDirty();
}
}
else if (this.canBrew())
{
this.brewTime = 400;
this.ingredientID = this.brewingItemStacks[3].getItem();
}
}
private boolean canBrew()
{
if (this.brewingItemStacks[3] != null && !this.brewingItemStacks[3].isEmpty())
{
ItemStack itemstack = this.brewingItemStacks[3];
if (!BrewingRegistry.isIngredient(itemstack))
{
return false;
}
else
{
boolean flag = false;
for (int i = 0; i < 3; ++i)
{
if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion potion)
{
ItemPotion result = this.getPotionResult(potion, itemstack);
StatusEffect list = potion.getEffect();
StatusEffect list1 = result.getEffect();
if ((potion.getType() == null || list != list1) && (list == null || !list.equals(list1) && list1 != null) && potion != result)
{
flag = true;
break;
}
}
}
return flag;
}
}
else
{
return false;
}
}
private void brewPotions()
{
if (this.canBrew())
{
ItemStack itemstack = this.brewingItemStacks[3];
for (int i = 0; i < 3; ++i)
{
if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion potion)
{
ItemPotion result = this.getPotionResult(potion, itemstack);
StatusEffect list = potion.getEffect();
StatusEffect list1 = result.getEffect();
if (potion.getType() != null && list == list1 || list != null && (list.equals(list1) || list1 == null))
{
}
else if (potion != result)
{
this.brewingItemStacks[i] = new ItemStack(result);
}
}
}
if (itemstack.getItem().hasContainerItem())
{
this.brewingItemStacks[3] = new ItemStack(itemstack.getItem().getContainerItem());
}
else
{
if (this.brewingItemStacks[3].decrSize())
{
this.brewingItemStacks[3] = null;
}
}
}
}
private ItemPotion getPotionResult(ItemPotion potion, ItemStack stack)
{
return stack == null ? potion : (BrewingRegistry.isIngredient(stack) ? BrewingRegistry.applyIngredient(potion, stack) : potion);
}
public void readTags(TagObject compound)
{
super.readTags(compound);
List<TagObject> nbttaglist = compound.getList("Items");
this.brewingItemStacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.size(); ++i)
{
TagObject nbttagcompound = nbttaglist.get(i);
int j = nbttagcompound.getByte("Slot");
if (j >= 0 && j < this.brewingItemStacks.length)
{
this.brewingItemStacks[j] = ItemStack.readFromTag(nbttagcompound);
}
}
this.brewTime = compound.getShort("BrewTime");
}
public void writeTags(TagObject compound)
{
super.writeTags(compound);
compound.setShort("BrewTime", (short)this.brewTime);
List<TagObject> nbttaglist = Lists.newArrayList();
for (int i = 0; i < this.brewingItemStacks.length; ++i)
{
if (this.brewingItemStacks[i] != null)
{
TagObject nbttagcompound = new TagObject();
nbttagcompound.setByte("Slot", (byte)i);
this.brewingItemStacks[i].writeTags(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
}
compound.setList("Items", nbttaglist);
}
/**
* Returns the stack in the given slot.
*/
public ItemStack getStackInSlot(int index)
{
return index >= 0 && index < this.brewingItemStacks.length ? this.brewingItemStacks[index] : null;
}
/**
* 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 (index >= 0 && index < this.brewingItemStacks.length)
{
ItemStack itemstack = this.brewingItemStacks[index];
this.brewingItemStacks[index] = null;
return itemstack;
}
else
{
return null;
}
}
/**
* Removes a stack from the given slot and returns it.
*/
public ItemStack removeStackFromSlot(int index)
{
if (index >= 0 && index < this.brewingItemStacks.length)
{
ItemStack itemstack = this.brewingItemStacks[index];
this.brewingItemStacks[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)
{
if (index >= 0 && index < this.brewingItemStacks.length)
{
this.brewingItemStacks[index] = stack;
}
}
/**
* 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;
}
/**
* Do not make give this method the name canInteractWith because it clashes with Container
*/
public boolean isUseableByPlayer(EntityNPC player)
{
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 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 index == 3 ? BrewingRegistry.isIngredient(stack) : stack.getItem() instanceof ItemPotion || stack.getItem() == Items.bottle;
}
public int[] getSlotsForFace(Facing side)
{
return side == Facing.UP ? inputSlots : outputSlots;
}
/**
* Returns true if automation can insert the given item in the given slot from the given side. Args: slot, item,
* side
*/
public boolean canInsertItem(int index, ItemStack itemStackIn, Facing direction)
{
return this.isItemValidForSlot(index, itemStackIn);
}
/**
* Returns true if automation can extract the given item in the given slot from the given side. Args: slot, item,
* side
*/
public boolean canExtractItem(int index, ItemStack stack, Facing direction)
{
return true;
}
public Container createContainer(EntityNPC playerInventory)
{
return new ContainerBrewingStand(playerInventory, this);
}
public int getField(int id)
{
switch (id)
{
case 0:
return this.brewTime;
default:
return 0;
}
}
public void setField(int id, int value)
{
switch (id)
{
case 0:
this.brewTime = value;
default:
}
}
public int getFieldCount()
{
return 1;
}
public void clear()
{
for (int i = 0; i < this.brewingItemStacks.length; ++i)
{
this.brewingItemStacks[i] = null;
}
}
public int getColor() {
return 0xffdf80;
}
}

View file

@ -101,12 +101,6 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory
public void setInventorySlotContents(int index, ItemStack stack)
{
this.chestContents[index] = stack;
if (stack != null && stack.getSize() > this.getInventoryStackLimit())
{
stack.setSize(this.getInventoryStackLimit());
}
this.markDirty();
}
@ -171,14 +165,6 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory
}
}
/**
* 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;
}
/**
* Do not make give this method the name canInteractWith because it clashes with Container
*/
@ -229,7 +215,7 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory
this.numPlayersUsing = using;
}
public void openInventory(EntityNPC player)
public void onOpened()
{
// if (!player.isSpectator())
// {
@ -247,7 +233,7 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory
// }
}
public void closeInventory(EntityNPC player)
public void onClosed()
{
if (/* !player.isSpectator() && */ this.getBlockType() instanceof BlockChest)
{
@ -260,28 +246,6 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory
}
}
/**
* 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 void clear()
{
for (int i = 0; i < this.chestContents.length; ++i)

View file

@ -1,291 +0,0 @@
package common.tileentity;
import common.block.tech.BlockDispenser;
import common.collect.Lists;
import common.entity.npc.EntityNPC;
import common.inventory.Container;
import common.inventory.ContainerDispenser;
import common.item.ItemStack;
import common.rng.Random;
import common.tags.TagObject;
import common.util.BlockPos;
import common.util.Facing;
import common.vars.Vars;
import common.world.AWorldServer;
import common.world.State;
import java.util.List;
public class TileEntityDispenser extends TileEntityInventory implements ITickable
{
private static final Random RNG = new Random();
private ItemStack[] stacks = new ItemStack[9];
private int cooldown = 0;
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
{
return 9;
}
/**
* Returns the stack in the given slot.
*/
public ItemStack getStackInSlot(int index)
{
return this.stacks[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.stacks[index] != null)
{
if (this.stacks[index].getSize() <= count)
{
ItemStack itemstack1 = this.stacks[index];
this.stacks[index] = null;
this.markDirty();
return itemstack1;
}
else
{
ItemStack itemstack = this.stacks[index].split(count);
if (this.stacks[index].isEmpty())
{
this.stacks[index] = null;
}
this.markDirty();
return itemstack;
}
}
else
{
return null;
}
}
/**
* Removes a stack from the given slot and returns it.
*/
public ItemStack removeStackFromSlot(int index)
{
if (this.stacks[index] != null)
{
ItemStack itemstack = this.stacks[index];
this.stacks[index] = null;
return itemstack;
}
else
{
return null;
}
}
public int getDispenseSlot()
{
int i = -1;
int j = 1;
for (int k = 0; k < this.stacks.length; ++k)
{
if (this.stacks[k] != null && RNG.zrange(j++) == 0)
{
i = k;
}
}
return i;
}
/**
* 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.stacks[index] = stack;
if (stack != null && stack.getSize() > this.getInventoryStackLimit())
{
stack.setSize(this.getInventoryStackLimit());
}
this.markDirty();
}
/**
* Add the given ItemStack to this Dispenser. Return the Slot the Item was placed in or -1 if no free slot is
* available.
*/
public int addItemStack(ItemStack stack)
{
for (int i = 0; i < this.stacks.length; ++i)
{
if (this.stacks[i] == null || this.stacks[i].getItem() == null)
{
this.setInventorySlotContents(i, stack);
return i;
}
}
return -1;
}
public void readTags(TagObject compound)
{
super.readTags(compound);
this.cooldown = compound.getInt("Cooldown");
List<TagObject> nbttaglist = compound.getList("Items");
this.stacks = 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.stacks.length)
{
this.stacks[j] = ItemStack.readFromTag(nbttagcompound);
}
}
}
public void writeTags(TagObject compound)
{
super.writeTags(compound);
compound.setInt("Cooldown", this.cooldown);
List<TagObject> nbttaglist = Lists.newArrayList();
for (int i = 0; i < this.stacks.length; ++i)
{
if (this.stacks[i] != null)
{
TagObject nbttagcompound = new TagObject();
nbttagcompound.setByte("Slot", (byte)i);
this.stacks[i].writeTags(nbttagcompound);
nbttaglist.add(nbttagcompound);
}
}
compound.setList("Items", nbttaglist);
}
/**
* 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;
}
/**
* Do not make give this method the name canInteractWith because it clashes with Container
*/
public boolean isUseableByPlayer(EntityNPC player)
{
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 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;
}
public Container createContainer(EntityNPC playerInventory)
{
return new ContainerDispenser(playerInventory, this);
}
public int getField(int id)
{
return 0;
}
public void setField(int id, int value)
{
}
public int getFieldCount()
{
return 0;
}
public void clear()
{
for (int i = 0; i < this.stacks.length; ++i)
{
this.stacks[i] = null;
}
}
public int getColor() {
return 0xffbf00;
}
protected ItemStack dispenseStack(ItemStack stack, AWorldServer world, BlockPos pos)
{
Facing facing = world.getState(pos).getValue(BlockDispenser.FACING);
ItemStack nstack = stack.getItem().dispenseStack(world, world.getTileEntity(pos), BlockDispenser.getDispensePosition(pos, facing), pos, facing, stack);
int id = stack.getItem().getDispenseSoundId();
if(id != 0)
world.playEffect(id, pos, 0);
world.playEffect(2000, pos, facing.getFrontOffsetX() + 1 + (facing.getFrontOffsetZ() + 1) * 3);
return nstack;
}
protected void dispense(AWorldServer worldIn, BlockPos pos)
{
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof TileEntityDispenser tileentitydispenser)
{
int i = tileentitydispenser.getDispenseSlot();
if (i < 0)
{
return;
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
if(itemstack != null) {
ItemStack itemstack1 = this.dispenseStack(itemstack, worldIn, pos);
tileentitydispenser.setInventorySlotContents(i, itemstack1.isEmpty() ? null : itemstack1);
}
}
}
}
public void update() {
if(this.worldObj != null && !this.worldObj.client) {
if (this.cooldown <= 0)
{
State state = this.getBlockState();
if(!(state.getBlock() instanceof BlockDispenser) || !this.decrPower())
return;
this.dispense((AWorldServer)this.worldObj, this.pos);
this.cooldown = Vars.dispenserDelay;
}
else {
this.cooldown--;
}
}
}
}

View file

@ -1,77 +0,0 @@
package common.tileentity;
import common.block.tech.BlockDispenser;
import common.inventory.IInventory;
import common.item.ItemStack;
import common.util.BlockPos;
import common.util.Facing;
import common.world.AWorldServer;
public class TileEntityDropper extends TileEntityDispenser
{
protected ItemStack dispenseStack(ItemStack stack, AWorldServer world, BlockPos pos)
{
Facing facing = world.getState(pos).getValue(BlockDispenser.FACING);
BlockDispenser.dispense(world, 6.0, facing, BlockDispenser.getDispensePosition(pos, facing), stack.split(1));
world.playEffect(1000, pos, 0);
world.playEffect(2000, pos, facing.getFrontOffsetX() + 1 + (facing.getFrontOffsetZ() + 1) * 3);
return stack;
}
protected void dispense(AWorldServer worldIn, BlockPos pos)
{
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof TileEntityDispenser tileentitydispenser)
{
int i = tileentitydispenser.getDispenseSlot();
if (i < 0)
{
return;
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
if (itemstack != null)
{
Facing enumfacing = (Facing)worldIn.getState(pos).getValue(BlockDispenser.FACING);
BlockPos blockpos = pos.offset(enumfacing);
IInventory iinventory = TileEntityHopper.getInventoryAtPosition(worldIn, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
ItemStack itemstack1;
if (iinventory == null)
{
itemstack1 = this.dispenseStack(itemstack, worldIn, pos);
if (itemstack1 != null && itemstack1.isEmpty())
{
itemstack1 = null;
}
}
else
{
itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(iinventory, itemstack.copy().split(1), enumfacing.getOpposite());
if (itemstack1 == null)
{
itemstack1 = itemstack.copy();
if (itemstack1.decrSize())
{
itemstack1 = null;
}
}
else
{
itemstack1 = itemstack.copy();
}
}
tileentitydispenser.setInventorySlotContents(i, itemstack1);
}
}
}
}
}

View file

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

View file

@ -6,13 +6,11 @@ import java.util.function.Predicate;
import common.block.Block;
import common.block.ITileEntityProvider;
import common.block.tech.BlockChest;
import common.block.tech.BlockHopper;
import common.block.tech.BlockPipe;
import common.collect.Lists;
import common.entity.Entity;
import common.entity.item.EntityItem;
import common.entity.npc.EntityNPC;
import common.inventory.Container;
import common.inventory.ContainerHopper;
import common.inventory.IInventory;
import common.inventory.ISidedInventory;
import common.item.ItemStack;
@ -25,7 +23,7 @@ import common.vars.Vars;
import common.world.State;
import common.world.World;
public class TileEntityHopper extends TileEntityInventory implements ITickable
public class TileEntityPipe extends TileEntity implements IInventory, ITickable
{
private ItemStack[] inventory = new ItemStack[5];
private int transferCooldown = -1;
@ -70,15 +68,6 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
compound.setInt("TransferCooldown", this.transferCooldown);
}
/**
* 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()
{
super.markDirty();
}
/**
* Returns the number of slots in the inventory.
*/
@ -149,19 +138,6 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
public void setInventorySlotContents(int index, ItemStack stack)
{
this.inventory[index] = stack;
if (stack != null && stack.getSize() > this.getInventoryStackLimit())
{
stack.setSize(this.getInventoryStackLimit());
}
}
/**
* 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;
}
/**
@ -172,22 +148,6 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
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 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;
}
/**
* Like the old updateEntity(), except more generic.
*/
@ -200,19 +160,19 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
if (!this.isOnTransferCooldown())
{
this.setTransferCooldown(0);
this.updateHopper();
this.updatePipe();
}
}
}
public boolean updateHopper()
public boolean updatePipe()
{
if (this.worldObj != null && !this.worldObj.client)
{
if (!this.isOnTransferCooldown())
{
State state = this.getBlockState();
if(!(state.getBlock() instanceof BlockHopper) || !this.decrPower())
if(!(state.getBlock() instanceof BlockPipe) || !this.decrPower())
return false;
boolean flag = false;
@ -223,12 +183,12 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
if (!this.isFull())
{
flag = captureDroppedItems(this, state.getValue(BlockHopper.FACING) != Facing.UP) || flag;
flag = captureDroppedItems(this, state.getValue(BlockPipe.FACING) != Facing.UP) || flag;
}
if (flag)
{
this.setTransferCooldown(Vars.hopperDelay);
this.setTransferCooldown(Vars.pipeDelay);
this.markDirty();
return true;
}
@ -270,7 +230,7 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
private boolean transferItemsOut()
{
IInventory iinventory = this.getInventoryForHopperTransfer();
IInventory iinventory = this.getInventoryForTransfer();
if (iinventory == null)
{
@ -279,7 +239,7 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
else
{
State state = this.getBlockState();
Facing enumfacing = state.getBlock() instanceof BlockHopper ? state.getValue(BlockHopper.FACING).getOpposite() : Facing.DOWN;
Facing enumfacing = state.getBlock() instanceof BlockPipe ? state.getValue(BlockPipe.FACING).getOpposite() : Facing.DOWN;
if (isInventoryFull(iinventory, enumfacing))
{
@ -309,9 +269,6 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
}
}
/**
* Returns false if the inventory has any room to place items in
*/
public static boolean isInventoryFull(IInventory inventoryIn, Facing side)
{
if (inventoryIn instanceof ISidedInventory)
@ -347,9 +304,6 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
return true;
}
/**
* Returns false if the specified IInventory contains any items
*/
public static boolean isInventoryEmpty(IInventory inventoryIn, Facing side)
{
if (inventoryIn instanceof ISidedInventory)
@ -381,9 +335,9 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
return true;
}
public static boolean captureDroppedItems(TileEntityHopper te, boolean down)
public static boolean captureDroppedItems(TileEntityPipe te, boolean down)
{
IInventory iinventory = getHopperInventory(te, !down);
IInventory iinventory = getPipeInventory(te, !down);
if (iinventory != null)
{
@ -434,18 +388,14 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
return false;
}
/**
* 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(TileEntityHopper hopper, IInventory inventoryIn, int index, Facing direction)
public static boolean pullItemFromSlot(TileEntityPipe pipe, IInventory inventoryIn, int index, Facing direction)
{
ItemStack itemstack = inventoryIn.getStackInSlot(index);
if (itemstack != null && canExtractItemFromSlot(inventoryIn, itemstack, index, direction))
{
ItemStack itemstack1 = itemstack.copy();
ItemStack itemstack2 = putStackInInventoryAllSlots(hopper, inventoryIn.decrStackSize(index, 1), (Facing)null);
ItemStack itemstack2 = putStackInInventoryAllSlots(pipe, inventoryIn.decrStackSize(index, 1), (Facing)null);
if (itemstack2 == null || itemstack2.isEmpty())
{
@ -459,10 +409,6 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
return false;
}
/**
* Attempts to place the passed EntityItem's stack into the inventory using as many slots as possible. Returns false
* if the stackSize of the drop was not depleted.
*/
public static boolean putDropInInventoryAllSlots(IInventory p_145898_0_, EntityItem itemIn)
{
boolean flag = false;
@ -490,9 +436,6 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
}
}
/**
* Attempts to place the passed stack in the inventory, using as many slots as required. Returns leftover items
*/
public static ItemStack putStackInInventoryAllSlots(IInventory inventoryIn, ItemStack stack, Facing side)
{
if (inventoryIn instanceof ISidedInventory && side != null)
@ -523,25 +466,16 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
return stack;
}
/**
* Can this hopper insert the specified item from the specified slot on the specified side?
*/
public static boolean canInsertItemInSlot(IInventory inventoryIn, ItemStack stack, int index, Facing side)
{
return !inventoryIn.isItemValidForSlot(index, stack) ? false : !(inventoryIn instanceof ISidedInventory) || ((ISidedInventory)inventoryIn).canInsertItem(index, stack, side);
}
/**
* Can this hopper extract the specified item from the specified slot on the specified side?
*/
public static boolean canExtractItemFromSlot(IInventory inventoryIn, ItemStack stack, int index, Facing side)
{
return !(inventoryIn instanceof ISidedInventory) || ((ISidedInventory)inventoryIn).canExtractItem(index, stack, side);
}
/**
* Insert the specified stack to the specified inventory and return any leftover items
*/
public static ItemStack insertStack(IInventory inventoryIn, ItemStack stack, int index, Facing side)
{
ItemStack itemstack = inventoryIn.getStackInSlot(index);
@ -567,13 +501,13 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
if (flag)
{
if (inventoryIn instanceof TileEntityHopper)
if (inventoryIn instanceof TileEntityPipe)
{
TileEntityHopper tileentityhopper = (TileEntityHopper)inventoryIn;
TileEntityPipe pipe = (TileEntityPipe)inventoryIn;
if (tileentityhopper.mayTransfer())
if (pipe.mayTransfer())
{
tileentityhopper.setTransferCooldown(Vars.hopperDelay);
pipe.setTransferCooldown(Vars.pipeDelay);
}
inventoryIn.markDirty();
@ -586,22 +520,16 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
return stack;
}
/**
* Returns the IInventory that this hopper is pointing into
*/
private IInventory getInventoryForHopperTransfer()
private IInventory getInventoryForTransfer()
{
State state = this.getBlockState();
Facing enumfacing = state.getBlock() instanceof BlockHopper ? state.getValue(BlockHopper.FACING) : Facing.DOWN;
Facing enumfacing = state.getBlock() instanceof BlockPipe ? state.getValue(BlockPipe.FACING) : Facing.DOWN;
return getInventoryAtPosition(this.getWorld(), (double)(this.pos.getX() + enumfacing.getFrontOffsetX()), (double)(this.pos.getY() + enumfacing.getFrontOffsetY()), (double)(this.pos.getZ() + enumfacing.getFrontOffsetZ()));
}
/**
* Returns the IInventory for the specified hopper
*/
public static IInventory getHopperInventory(TileEntityHopper hopper, boolean down)
public static IInventory getPipeInventory(TileEntityPipe pipe, boolean down)
{
return getInventoryAtPosition(hopper.getWorld(), hopper.getXPos(), hopper.getYPos() + (down ? -1.0 : 1.0), hopper.getZPos());
return getInventoryAtPosition(pipe.getWorld(), pipe.getXPos(), pipe.getYPos() + (down ? -1.0 : 1.0), pipe.getZPos());
}
public static List<EntityItem> func_181556_a(World p_181556_0_, double p_181556_1_, double p_181556_3_, double p_181556_5_)
@ -613,9 +541,6 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
});
}
/**
* Returns the IInventory (if applicable) of the TileEntity at the specified position
*/
public static IInventory getInventoryAtPosition(World worldIn, double x, double y, double z)
{
IInventory iinventory = null;
@ -677,25 +602,6 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
return this.transferCooldown <= 1;
}
public Container createContainer(EntityNPC playerInventory)
{
return new ContainerHopper(playerInventory, this, playerInventory);
}
public int getField(int id)
{
return 0;
}
public void setField(int id, int value)
{
}
public int getFieldCount()
{
return 0;
}
public void clear()
{
for (int i = 0; i < this.inventory.length; ++i)

View file

@ -249,8 +249,8 @@ public abstract class Vars {
public static int orbDamageOther = 0;
@Var(name = "healChance")
public static int healChance = 5;
@Var(name = "hopperCooldown", min = 0, max = 160)
public static int hopperDelay = 2;
@Var(name = "pipeCooldown", min = 0, max = 160)
public static int pipeDelay = 2;
@Var(name = "dispenserCooldown", min = 0, max = 160)
public static int dispenserDelay = 1;
@Var(name = "xpCooldown", min = 0, max = 10)

View file

@ -14,7 +14,7 @@ import common.block.foliage.LeavesType;
import common.block.liquid.BlockLiquid;
import common.block.natural.BlockSnow;
import common.block.tech.BlockAnvil;
import common.block.tech.BlockHopper;
import common.block.tech.BlockPipe;
import common.collect.Lists;
import common.collect.Sets;
import common.dimension.DimType;
@ -82,7 +82,7 @@ public abstract class World implements IWorldAccess {
return block.getMaterial().isOpaque() && block.isFullCube() ? true
: (block instanceof BlockStairs ? state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP
: (block instanceof BlockSlab ? state.getValue(BlockSlab.FACING) == Facing.UP
: (block instanceof BlockHopper ? true
: (block instanceof BlockPipe ? true
: (block instanceof BlockSnow ? ((Integer)state.getValue(BlockSnow.LAYERS)).intValue() == 7
: false))));
}

View file

@ -25,7 +25,7 @@ public class CommandItem extends Command {
}
});
this.setParamsOptional();
this.addInt("amount", 1, ItemStack.MAX_SIZE, 1);
this.addInt("amount", 1, 100000000, 1);
this.addTag("tag", 't');
this.setParamsRequired();
this.addPlayerEntityList("players", 'p', true, UserPolicy.NON_ADMINS_OR_SELF);

View file

@ -106,7 +106,6 @@ import common.packet.SPacketMessage.Type;
import common.tags.TagObject;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest;
import common.tileentity.TileEntityInventory;
import common.tileentity.Device;
import common.tileentity.TileEntitySign;
import common.util.BlockPos;
@ -735,20 +734,9 @@ public class Player extends User implements Executor, IPlayer
}
else if (object instanceof TileEntityChest chest)
{
if (chest.getLockCode() != null && !this.entity.canOpen(chest.getLockCode()))
{
this.addHotbar(Color.RED + "%s ist verschlossen!", chest.getName());
this.sendPacket(new SPacketSoundEffect(SoundEvent.DOOR, this.entity.posX, this.entity.posY, this.entity.posZ, 1.0F));
return;
}
this.sendPacket(new SPacketOpenWindow(this.getNextWindowId(), chest.getBlockType(), chest.getSizeInventory()));
this.entity.openContainer = new ContainerChest(this.entity, chest);
}
else if (object instanceof TileEntityInventory tile)
{
this.sendPacket(new SPacketOpenWindow(this.getNextWindowId(), tile.getBlockType(), tile.getSizeInventory()));
this.entity.openContainer = tile.createContainer(this.entity);
}
else if (object instanceof InteractionObject obj)
{
this.sendPacket(new SPacketOpenWindow(this.getNextWindowId(), obj.getBlock(), 0));
@ -868,14 +856,6 @@ public class Player extends User implements Executor, IPlayer
{
this.sendPacket(new SPacketWindowProperty(container.windowId, variable, value));
}
public void sendProperties(Container container, IInventory inventory)
{
for (int z = 0; z < inventory.getFieldCount(); z++)
{
this.sendPacket(new SPacketWindowProperty(container.windowId, z, inventory.getField(z)));
}
}
@ -2959,14 +2939,14 @@ public class Player extends User implements Executor, IPlayer
Slot slot = packet.getSlot() < 0 ? this.entity.inventoryContainer.getSlot(5 + Equipment.ARMOR_SLOTS + 27 + -2 - packet.getSlot()) : this.entity.openContainer.getSlot(packet.getSlot());
if(slot == null || !slot.canCheatItem())
return;
stack.setSize(Math.min(slot.getSlotStackLimit(), stack.getSize()));
stack.setSize(Math.min(slot.getItemStackLimit(stack), stack.getSize()));
amount = stack.getSize();
if(amount <= 0)
return;
if(slot.getHasStack()) {
ItemStack old = slot.getStack();
if(ItemStack.itemEquals(stack, old) && ItemStack.dataEquals(stack, old)) {
stack.setSize(Math.min(slot.getSlotStackLimit(), Math.min(stack.getMaxStackSize(), old.getSize() + stack.getSize())));
stack.setSize(Math.min(slot.getItemStackLimit(stack), Math.min(stack.getMaxStackSize(), old.getSize() + stack.getSize())));
amount = stack.getSize() - old.getSize();
if(amount <= 0 || !slot.isItemValid(stack))
return;

View file

@ -57,11 +57,6 @@ import common.block.natural.BlockSnow;
import common.block.tech.BlockAnvil;
import common.block.tech.BlockButton;
import common.block.tech.BlockCauldron;
import common.block.tech.BlockChest;
import common.block.tech.BlockDispenser;
import common.block.tech.BlockDropper;
import common.block.tech.BlockFurnace;
import common.block.tech.BlockHopper;
import common.block.tech.BlockLever;
import common.block.tech.BlockLever.EnumOrientation;
import common.block.tech.BlockPistonBase;
@ -76,34 +71,13 @@ import common.block.tech.BlockTNT;
import common.block.tech.BlockString;
import common.block.tech.BlockHook;
import common.block.tech.BlockWallSign;
import common.block.tech.BlockWarpChest;
import common.collect.Lists;
import common.collect.Maps;
import common.entity.Entity;
import common.entity.animal.EntityBat;
import common.entity.animal.EntityChicken;
import common.entity.animal.EntityCow;
import common.entity.animal.EntityHorse;
import common.entity.animal.EntityCat;
import common.entity.animal.EntityPig;
import common.entity.animal.EntityRabbit;
import common.entity.animal.EntitySheep;
import common.entity.animal.EntityWolf;
import common.entity.item.EntityBoat;
import common.entity.item.EntityMinecart;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.init.EntityRegistry;
import common.log.Log;
import common.rng.Random;
import common.tags.TagObject;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest;
import common.tileentity.TileEntityDispenser;
import common.tileentity.TileEntityDropper;
import common.tileentity.DeviceFurnace;
import common.tileentity.TileEntityHopper;
import common.tileentity.TileEntitySign;
import common.util.BlockPos;
import common.util.Facing;
import common.util.Facing.Axis;
@ -120,14 +94,6 @@ public abstract class Converter {
return tag != null && tag.getClass() == type;
}
private List<?> getList(String key, Class<?> type) {
Object tag = this.map.get(key);
if(!(tag instanceof List))
return Lists.newArrayList();
List<?> list = (List<?>)tag;
return !list.isEmpty() && list.get(0).getClass() != type ? Lists.newArrayList() : list;
}
public byte getByte(String key) {
return !this.has(key, Byte.class) ? 0 : (Byte)this.map.get(key);
}
@ -152,26 +118,13 @@ public abstract class Converter {
return !this.has(key, NbtTag.class) ? new NbtTag() : (NbtTag)this.map.get(key);
}
public float[] getFloatList(String key) {
List<?> list = this.getList(key, Float.class);
float[] values = new float[list.size()];
for(int z = 0; z < values.length; z++) {
values[z] = (Float)list.get(z);
}
return values;
}
public double[] getDoubleList(String key) {
List<?> list = this.getList(key, Double.class);
double[] values = new double[list.size()];
for(int z = 0; z < values.length; z++) {
values[z] = (Double)list.get(z);
}
return values;
}
public NbtTag[] getTagList(String key) {
List<?> list = this.getList(key, NbtTag.class);
Object tag = this.map.get(key);
if(!(tag instanceof List))
return new NbtTag[0];
List<?> list = (List<?>)tag;
if(!list.isEmpty() && list.get(0).getClass() != NbtTag.class)
return new NbtTag[0];
NbtTag[] values = new NbtTag[list.size()];
for(int z = 0; z < values.length; z++) {
values[z] = (NbtTag)list.get(z);
@ -287,27 +240,12 @@ public abstract class Converter {
}
private static final Random RANDOM = new Random();
private static final Map<String, String> ENTITY_MAP = Maps.newHashMap();
private static final Map<String, Class<? extends TileEntity>> TILE_MAP = Maps.newHashMap();
private static final State[] BLOCK_MAP = new State[65536];
private static final Color[] COLOR_LOOKUP = new Color[] {
Color.WHITE, Color.ORANGE, Color.MAGENTA, Color.LIGHT_BLUE, Color.YELLOW, Color.GREEN, Color.MAGENTA, Color.GRAY,
Color.LIGHT_GRAY, Color.CYAN, Color.VIOLET, Color.BLUE, Color.BROWN, Color.DARK_GREEN, Color.RED, Color.BLACK
};
private static void mapEntity(Class<? extends Entity> clazz, String ... names) {
String name = EntityRegistry.getEntityString(clazz);
for(String oldname : names) {
ENTITY_MAP.put(oldname, name);
}
}
private static void mapTile(Class<? extends TileEntity> clazz, String ... names) {
for(String oldname : names) {
TILE_MAP.put(oldname, clazz);
}
}
private static void mapBlock(State state, int id, int data) {
BLOCK_MAP[(id << 4) | data] = state;
}
@ -339,25 +277,6 @@ public abstract class Converter {
}
static {
mapEntity(EntityBoat.class, "Boat", "boat");
mapEntity(EntityMinecart.class, "Minecart", "MinecartRideable", "minecart");
mapEntity(EntityBat.class, "Bat", "bat");
mapEntity(EntityPig.class, "Pig", "pig");
mapEntity(EntitySheep.class, "Sheep", "sheep");
mapEntity(EntityCow.class, "Cow", "cow", "MushroomCow", "mooshroom");
mapEntity(EntityChicken.class, "Chicken", "chicken");
mapEntity(EntityWolf.class, "Wolf", "wolf");
mapEntity(EntityCat.class, "Ozelot", "ocelot");
mapEntity(EntityHorse.class, "EntityHorse", "horse");
mapEntity(EntityRabbit.class, "Rabbit", "rabbit");
mapTile(DeviceFurnace.class, "Furnace", "furnace");
mapTile(TileEntityChest.class, "Chest", "chest");
mapTile(TileEntityDispenser.class, "Trap", "dispenser");
mapTile(TileEntityDropper.class, "Dropper", "dropper");
mapTile(TileEntitySign.class, "Sign", "sign");
mapTile(TileEntityHopper.class, "Hopper", "hopper");
Arrays.fill(BLOCK_MAP, Blocks.air.getState());
mapBlock(Blocks.stone, 1);
@ -459,18 +378,7 @@ public abstract class Converter {
mapBlock(Blocks.glass, 20);
mapBlock(Blocks.lapis_ore, 21);
mapBlock(Blocks.lapis_block, 22);
mapBlock(Blocks.dispenser.getState().withProperty(BlockDispenser.FACING, Facing.DOWN), 23, 0, 6);
mapBlock(Blocks.dispenser.getState().withProperty(BlockDispenser.FACING, Facing.UP), 23, 1, 7);
mapBlock(Blocks.dispenser.getState().withProperty(BlockDispenser.FACING, Facing.NORTH), 23, 2);
mapBlock(Blocks.dispenser.getState().withProperty(BlockDispenser.FACING, Facing.SOUTH), 23, 3);
mapBlock(Blocks.dispenser.getState().withProperty(BlockDispenser.FACING, Facing.WEST), 23, 4);
mapBlock(Blocks.dispenser.getState().withProperty(BlockDispenser.FACING, Facing.EAST), 23, 5);
mapBlock(Blocks.dispenser.getState().withProperty(BlockDispenser.FACING, Facing.DOWN), 23, 8, 14);
mapBlock(Blocks.dispenser.getState().withProperty(BlockDispenser.FACING, Facing.UP), 23, 9, 15);
mapBlock(Blocks.dispenser.getState().withProperty(BlockDispenser.FACING, Facing.NORTH), 23, 10);
mapBlock(Blocks.dispenser.getState().withProperty(BlockDispenser.FACING, Facing.SOUTH), 23, 11);
mapBlock(Blocks.dispenser.getState().withProperty(BlockDispenser.FACING, Facing.WEST), 23, 12);
mapBlock(Blocks.dispenser.getState().withProperty(BlockDispenser.FACING, Facing.EAST), 23, 13);
mapBlock(Blocks.smooth_rock, 23);
mapBlock(Blocks.sandstone, 24);
mapBlock(Blocks.carved_sandstone, 24, 1);
mapBlock(Blocks.smooth_sandstone, 24, 2);
@ -654,10 +562,6 @@ public abstract class Converter {
mapBlock(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.WEST).withProperty(BlockStairs.HALF, EnumHalf.TOP), 53, 5, 13);
mapBlock(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.SOUTH).withProperty(BlockStairs.HALF, EnumHalf.TOP), 53, 6, 14);
mapBlock(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH).withProperty(BlockStairs.HALF, EnumHalf.TOP), 53, 7, 15);
mapBlock(Blocks.wood_chest.getState().withProperty(BlockChest.FACING, Facing.NORTH), 54);
mapBlock(Blocks.wood_chest.getState().withProperty(BlockChest.FACING, Facing.SOUTH), 54, 3, 9, 15);
mapBlock(Blocks.wood_chest.getState().withProperty(BlockChest.FACING, Facing.WEST), 54, 4, 10);
mapBlock(Blocks.wood_chest.getState().withProperty(BlockChest.FACING, Facing.EAST), 54, 5, 11);
mapBlock(Blocks.diamond_ore, 56);
mapBlock(Blocks.diamond_block, 57);
mapBlock(Blocks.workbench, 58);
@ -677,14 +581,8 @@ public abstract class Converter {
mapBlock(Blocks.farmland.getState().withProperty(BlockFarmland.MOISTURE, 5), 60, 5, 13);
mapBlock(Blocks.farmland.getState().withProperty(BlockFarmland.MOISTURE, 6), 60, 6, 14);
mapBlock(Blocks.farmland.getState().withProperty(BlockFarmland.MOISTURE, 7), 60, 7, 15);
mapBlock(Blocks.stone_furnace.getState().withProperty(BlockFurnace.FACING, Facing.NORTH), 61);
mapBlock(Blocks.stone_furnace.getState().withProperty(BlockFurnace.FACING, Facing.SOUTH), 61, 3, 9, 15);
mapBlock(Blocks.stone_furnace.getState().withProperty(BlockFurnace.FACING, Facing.WEST), 61, 4, 10);
mapBlock(Blocks.stone_furnace.getState().withProperty(BlockFurnace.FACING, Facing.EAST), 61, 5, 11);
mapBlock(Blocks.lit_stone_furnace.getState().withProperty(BlockFurnace.FACING, Facing.NORTH), 62);
mapBlock(Blocks.lit_stone_furnace.getState().withProperty(BlockFurnace.FACING, Facing.SOUTH), 62, 3, 9, 15);
mapBlock(Blocks.lit_stone_furnace.getState().withProperty(BlockFurnace.FACING, Facing.WEST), 62, 4, 10);
mapBlock(Blocks.lit_stone_furnace.getState().withProperty(BlockFurnace.FACING, Facing.EAST), 62, 5, 11);
mapBlock(Blocks.smooth_rock, 61);
mapBlock(Blocks.smooth_rock, 62);
mapBlock(Blocks.sign.getState().withProperty(BlockStandingSign.FACING, Facing.SOUTH), 63, 0, 1, 14, 15);
mapBlock(Blocks.sign.getState().withProperty(BlockStandingSign.FACING, Facing.WEST), 63, 2, 3, 4, 5);
mapBlock(Blocks.sign.getState().withProperty(BlockStandingSign.FACING, Facing.NORTH), 63, 6, 7, 8, 9);
@ -942,8 +840,6 @@ public abstract class Converter {
mapBlock(Blocks.soul_grass.getState().withProperty(BlockSoulGrass.AGE, 1), 115, 1);
mapBlock(Blocks.soul_grass.getState().withProperty(BlockSoulGrass.AGE, 2), 115, 2);
mapBlock(Blocks.soul_grass.getState().withProperty(BlockSoulGrass.AGE, 3), 115, 3);
mapBlock(Blocks.enchanting_table, 116);
mapBlock(Blocks.brewing_stand, 117);
mapBlock(Blocks.cauldron.getState().withProperty(BlockCauldron.LEVEL, 0), 118);
mapBlock(Blocks.cauldron.getState().withProperty(BlockCauldron.LEVEL, 1), 118, 1);
mapBlock(Blocks.cauldron.getState().withProperty(BlockCauldron.LEVEL, 2), 118, 2);
@ -999,10 +895,6 @@ public abstract class Converter {
mapBlock(Blocks.sandstone_stairs.getState().withProperty(BlockStairs.FACING, Facing.SOUTH).withProperty(BlockStairs.HALF, EnumHalf.TOP), 128, 6, 14);
mapBlock(Blocks.sandstone_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH).withProperty(BlockStairs.HALF, EnumHalf.TOP), 128, 7, 15);
mapBlock(Blocks.emerald_ore, 129);
mapBlock(Blocks.warp_chest.getState().withProperty(BlockWarpChest.FACING, Facing.NORTH), 130);
mapBlock(Blocks.warp_chest.getState().withProperty(BlockWarpChest.FACING, Facing.SOUTH), 130, 3, 9, 15);
mapBlock(Blocks.warp_chest.getState().withProperty(BlockWarpChest.FACING, Facing.WEST), 130, 4, 10);
mapBlock(Blocks.warp_chest.getState().withProperty(BlockWarpChest.FACING, Facing.EAST), 130, 5, 11);
mapBlock(Blocks.hook.getState().withProperty(BlockHook.ATTACHED, false).withProperty(BlockHook.FACING, Facing.SOUTH).withProperty(BlockHook.TRIGGERED, false), 131, 0);
mapBlock(Blocks.hook.getState().withProperty(BlockHook.ATTACHED, false).withProperty(BlockHook.FACING, Facing.WEST).withProperty(BlockHook.TRIGGERED, false), 131, 1);
mapBlock(Blocks.hook.getState().withProperty(BlockHook.ATTACHED, false).withProperty(BlockHook.FACING, Facing.NORTH).withProperty(BlockHook.TRIGGERED, false), 131, 2);
@ -1101,10 +993,6 @@ public abstract class Converter {
mapBlock(Blocks.anvil.getState().withProperty(BlockAnvil.FACING, Facing.WEST), 145, 1, 5, 9, 13);
mapBlock(Blocks.anvil.getState().withProperty(BlockAnvil.FACING, Facing.NORTH), 145, 2, 6, 10, 14);
mapBlock(Blocks.anvil.getState().withProperty(BlockAnvil.FACING, Facing.EAST), 145, 3, 7, 11, 15);
mapBlock(Blocks.wood_chest.getState().withProperty(BlockChest.FACING, Facing.NORTH), 146);
mapBlock(Blocks.wood_chest.getState().withProperty(BlockChest.FACING, Facing.SOUTH), 146, 3, 9, 15);
mapBlock(Blocks.wood_chest.getState().withProperty(BlockChest.FACING, Facing.WEST), 146, 4, 10);
mapBlock(Blocks.wood_chest.getState().withProperty(BlockChest.FACING, Facing.EAST), 146, 5, 11);
mapBlock(Blocks.light_weighted_pressure_plate.getState().withProperty(BlockPressurePlateWeighted.POWER, 0), 147, 0);
mapBlock(Blocks.light_weighted_pressure_plate.getState().withProperty(BlockPressurePlateWeighted.POWER, 1), 147, 1);
mapBlock(Blocks.light_weighted_pressure_plate.getState().withProperty(BlockPressurePlateWeighted.POWER, 2), 147, 2);
@ -1139,16 +1027,6 @@ public abstract class Converter {
mapBlock(Blocks.heavy_weighted_pressure_plate.getState().withProperty(BlockPressurePlateWeighted.POWER, 15), 148, 15);
mapBlock(Blocks.cobblestone, 152);
mapBlock(Blocks.quartz_ore, 153);
mapBlock(Blocks.hopper.getState().withProperty(BlockHopper.FACING, Facing.DOWN), 154, 0, 1, 6, 7);
mapBlock(Blocks.hopper.getState().withProperty(BlockHopper.FACING, Facing.NORTH), 154, 2);
mapBlock(Blocks.hopper.getState().withProperty(BlockHopper.FACING, Facing.SOUTH), 154, 3);
mapBlock(Blocks.hopper.getState().withProperty(BlockHopper.FACING, Facing.WEST), 154, 4);
mapBlock(Blocks.hopper.getState().withProperty(BlockHopper.FACING, Facing.EAST), 154, 5);
mapBlock(Blocks.hopper.getState().withProperty(BlockHopper.FACING, Facing.DOWN), 154, 8, 9, 14, 15);
mapBlock(Blocks.hopper.getState().withProperty(BlockHopper.FACING, Facing.NORTH), 154, 10);
mapBlock(Blocks.hopper.getState().withProperty(BlockHopper.FACING, Facing.SOUTH), 154, 11);
mapBlock(Blocks.hopper.getState().withProperty(BlockHopper.FACING, Facing.WEST), 154, 12);
mapBlock(Blocks.hopper.getState().withProperty(BlockHopper.FACING, Facing.EAST), 154, 13);
mapBlock(Blocks.quartz_block, 155);
mapBlock(Blocks.quartz_ornaments, 155, 1);
mapBlock(Blocks.quartz_pillar.getState().withProperty(BlockQuartzPillar.AXIS, Facing.Axis.Y), 155, 2);
@ -1174,18 +1052,7 @@ public abstract class Converter {
mapBlock(Blocks.rail.getState().withProperty(BlockRail.SHAPE, EnumRailDirection.ASCENDING_WEST), 157, 11);
mapBlock(Blocks.rail.getState().withProperty(BlockRail.SHAPE, EnumRailDirection.ASCENDING_NORTH), 157, 12);
mapBlock(Blocks.rail.getState().withProperty(BlockRail.SHAPE, EnumRailDirection.ASCENDING_SOUTH), 157, 13);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.DOWN), 158, 0, 6);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.UP), 158, 1, 7);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.NORTH), 158, 2);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.SOUTH), 158, 3);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.WEST), 158, 4);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.EAST), 158, 5);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.DOWN), 158, 8, 14);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.UP), 158, 9, 15);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.NORTH), 158, 10);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.SOUTH), 158, 11);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.WEST), 158, 12);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.EAST), 158, 13);
mapBlock(Blocks.smooth_rock, 158);
mapBlock(new BlockFunction() {
public State getState(int id, int data) {
return BlockColoredClay.getByColor(COLOR_LOOKUP[data]).getState();
@ -1418,18 +1285,7 @@ public abstract class Converter {
mapBlock(Blocks.blood_brick, 215);
mapBlock(Blocks.quartz_block, 216);
mapBlock(Blocks.glass, 217);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.DOWN), 218, 0, 6);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.UP), 218, 1, 7);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.NORTH), 218, 2);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.SOUTH), 218, 3);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.WEST), 218, 4);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.EAST), 218, 5);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.DOWN), 218, 8, 14);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.UP), 218, 9, 15);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.NORTH), 218, 10);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.SOUTH), 218, 11);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.WEST), 218, 12);
mapBlock(Blocks.dropper.getState().withProperty(BlockDropper.FACING, Facing.EAST), 218, 13);
mapBlock(Blocks.smooth_rock, 218);
for(int id = 219; id <= 234; id++) {
mapBlock(BlockWool.getByColor(COLOR_LOOKUP[id - 219]).getState(), id);
}
@ -1513,43 +1369,41 @@ public abstract class Converter {
return (NbtTag)read(in, (byte)10);
}
private static TagObject convertTile(NbtTag ent, Class<? extends TileEntity> clazz) {
private static TagObject convertText(NbtTag ent) {
TagObject nent = new TagObject();
if(clazz == TileEntitySign.class) {
String[] signText = new String[4];
for(int i = 0; i < 4; ++i) {
signText[i] = ent.getString("Text" + (i + 1));
}
byte newComp = 0;
byte quotes = 0;
String[] old = new String[4];
for(int i = 0; i < 4; ++i) {
old[i] = signText[i];
signText[i] = signText[i].indexOf('\u00A7') != -1 ?
signText[i].replaceAll("\u00A7[0-9a-fA-Fk-oK-O]", "") :
signText[i];
if(signText[i].startsWith("{") && signText[i].endsWith("}")) {
try {
signText[i] = "<JSON>";
newComp++;
}
catch(Throwable e) {
}
}
else if(signText[i].startsWith("\"") && signText[i].endsWith("\"")) {
String[] signText = new String[4];
for(int i = 0; i < 4; ++i) {
signText[i] = ent.getString("Text" + (i + 1));
}
byte newComp = 0;
byte quotes = 0;
String[] old = new String[4];
for(int i = 0; i < 4; ++i) {
old[i] = signText[i];
signText[i] = signText[i].indexOf('\u00A7') != -1 ?
signText[i].replaceAll("\u00A7[0-9a-fA-Fk-oK-O]", "") :
signText[i];
if(signText[i].startsWith("{") && signText[i].endsWith("}")) {
try {
signText[i] = "<JSON>";
newComp++;
quotes |= 1 << i;
}
catch(Throwable e) {
}
}
for(int i = 0; i < 4; ++i) {
if(newComp == 4 && (quotes & (1 << i)) != 0) {
signText[i] = signText[i].substring(1, signText[i].length() - 1);
}
else if(signText[i].startsWith("\"") && signText[i].endsWith("\"")) {
newComp++;
quotes |= 1 << i;
}
for(int i = 0; i < 4; ++i) {
nent.setString("Text" + (i + 1), signText[i]);
}
for(int i = 0; i < 4; ++i) {
if(newComp == 4 && (quotes & (1 << i)) != 0) {
signText[i] = signText[i].substring(1, signText[i].length() - 1);
}
}
for(int i = 0; i < 4; ++i) {
nent.setString("Text" + (i + 1), signText[i]);
}
return nent;
}
@ -1644,50 +1498,23 @@ public abstract class Converter {
ntag.setBool("P", true);
ntag.setBool("L", tag.getByte("LightPopulated") != 0);
NbtTag[] ents = tag.getTagList("Entities");
List<TagObject> entities = Lists.newArrayList();
for(NbtTag ent : ents) {
TagObject nent = new TagObject();
String mapped = ENTITY_MAP.get(trimColon(ent.getString("id")));
if(mapped != null) {
double[] pos = ent.getDoubleList("Pos");
double[] motion = ent.getDoubleList("Motion");
float[] rotation = ent.getFloatList("Rotation");
if(pos.length != 3 || motion.length != 3 || rotation.length != 2)
continue;
boolean ground = ent.getByte("OnGround") != 0;
nent.setDouble("PosX", pos[0]);
nent.setDouble("PosY", pos[1]);
nent.setDouble("PosZ", pos[2]);
nent.setDouble("MotionX", motion[0]);
nent.setDouble("MotionY", motion[1]);
nent.setDouble("MotionZ", motion[2]);
nent.setFloat("Yaw", rotation[0]);
nent.setFloat("Pitch", rotation[1]);
nent.setBool("OnGround", ground);
nent.setString("id", mapped);
entities.add(nent);
}
}
ntag.setList("E", entities);
ntag.setList("E", Lists.newArrayList());
ents = tag.getTagList("TileEntities");
entities = Lists.newArrayList();
for(NbtTag ent : ents) {
TagObject nent = new TagObject();
Class<? extends TileEntity> mapped = TILE_MAP.get(trimColon(ent.getString("id")));
if(mapped != null) {
nent = convertTile(ent, mapped);
NbtTag[] tes = tag.getTagList("TileEntities");
List<TagObject> list = Lists.newArrayList();
for(NbtTag ent : tes) {
if(trimColon(ent.getString("id")).equalsIgnoreCase("sign")) {
TagObject nent = convertText(ent);
nent.setByte("X", (byte)(ent.getInt("x") & 15));
nent.setShort("Y", (short)ent.getInt("y"));
nent.setByte("Z", (byte)(ent.getInt("z") & 15));
entities.add(nent);
list.add(nent);
}
}
ntag.setList("B", entities);
ntag.setList("B", list);
NbtTag[] sects = tag.getTagList("Sections");
entities = Lists.newArrayList();
list = Lists.newArrayList();
char[] mapping = Region.getEncodeMap();
NbtTag[] sections = new NbtTag[16];
for(NbtTag sect : sects) {
@ -1742,14 +1569,14 @@ public abstract class Converter {
nsect.setByteArray("D", newblks);
nsect.setByteArray("B", sect.getByteArray("BlockLight"));
nsect.setByteArray("S", sect.getByteArray("SkyLight"));
entities.add(nsect);
list.add(nsect);
}
lastBlocks = blocks;
lastData = data;
lastAdd = adddata;
}
ntag.setList("S", entities);
ntag.setList("S", list);
return ntag;
}

View file

@ -7,7 +7,6 @@ import common.block.Directional;
import common.block.Rotatable;
import common.block.artificial.BlockDoor;
import common.block.tech.BlockButton;
import common.block.tech.BlockDispenser;
import common.block.tech.BlockLever;
import common.block.tech.BlockPistonBase;
import common.block.tech.BlockRail;
@ -390,7 +389,7 @@ public abstract class StructureComponent
}
}
}
else if (blockIn instanceof BlockPistonBase || blockIn instanceof BlockDispenser)
else if (blockIn instanceof BlockPistonBase)
{
Facing meta = state.getValue(Directional.FACING);
if (this.coordBaseMode == Facing.SOUTH)