pre-fix for guis, large chests

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

View file

@ -1233,8 +1233,12 @@ public class Client implements IThreadListener {
{ {
if(!this.refreshing) if(!this.refreshing)
this.waitingForFile = false; this.waitingForFile = false;
if(this.player != null) if(this.player != null) {
this.player.setScreenClosed(); if(this.getNetHandler() != null)
this.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_CONTAINER, this.player.openContainer.windowId));
this.player.inventory.setItemStack(null);
this.player.openContainer = this.player.inventoryContainer;
}
if (this.open != null) if (this.open != null)
{ {
this.open.onGuiClosed(); this.open.onGuiClosed();

View file

@ -1,5 +1,6 @@
package client.gui.container; package client.gui.container;
import common.init.Blocks;
import common.inventory.ContainerBrewingStand; import common.inventory.ContainerBrewingStand;
import common.inventory.IInventory; import common.inventory.IInventory;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
@ -25,7 +26,7 @@ public class GuiBrewing extends GuiContainer {
} }
public void addElements() { public void addElements() {
this.label(this.brewer.getCommandName(), 8, 6); this.label(Blocks.brewing_stand.getDisplay(), 8, 6);
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2); this.label("Inventar", 8, this.ySize - 96 + 2);
} }
} }

View file

@ -1,24 +1,24 @@
package client.gui.container; package client.gui.container;
import client.Client; import client.Client;
import common.block.Block;
import common.inventory.ContainerChest; import common.inventory.ContainerChest;
import common.inventory.IInventory; import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
public class GuiChest extends GuiContainer { public class GuiChest extends GuiContainer {
private final IInventory upper; private final Block block;
private final IInventory lower;
public GuiChest(IInventory upper, IInventory lower) { public GuiChest(InventoryPlayer inv, IInventory chest, Block block) {
super(new ContainerChest(upper, lower, Client.CLIENT.player)); super(new ContainerChest(inv, chest, Client.CLIENT.player));
this.upper = upper; this.block = block;
this.lower = lower;
int i = 222; int i = 222;
int j = i - 108; int j = i - 108;
this.ySize = j + (lower.getSizeInventory() / 9) * 18; this.ySize = j + (chest.getSizeInventory() / 9) * 18;
} }
public void addElements() { public void addElements() {
this.label(this.lower.getCommandName(), 8, 6); this.label(this.block.getDisplay(), 8, 6);
this.label(this.upper.getCommandName(), 8, this.ySize - 96 + 2); this.label("Inventar", 8, this.ySize - 96 + 2);
} }
} }

View file

@ -5,18 +5,18 @@ import client.gui.element.Label;
import common.inventory.ContainerTile; import common.inventory.ContainerTile;
import common.inventory.IInventory; import common.inventory.IInventory;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
import common.tileentity.TileEntityDevice; import common.tileentity.Device;
public class GuiTile extends GuiContainer { public class GuiDevice extends GuiContainer {
private final IInventory playerInv; private final IInventory playerInv;
private final IInventory tileInv; private final IInventory tileInv;
private final TileEntityDevice tile; private final Device tile;
private Label header; private Label header;
private Label temp; private Label temp;
private Label desc; private Label desc;
public GuiTile(InventoryPlayer player, IInventory inv, TileEntityDevice tile) { public GuiDevice(InventoryPlayer player, IInventory inv, Device tile) {
super(new ContainerTile(player, tile, inv, Client.CLIENT.player)); super(new ContainerTile(player, tile, inv, Client.CLIENT.player));
this.playerInv = player; this.playerInv = player;
this.tileInv = tile; this.tileInv = tile;
@ -26,14 +26,14 @@ public class GuiTile extends GuiContainer {
public void updateScreen() { public void updateScreen() {
super.updateScreen(); super.updateScreen();
this.header.setText(this.tile.getStatus().color + this.tileInv.getCommandName() + " - " + this.tile.getStatus().name); this.header.setText(this.tile.getStatus().color + this.tile.getBlockType().getDisplay() + " - " + this.tile.getStatus().name);
this.temp.setText(String.format("Temperatur: %d °", this.tile.getTemperature())); this.temp.setText(String.format("Temperatur: %d °", this.tile.getTemperature()));
this.desc.setText(this.tile.formatDisplay((ContainerTile)this.inventorySlots)); this.desc.setText(this.tile.formatDisplay((ContainerTile)this.inventorySlots));
} }
public void addElements() { public void addElements() {
this.header = this.label("", 8, 6); this.header = this.label("", 8, 6);
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2); this.label("Inventar", 8, this.ySize - 96 + 2);
this.temp = this.label("", 8, 18); this.temp = this.label("", 8, 18);
this.desc = this.label("", 8, 28); this.desc = this.label("", 8, 28);
} }

View file

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

View file

@ -6,6 +6,7 @@ import client.gui.element.Label;
import client.gui.element.PressType; import client.gui.element.PressType;
import common.color.TextColor; import common.color.TextColor;
import common.enchantment.Enchantment; import common.enchantment.Enchantment;
import common.init.Blocks;
import common.inventory.ContainerEnchantment; import common.inventory.ContainerEnchantment;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
import common.rng.Random; import common.rng.Random;
@ -17,20 +18,16 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
"the elder scrolls klaatu berata niktu xyzzy bless curse light darkness fire air earth water hot dry cold wet ignite snuff embiggen twist shorten stretch fiddle destroy imbue galvanize enchant free limited range of towards inside sphere cube self other ball mental physical grow shrink demon elemental spirit animal creature beast humanoid undead fresh stale " "the elder scrolls klaatu berata niktu xyzzy bless curse light darkness fire air earth water hot dry cold wet ignite snuff embiggen twist shorten stretch fiddle destroy imbue galvanize enchant free limited range of towards inside sphere cube self other ball mental physical grow shrink demon elemental spirit animal creature beast humanoid undead fresh stale "
.split(" "); .split(" ");
private final InventoryPlayer playerInv;
private final Random nameRand = new Random(); private final Random nameRand = new Random();
private final Random random = new Random(); private final Random random = new Random();
private final ContainerEnchantment enchantment; private final ContainerEnchantment enchantment;
private final String title;
private final ActButton[] buttons = new ActButton[3]; private final ActButton[] buttons = new ActButton[3];
private final Label[] labels = new Label[3]; private final Label[] labels = new Label[3];
private final Label[] mana = new Label[3]; private final Label[] mana = new Label[3];
public GuiEnchant(InventoryPlayer inv, World world, String title) { public GuiEnchant(InventoryPlayer inv, World world) {
super(new ContainerEnchantment(inv, world)); super(new ContainerEnchantment(inv, world));
this.playerInv = inv;
this.enchantment = (ContainerEnchantment)this.inventorySlots; this.enchantment = (ContainerEnchantment)this.inventorySlots;
this.title = title;
} }
public void updateScreen() { public void updateScreen() {
@ -62,8 +59,8 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
} }
public void addElements() { public void addElements() {
this.label(this.title, 12, 5); this.label(Blocks.enchanting_table.getDisplay(), 12, 5);
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2); this.label("Inventar", 8, this.ySize - 96 + 2);
for(int l = 0; l < 3; ++l) { for(int l = 0; l < 3; ++l) {
int i1 = 60; int i1 = 60;
int j1 = i1 + 2; int j1 = i1 + 2;

View file

@ -6,17 +6,15 @@ import common.inventory.ContainerEntityInventory;
import common.inventory.IInventory; import common.inventory.IInventory;
public class GuiEntity extends GuiContainer { public class GuiEntity extends GuiContainer {
private final IInventory playerInv; private final String title;
private final IInventory entity;
public GuiEntity(IInventory playerInv, IInventory entityInv, Entity entity) { public GuiEntity(IInventory playerInv, IInventory entityInv, Entity entity) {
super(new ContainerEntityInventory(playerInv, entityInv, entity, Client.CLIENT.player)); super(new ContainerEntityInventory(playerInv, entityInv, entity, Client.CLIENT.player));
this.playerInv = playerInv; this.title = entity.getName();
this.entity = entityInv;
} }
public void addElements() { public void addElements() {
this.label(this.entity.getCommandName(), 8, 6); this.label(this.title, 8, 6);
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2); this.label("Inventar", 8, this.ySize - 96 + 2);
} }
} }

View file

@ -1,17 +1,18 @@
package client.gui.container; package client.gui.container;
import common.block.tech.BlockFurnace;
import common.inventory.ContainerFurnace; import common.inventory.ContainerFurnace;
import common.inventory.IInventory; import common.inventory.IInventory;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
import common.tileentity.TileEntityFurnace; import common.tileentity.TileEntityFurnace;
public class GuiFurnace extends GuiContainer { public class GuiFurnace extends GuiContainer {
private final InventoryPlayer playerInv; private final BlockFurnace block;
private final IInventory furnace; private final IInventory furnace;
public GuiFurnace(InventoryPlayer playerInv, IInventory furnaceInv) { public GuiFurnace(InventoryPlayer playerInv, IInventory furnaceInv, BlockFurnace block) {
super(new ContainerFurnace(playerInv, furnaceInv)); super(new ContainerFurnace(playerInv, furnaceInv));
this.playerInv = playerInv; this.block = block;
this.furnace = furnaceInv; this.furnace = furnaceInv;
} }
@ -31,8 +32,8 @@ public class GuiFurnace extends GuiContainer {
} }
public void addElements() { public void addElements() {
this.label(this.furnace.getCommandName(), 8, 6); this.label(this.block.getDisplay(), 8, 6);
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2); this.label("Inventar", 8, this.ySize - 96 + 2);
} }
private int getCookProgressScaled(int pixels) { private int getCookProgressScaled(int pixels) {

View file

@ -1,23 +1,19 @@
package client.gui.container; package client.gui.container;
import client.Client; import client.Client;
import common.init.Blocks;
import common.inventory.ContainerHopper; import common.inventory.ContainerHopper;
import common.inventory.IInventory; import common.inventory.IInventory;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
public class GuiHopper extends GuiContainer { public class GuiHopper extends GuiContainer {
private final IInventory playerInv;
private final IInventory hopper;
public GuiHopper(InventoryPlayer playerInv, IInventory hopper) { public GuiHopper(InventoryPlayer playerInv, IInventory hopper) {
super(new ContainerHopper(playerInv, hopper, Client.CLIENT.player)); super(new ContainerHopper(playerInv, hopper, Client.CLIENT.player));
this.playerInv = playerInv;
this.hopper = hopper;
this.ySize = 133; this.ySize = 133;
} }
public void addElements() { public void addElements() {
this.label(this.hopper.getCommandName(), 8, 6); this.label(Blocks.hopper.getDisplay(), 8, 6);
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2); this.label("Inventar", 8, this.ySize - 96 + 2);
} }
} }

View file

@ -7,6 +7,7 @@ import client.gui.element.ButtonCallback;
import client.gui.element.PressType; import client.gui.element.PressType;
import client.renderer.GlState; import client.renderer.GlState;
import client.renderer.ItemRenderer; import client.renderer.ItemRenderer;
import common.entity.Entity;
import common.inventory.ContainerMerchant; import common.inventory.ContainerMerchant;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
import common.item.ItemStack; import common.item.ItemStack;
@ -22,9 +23,9 @@ public class GuiMerchant extends GuiContainer implements ButtonCallback {
private ActButton prevBtn; private ActButton prevBtn;
private ActButton nextBtn; private ActButton nextBtn;
public GuiMerchant(InventoryPlayer inv, String name, World world) { public GuiMerchant(InventoryPlayer inv, Entity entity, World world) {
super(new ContainerMerchant(inv, null, world)); super(new ContainerMerchant(inv, null, world));
this.title = name != null ? name : "NSC"; this.title = entity.getName();
} }
public void addButtons() { public void addButtons() {

View file

@ -16,7 +16,7 @@ import client.gui.container.GuiEnchant;
import client.gui.container.GuiFurnace; import client.gui.container.GuiFurnace;
import client.gui.container.GuiHopper; import client.gui.container.GuiHopper;
import client.gui.container.GuiEntity; import client.gui.container.GuiEntity;
import client.gui.container.GuiTile; import client.gui.container.GuiDevice;
import client.gui.container.GuiMerchant; import client.gui.container.GuiMerchant;
import client.gui.container.GuiRepair; import client.gui.container.GuiRepair;
import client.gui.ingame.GuiSign; import client.gui.ingame.GuiSign;
@ -26,6 +26,10 @@ import client.util.PlayerController;
import client.world.ChunkClient; import client.world.ChunkClient;
import client.world.WorldClient; import client.world.WorldClient;
import common.block.Block; import common.block.Block;
import common.block.tech.BlockAnvil;
import common.block.tech.BlockChest;
import common.block.tech.BlockDispenser;
import common.block.tech.BlockFurnace;
import common.block.tech.BlockWorkbench; import common.block.tech.BlockWorkbench;
import common.dimension.Dimension; import common.dimension.Dimension;
import common.effect.StatusEffect; import common.effect.StatusEffect;
@ -38,14 +42,14 @@ import common.entity.npc.EntityNPC;
import common.entity.npc.PlayerCharacter; import common.entity.npc.PlayerCharacter;
import common.entity.projectile.EntityProjectile; import common.entity.projectile.EntityProjectile;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.BlockRegistry; import common.init.Blocks;
import common.init.EntityRegistry; import common.init.EntityRegistry;
import common.init.ItemRegistry; import common.init.ItemRegistry;
import common.init.SoundEvent; import common.init.SoundEvent;
import common.inventory.AnimalChest;
import common.inventory.Container; import common.inventory.Container;
import common.inventory.InventoryBasic; import common.inventory.InventoryBasic;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
import common.inventory.InventoryWarpChest;
import common.item.ItemStack; import common.item.ItemStack;
import common.log.Log; import common.log.Log;
import common.network.IClientPlayer; import common.network.IClientPlayer;
@ -121,7 +125,7 @@ import common.packet.SPacketUpdateHealth;
import common.rng.Random; import common.rng.Random;
import common.sound.Sound; import common.sound.Sound;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityDevice; import common.tileentity.Device;
import common.tileentity.TileEntityDisplay; import common.tileentity.TileEntityDisplay;
import common.tileentity.TileEntitySign; import common.tileentity.TileEntitySign;
import common.util.Pair; import common.util.Pair;
@ -1111,79 +1115,68 @@ public class ClientPlayer implements IClientPlayer
this.gm.player.motionZ += (double)packetIn.func_149147_e(); this.gm.player.motionZ += (double)packetIn.func_149147_e();
} }
/**
* Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
* Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
*/
public void handleOpenWindow(SPacketOpenWindow packet) public void handleOpenWindow(SPacketOpenWindow packet)
{ {
NetHandler.checkThread(packet, this, this.gm, this.world); NetHandler.checkThread(packet, this, this.gm, this.world);
EntityNPC player = this.gm.player; EntityNPC player = this.gm.player;
String id = packet.getGuiId(); Block block = packet.getGuiId();
String title = packet.getWindowTitle();
int slots = packet.getSlotCount(); int slots = packet.getSlotCount();
LocalContainer local = new LocalContainer(title, slots);
if ("container".equals(id)) if(packet.getTilePos() != null)
{ {
this.gm.show(new GuiChest(player.inventory, new InventoryBasic(title, slots))); TileEntity tile = this.world.getTileEntity(packet.getTilePos());
if(!(tile instanceof Device dev))
return;
this.gm.show(new GuiDevice(this.gm.player.inventory, new LocalContainer(slots), dev));
} }
else if ("enchanting_table".equals(id)) else if (packet.getEntityId() != -1)
{
this.gm.show(new GuiEnchant(player.inventory, player.worldObj, title));
}
else if ("anvil".equals(id))
{
this.gm.show(new GuiRepair(player.inventory, player.worldObj));
}
else if ("chest".equals(id))
{
this.gm.show(new GuiChest(player.inventory, local));
}
else if ("hopper".equals(id))
{
this.gm.show(new GuiHopper(player.inventory, local));
}
else if ("furnace".equals(id))
{
this.gm.show(new GuiFurnace(player.inventory, local));
}
else if ("brewing_stand".equals(id))
{
this.gm.show(new GuiBrewing(player.inventory, local));
}
else if ("dispenser".equals(id) || "dropper".equals(id))
{
this.gm.show(new GuiDispenser(player.inventory, local));
}
else if ("trade".equals(id))
{
this.gm.show(new GuiMerchant(player.inventory, title, player.worldObj));
}
else if ("entity".equals(id))
{ {
Entity entity = this.world.getEntityByID(packet.getEntityId()); Entity entity = this.world.getEntityByID(packet.getEntityId());
if(entity == null) if(entity == null)
return; return;
this.gm.show(new GuiEntity(player.inventory, new AnimalChest(title, true, slots), entity)); if(entity instanceof EntityNPC)
this.gm.show(new GuiMerchant(player.inventory, entity, player.worldObj));
else
this.gm.show(new GuiEntity(player.inventory, new InventoryBasic(slots), entity));
} }
else if ("tile".equals(id)) else if (block == Blocks.warp_chest)
{ {
TileEntity tile = this.world.getTileEntity(packet.getTilePos()); this.gm.show(new GuiChest(player.inventory, new InventoryWarpChest(), block));
if(!(tile instanceof TileEntityDevice dev))
return;
this.gm.show(new GuiTile(this.gm.player.inventory, local, dev));
} }
else else if (block == Blocks.enchanting_table)
{ {
Block block = BlockRegistry.byName(id); this.gm.show(new GuiEnchant(player.inventory, player.worldObj));
if(block instanceof BlockWorkbench bench) {
this.gm.show(new GuiCrafting(player.inventory, player.worldObj, bench));
}
else {
this.gm.show(new GuiChest(player.inventory, local));
}
} }
else if (block instanceof BlockAnvil)
{
this.gm.show(new GuiRepair(player.inventory, player.worldObj));
}
else if (block instanceof BlockChest)
{
this.gm.show(new GuiChest(player.inventory, new InventoryBasic(slots), block));
}
else if (block == Blocks.hopper)
{
this.gm.show(new GuiHopper(player.inventory, new InventoryBasic(slots)));
}
else if (block instanceof BlockFurnace furnace)
{
this.gm.show(new GuiFurnace(player.inventory, new LocalContainer(slots), furnace));
}
else if (block == Blocks.brewing_stand)
{
this.gm.show(new GuiBrewing(player.inventory, new LocalContainer(slots)));
}
else if (block instanceof BlockDispenser dispenser)
{
this.gm.show(new GuiDispenser(player.inventory, new InventoryBasic(slots), dispenser));
}
else if(block instanceof BlockWorkbench bench) {
this.gm.show(new GuiCrafting(player.inventory, player.worldObj, bench));
}
else {
return;
}
player.openContainer.windowId = packet.getWindowId(); player.openContainer.windowId = packet.getWindowId();
} }
@ -1339,25 +1332,14 @@ public class ClientPlayer implements IClientPlayer
} }
} }
/** public void handleUpdateDevice(SPacketUpdateDevice packet) {
* Updates the metadata of instances of the following entitytypes: Mob spawners, command blocks, NetHandler.checkThread(packet, this, this.gm, this.world);
* beacons, skulls, flowerpot if(this.gm.world.isBlockLoaded(packet.getPos())) {
*/ TileEntity te = this.gm.world.getTileEntity(packet.getPos());
public void handleUpdateTileEntity(SPacketUpdateDevice packetIn) if(te != null && packet.getType() == te.getBlockType())
{ te.readTags(packet.getTag());
NetHandler.checkThread(packetIn, this, this.gm, this.world); }
}
if (this.gm.world.isBlockLoaded(packetIn.getPos()))
{
TileEntity tileentity = this.gm.world.getTileEntity(packetIn.getPos());
// int i = packetIn.getTileEntityType();
if (tileentity != null && packetIn.isTileEntityType(tileentity)) // i == 1 && tileentity instanceof TileEntityMobSpawner || /* i == 2 && tileentity instanceof TileEntityCommandBlock || */ i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || /* i == 5 && tileentity instanceof TileEntityFlowerPot || */ i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityMachine)
{
tileentity.readTags(packetIn.getTags());
}
}
}
/** /**
* Sets the progressbar of the opened window to the specified value * Sets the progressbar of the opened window to the specified value

View file

@ -3,18 +3,14 @@ package client.network;
import java.util.Map; import java.util.Map;
import common.collect.Maps; import common.collect.Maps;
import common.entity.npc.EntityNPC; import common.inventory.IInventory;
import common.inventory.Container;
import common.inventory.InventoryBasic; import common.inventory.InventoryBasic;
import common.inventory.InventoryPlayer;
import common.tileentity.ILockableContainer;
import common.tileentity.Passcode;
public class LocalContainer extends InventoryBasic implements ILockableContainer { public class LocalContainer extends InventoryBasic implements IInventory {
private Map<Integer, Integer> fields = Maps.<Integer, Integer>newHashMap(); private Map<Integer, Integer> fields = Maps.<Integer, Integer>newHashMap();
public LocalContainer(String title, int slotCount) { public LocalContainer(int slotCount) {
super(title, slotCount); super(slotCount);
} }
public int getField(int id) { public int getField(int id) {
@ -28,23 +24,4 @@ public class LocalContainer extends InventoryBasic implements ILockableContainer
public int getFieldCount() { public int getFieldCount() {
return this.fields.size(); return this.fields.size();
} }
public boolean isLocked() {
return false;
}
public void setLockCode(Passcode code) {
}
public Passcode getLockCode() {
return Passcode.EMPTY_CODE;
}
public String getGuiID() {
return null;
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn) {
throw new UnsupportedOperationException();
}
} }

View file

@ -43,7 +43,6 @@ import common.model.BlockLayer;
import common.rng.Random; import common.rng.Random;
import common.sound.Sound; import common.sound.Sound;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.BoundingBox; import common.util.BoundingBox;
import common.util.InheritanceMultiMap; import common.util.InheritanceMultiMap;
@ -686,23 +685,6 @@ public class RenderGlobal
{ {
BlockPos blockpos = destroyblockprogress.getPosition(); BlockPos blockpos = destroyblockprogress.getPosition();
TileEntity tileentity1 = this.theWorld.getTileEntity(blockpos); TileEntity tileentity1 = this.theWorld.getTileEntity(blockpos);
if (tileentity1 instanceof TileEntityChest)
{
TileEntityChest tileentitychest = (TileEntityChest)tileentity1;
if (tileentitychest.adjacentChestXNeg != null)
{
blockpos = blockpos.offset(Facing.WEST);
tileentity1 = this.theWorld.getTileEntity(blockpos);
}
else if (tileentitychest.adjacentChestZNeg != null)
{
blockpos = blockpos.offset(Facing.NORTH);
tileentity1 = this.theWorld.getTileEntity(blockpos);
}
}
Block block = this.theWorld.getState(blockpos).getBlock(); Block block = this.theWorld.getState(blockpos).getBlock();
if (tileentity1 != null && (block instanceof BlockChest || block instanceof BlockSign)) if (tileentity1 != null && (block instanceof BlockChest || block instanceof BlockSign))

View file

@ -1,23 +0,0 @@
package client.renderer.model;
public class ModelLargeChest extends ModelChest
{
public ModelLargeChest()
{
this.chestLid = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64);
this.chestLid.addBox(0.0F, -5.0F, -14.0F, 30, 5, 14, 0.0F);
this.chestLid.rotationPointX = 1.0F;
this.chestLid.rotationPointY = 7.0F;
this.chestLid.rotationPointZ = 15.0F;
this.chestKnob = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64);
this.chestKnob.addBox(-1.0F, -2.0F, -15.0F, 2, 4, 1, 0.0F);
this.chestKnob.rotationPointX = 16.0F;
this.chestKnob.rotationPointY = 7.0F;
this.chestKnob.rotationPointZ = 15.0F;
this.chestBelow = (new ModelRenderer(this, 0, 19)).setTextureSize(128, 64);
this.chestBelow.addBox(0.0F, 0.0F, 0.0F, 30, 10, 14, 0.0F);
this.chestBelow.rotationPointX = 1.0F;
this.chestBelow.rotationPointY = 6.0F;
this.chestBelow.rotationPointZ = 1.0F;
}
}

View file

@ -4,40 +4,16 @@ import org.lwjgl.opengl.GL11;
import client.renderer.GlState; import client.renderer.GlState;
import client.renderer.model.ModelChest; import client.renderer.model.ModelChest;
import client.renderer.model.ModelLargeChest;
import common.block.tech.BlockChest; import common.block.tech.BlockChest;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.tileentity.TileEntityChest; import common.tileentity.TileEntityChest;
import common.world.State; import common.world.State;
public class TileEntityChestRenderer extends TileEntitySpecialRenderer<TileEntityChest> public class TileEntityChestRenderer extends TileEntitySpecialRenderer<TileEntityChest>
{ {
private static final String textureTrappedDouble = "textures/blocks/chest_trapped_double.png"; private final ModelChest model = new ModelChest();
// private static final ResourceLocation textureChristmasDouble = new ResourceLocation("textures/tile/chest_christmas_double.png");
private static final String textureNormalDouble = "textures/blocks/chest_normal_double.png";
private static final String textureTrapped = "textures/blocks/chest_trapped.png";
// private static final ResourceLocation textureChristmas = new ResourceLocation("textures/tile/chest_christmas.png");
private static final String textureNormal = "textures/blocks/chest_normal.png";
private ModelChest simpleChest = new ModelChest();
private ModelChest largeChest = new ModelLargeChest();
// private boolean isChristmas;
// public TileEntityChestRenderer()
// {
// this.setChristmas(true);
// }
// public void setChristmas(boolean xmas) {
// if(!xmas) {
// this.isChristmas = false;
// }
// else {
// Calendar calendar = Calendar.getInstance();
// if(calendar.get(2) + 1 == 12 && calendar.get(5) >= 24 && calendar.get(5) <= 26)
// this.isChristmas = true;
// }
// }
public void renderTileEntityAt(TileEntityChest te, double x, double y, double z, float partialTicks, int destroyStage) public void renderTileEntityAt(TileEntityChest te, double x, double y, double z, float partialTicks, int destroyStage)
{ {
@ -45,161 +21,81 @@ public class TileEntityChestRenderer extends TileEntitySpecialRenderer<TileEntit
GlState.depthFunc(GL11.GL_LEQUAL); GlState.depthFunc(GL11.GL_LEQUAL);
GlState.depthMask(true); GlState.depthMask(true);
int i = 0; int i = 0;
BlockChest block = Blocks.chest;
if (te.hasWorldObj()) if (te.hasWorldObj())
{ {
State state = te.getBlockState(); State state = te.getBlockState();
if(state.getBlock() instanceof BlockChest) { if(state.getBlock() instanceof BlockChest chest) {
i = state.getValue(BlockChest.FACING).getIndex(); i = state.getValue(BlockChest.FACING).getIndex();
block = chest;
if (i == 0)
{
((BlockChest)state.getBlock()).checkForSurroundingChests(te.getWorld(), te.getPos(), te.getWorld().getState(te.getPos()));
i = state.getValue(BlockChest.FACING).getIndex();
}
} }
te.checkForAdjacentChests();
} }
if (te.adjacentChestZNeg == null && te.adjacentChestXNeg == null) if (destroyStage >= 0)
{ {
ModelChest modelchest; this.bindTexture(DESTROY_STAGES[destroyStage]);
GL11.glMatrixMode(GL11.GL_TEXTURE);
if (te.adjacentChestXPos == null && te.adjacentChestZPos == null)
{
modelchest = this.simpleChest;
if (destroyStage >= 0)
{
this.bindTexture(DESTROY_STAGES[destroyStage]);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
GL11.glScalef(4.0F, 4.0F, 1.0F);
GL11.glTranslatef(0.0625F, 0.0625F, 0.0625F);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
// else if (this.isChristmas)
// {
// this.bindTexture(textureChristmas);
// }
else if (te.getChestType() == 1)
{
this.bindTexture(textureTrapped);
}
else
{
this.bindTexture(textureNormal);
}
}
else
{
modelchest = this.largeChest;
if (destroyStage >= 0)
{
this.bindTexture(DESTROY_STAGES[destroyStage]);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
GL11.glScalef(8.0F, 4.0F, 1.0F);
GL11.glTranslatef(0.0625F, 0.0625F, 0.0625F);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
// else if (this.isChristmas)
// {
// this.bindTexture(textureChristmasDouble);
// }
else if (te.getChestType() == 1)
{
this.bindTexture(textureTrappedDouble);
}
else
{
this.bindTexture(textureNormalDouble);
}
}
GL11.glPushMatrix(); GL11.glPushMatrix();
GlState.enableRescaleNormal(); GL11.glScalef(4.0F, 4.0F, 1.0F);
GL11.glTranslatef(0.0625F, 0.0625F, 0.0625F);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
else
{
this.bindTexture("textures/blocks/" + BlockRegistry.getName(block) + ".png");
}
if (destroyStage < 0) GL11.glPushMatrix();
{ GlState.enableRescaleNormal();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
}
GL11.glTranslatef((float)x, (float)y + 1.0F, (float)z + 1.0F); if (destroyStage < 0)
GL11.glScalef(1.0F, -1.0F, -1.0F); {
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
int j = 0;
if (i == 2)
{
j = 180;
}
if (i == 3)
{
j = 0;
}
if (i == 4)
{
j = 90;
}
if (i == 5)
{
j = -90;
}
if (i == 2 && te.adjacentChestXPos != null)
{
GL11.glTranslatef(1.0F, 0.0F, 0.0F);
}
if (i == 5 && te.adjacentChestZPos != null)
{
GL11.glTranslatef(0.0F, 0.0F, -1.0F);
}
GL11.glRotatef((float)j, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
if (te.adjacentChestZNeg != null)
{
float f1 = te.adjacentChestZNeg.prevLidAngle + (te.adjacentChestZNeg.lidAngle - te.adjacentChestZNeg.prevLidAngle) * partialTicks;
if (f1 > f)
{
f = f1;
}
}
if (te.adjacentChestXNeg != null)
{
float f2 = te.adjacentChestXNeg.prevLidAngle + (te.adjacentChestXNeg.lidAngle - te.adjacentChestXNeg.prevLidAngle) * partialTicks;
if (f2 > f)
{
f = f2;
}
}
f = 1.0F - f;
f = 1.0F - f * f * f;
modelchest.chestLid.rotateAngleX = -(f * (float)Math.PI / 2.0F);
modelchest.renderAll();
GlState.disableRescaleNormal();
GL11.glPopMatrix();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F); GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
}
if (destroyStage >= 0) GL11.glTranslatef((float)x, (float)y + 1.0F, (float)z + 1.0F);
{ GL11.glScalef(1.0F, -1.0F, -1.0F);
GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GL11.glPopMatrix(); int j = 0;
GL11.glMatrixMode(GL11.GL_MODELVIEW);
} if (i == 2)
{
j = 180;
}
if (i == 3)
{
j = 0;
}
if (i == 4)
{
j = 90;
}
if (i == 5)
{
j = -90;
}
GL11.glRotatef((float)j, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
f = 1.0F - f;
f = 1.0F - f * f * f;
this.model.chestLid.rotateAngleX = -(f * (float)Math.PI / 2.0F);
this.model.renderAll();
GlState.disableRescaleNormal();
GL11.glPopMatrix();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
if (destroyStage >= 0)
{
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
} }
} }
} }

View file

@ -1,20 +1,30 @@
package client.renderer.tileentity; package client.renderer.tileentity;
import common.init.Items; import common.block.tech.BlockChest;
import common.item.ItemStack; import common.item.ItemStack;
import common.item.block.ItemChest;
import common.tileentity.TileEntityChest; import common.tileentity.TileEntityChest;
import common.util.Facing;
import common.world.State;
public class TileEntityItemStackRenderer { public class TileEntityItemStackRenderer {
public static TileEntityItemStackRenderer instance = new TileEntityItemStackRenderer(); public static TileEntityItemStackRenderer instance = new TileEntityItemStackRenderer();
private State state;
private final TileEntityChest chest = new TileEntityChest(0); private final TileEntityChest chest = new TileEntityChest(0) {
private final TileEntityChest trapChest = new TileEntityChest(1); public boolean hasWorldObj() {
return true;
}
public State getBlockState() {
return TileEntityItemStackRenderer.this.state;
}
};
public void renderByItem(ItemStack stack) { public void renderByItem(ItemStack stack) {
if(stack.getItem() == Items.trapped_chest) { if(stack.getItem() instanceof ItemChest chest) {
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.trapChest, 0.0D, 0.0D, 0.0D, 0.0F); this.state = chest.getBlock().getState().withProperty(BlockChest.FACING, Facing.SOUTH);
}
else if(stack.getItem() == Items.chest) {
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chest, 0.0D, 0.0D, 0.0D, 0.0F); TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chest, 0.0D, 0.0D, 0.0D, 0.0F);
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 B

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 B

After

Width:  |  Height:  |  Size: 4.9 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -11,6 +11,7 @@ import common.block.Block;
import common.block.artificial.BlockFence; import common.block.artificial.BlockFence;
import common.block.artificial.BlockFenceGate; import common.block.artificial.BlockFenceGate;
import common.block.artificial.BlockWall; import common.block.artificial.BlockWall;
import common.block.tech.InteractionObject;
import common.collect.Lists; import common.collect.Lists;
import common.color.TextColor; import common.color.TextColor;
import common.dimension.Dimension; import common.dimension.Dimension;
@ -37,7 +38,9 @@ import common.inventory.ContainerChest;
import common.inventory.ContainerEnchantment; import common.inventory.ContainerEnchantment;
import common.inventory.ContainerEntityInventory; import common.inventory.ContainerEntityInventory;
import common.inventory.ContainerMerchant; import common.inventory.ContainerMerchant;
import common.inventory.ContainerTile;
import common.inventory.IInventory; import common.inventory.IInventory;
import common.inventory.InventoryBasic;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
import common.inventory.Slot; import common.inventory.Slot;
import common.inventory.SlotCrafting; import common.inventory.SlotCrafting;
@ -99,10 +102,10 @@ import common.packet.SPacketUpdateHealth;
import common.packet.CPacketAction.Action; import common.packet.CPacketAction.Action;
import common.packet.SPacketMessage.Type; import common.packet.SPacketMessage.Type;
import common.tags.TagObject; import common.tags.TagObject;
import common.tileentity.IInteractionObject;
import common.tileentity.ILockableContainer;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityDevice; import common.tileentity.TileEntityChest;
import common.tileentity.TileEntityInventory;
import common.tileentity.Device;
import common.tileentity.TileEntitySign; import common.tileentity.TileEntitySign;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.BlockPos.MutableBlockPos; import common.util.BlockPos.MutableBlockPos;
@ -394,35 +397,16 @@ public class Player extends User implements Executor, IPlayer
this.entity.updateEntityFall(p_71122_1_, p_71122_3_, block, blockpos); this.entity.updateEntityFall(p_71122_1_, p_71122_3_, block, blockpos);
} }
private void getNextWindowId() private int getNextWindowId()
{ {
this.currentWindowId = this.currentWindowId % 100 + 1; this.currentWindowId = this.currentWindowId % 100 + 1;
return this.currentWindowId;
} }
private void getNextFormId() private void getNextFormId()
{ {
this.currentFormId = this.currentFormId % 100 + 1; this.currentFormId = this.currentFormId % 100 + 1;
} }
public void displayTradeGui(EntityNPC npc)
{
this.getNextWindowId();
this.entity.openContainer = new ContainerMerchant(this.entity.inventory, npc, this.entity.worldObj);
this.entity.openContainer.windowId = this.currentWindowId;
this.entity.openContainer.onCraftGuiOpened(this);
IInventory iinventory = ((ContainerMerchant)this.entity.openContainer).getMerchantInventory();
String ichatcomponent = npc.getName();
this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "trade", ichatcomponent, iinventory.getSizeInventory()));
MerchantRecipeList merchantrecipelist = npc.getTrades(this.entity);
if (merchantrecipelist != null)
{
// PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
// packetbuffer.writeInt(this.currentWindowId);
// merchantrecipelist.writeToBuf(packetbuffer);
this.sendPacket(new SPacketTrades(merchantrecipelist, this.currentWindowId));
}
}
public void updateHeldItem() public void updateHeldItem()
{ {
@ -431,12 +415,6 @@ public class Player extends User implements Executor, IPlayer
this.sendPacket(new SPacketSetSlot(-1, -1, this.entity.inventory.getItemStack())); this.sendPacket(new SPacketSetSlot(-1, -1, this.entity.inventory.getItemStack()));
} }
} }
public void closeContainer()
{
this.entity.openContainer.onContainerClosed(this.entity);
this.entity.openContainer = this.entity.inventoryContainer;
}
public void setEntityActionState(float p_110430_1_, float p_110430_2_, boolean p_110430_3_, boolean sneaking) public void setEntityActionState(float p_110430_1_, float p_110430_2_, boolean p_110430_3_, boolean sneaking)
{ {
@ -668,92 +646,71 @@ public class Player extends User implements Executor, IPlayer
this.sendPacket(new SPacketEntityAttach(0, this.entity, this.entity.vehicle)); this.sendPacket(new SPacketEntityAttach(0, this.entity, this.entity.vehicle));
this.setPlayerLocation(this.entity.posX, this.entity.posY, this.entity.posZ, this.entity.rotYaw, this.entity.rotPitch); this.setPlayerLocation(this.entity.posX, this.entity.posY, this.entity.posZ, this.entity.rotYaw, this.entity.rotPitch);
} }
public void openEditSign(TileEntitySign signTile)
{
signTile.setPlayer(this.entity);
this.sendPacket(new SPacketSignEditorOpen(signTile.getPos()));
}
public void displayGui(IInteractionObject guiOwner)
{
this.getNextWindowId();
this.sendPacket(new SPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getCommandName()));
this.entity.openContainer = guiOwner.createContainer(this.entity.inventory, this.entity);
this.entity.openContainer.windowId = this.currentWindowId;
this.entity.openContainer.onCraftGuiOpened(this);
}
public void displayGUIChest(IInventory chestInventory) public void show(Object object)
{ {
if (this.entity.openContainer != this.entity.inventoryContainer) if(object == null || this.entity.openContainer != this.entity.inventoryContainer) {
{ this.sendPacket(new SPacketCloseWindow(this.entity.openContainer.windowId));
this.closeScreen(); this.entity.openContainer.onContainerClosed(this.entity);
this.entity.openContainer = this.entity.inventoryContainer;
if(object == null)
return;
}
if(object instanceof TileEntitySign sign) {
sign.setPlayer(this.entity);
this.sendPacket(new SPacketSignEditorOpen(sign.getPos()));
return;
} }
else if(object instanceof EntityNPC npc) {
if (chestInventory instanceof ILockableContainer) this.getNextWindowId();
this.entity.openContainer = new ContainerMerchant(this.entity.inventory, npc, this.entity.worldObj);
}
else if(object instanceof Entity entity) {
InventoryBasic inv = entity.getEntityInventory();
this.sendPacket(new SPacketOpenWindow(this.getNextWindowId(), entity.getId(), entity.getName(), inv.getSizeInventory()));
this.entity.openContainer = new ContainerEntityInventory(this.entity.inventory, inv, entity, this.entity);
}
else if (object instanceof Device device)
{ {
ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory; this.sendPacket(new SPacketOpenWindow(this.getNextWindowId(), device.getPos(), device.getBlockType().getDisplay(), device.getSizeInventory()));
this.entity.openContainer = new ContainerTile(this.entity.inventory, device, device, this.entity);
if (ilockablecontainer.isLocked() && !this.entity.canOpen(ilockablecontainer.getLockCode())) // && !this.isSpectator()) }
else if (object instanceof TileEntityChest chest)
{
if (chest.getLockCode() != null && !this.entity.canOpen(chest.getLockCode()))
{ {
this.addHotbar(TextColor.RED + "%s ist verschlossen!", chestInventory.getCommandName()); this.addHotbar(TextColor.RED + "%s ist verschlossen!", chest.getName());
this.sendPacket(new SPacketSoundEffect(SoundEvent.DOOR, this.entity.posX, this.entity.posY, this.entity.posZ, 1.0F)); this.sendPacket(new SPacketSoundEffect(SoundEvent.DOOR, this.entity.posX, this.entity.posY, this.entity.posZ, 1.0F));
return; return;
} }
this.sendPacket(new SPacketOpenWindow(this.getNextWindowId(), chest.getBlockType(), chest.getName(), chest.getSizeInventory()));
this.entity.openContainer = new ContainerChest(this.entity.inventory, chest, this.entity);
} }
else if (object instanceof TileEntityInventory tile)
this.getNextWindowId();
if (chestInventory instanceof TileEntityDevice)
{ {
this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "tile", chestInventory.getCommandName(), chestInventory.getSizeInventory(), this.sendPacket(new SPacketOpenWindow(this.getNextWindowId(), tile.getBlockType(), tile.getBlockType().getDisplay(), tile.getSizeInventory()));
((TileEntityDevice)chestInventory).getPos())); this.entity.openContainer = tile.createContainer(this.entity.inventory, this.entity);
this.entity.openContainer = ((IInteractionObject)chestInventory).createContainer(this.entity.inventory, this.entity);
} }
else if (chestInventory instanceof IInteractionObject) else if (object instanceof InteractionObject obj)
{ {
this.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getCommandName(), chestInventory.getSizeInventory())); this.sendPacket(new SPacketOpenWindow(this.getNextWindowId(), obj.getBlock(), obj.getBlock().getDisplay(), 0));
this.entity.openContainer = ((IInteractionObject)chestInventory).createContainer(this.entity.inventory, this.entity); this.entity.openContainer = obj.createContainer(this.entity.inventory, this.entity);
} }
else else {
{ return;
this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "container", chestInventory.getCommandName(), chestInventory.getSizeInventory()));
this.entity.openContainer = new ContainerChest(this.entity.inventory, chestInventory, this.entity);
} }
this.entity.openContainer.windowId = this.currentWindowId; this.entity.openContainer.windowId = this.currentWindowId;
this.entity.openContainer.onCraftGuiOpened(this); this.entity.openContainer.onCraftGuiOpened(this);
}
if(object instanceof EntityNPC npc) {
public void displayEntityGui(Entity entity, IInventory inventory) IInventory merchant = ((ContainerMerchant)this.entity.openContainer).getMerchantInventory();
{ this.sendPacket(new SPacketOpenWindow(this.currentWindowId, npc.getId(), npc.getName(), merchant.getSizeInventory()));
if (this.entity.openContainer != this.entity.inventoryContainer) MerchantRecipeList trades = npc.getTrades(this.entity);
{ if(trades != null)
this.closeScreen(); this.sendPacket(new SPacketTrades(trades, this.currentWindowId));
} }
this.getNextWindowId();
this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "entity", inventory.getCommandName(), inventory.getSizeInventory(), entity.getId()));
this.entity.openContainer = new ContainerEntityInventory(this.entity.inventory, inventory, entity, this.entity);
this.entity.openContainer.windowId = this.currentWindowId;
this.entity.openContainer.onCraftGuiOpened(this);
}
// public void displayGUIBook(ItemStack bookStack)
// {
// Item item = bookStack.getItem();
//
// if (item == Items.writable_book)
// {
// this.sendPacket(new SPacketBook());
// }
// }
public void closeScreen()
{
this.sendPacket(new SPacketCloseWindow(this.entity.openContainer.windowId));
this.closeContainer();
} }
// public void addStat(int amount) // public void addStat(int amount)
@ -980,8 +937,7 @@ public class Player extends User implements Executor, IPlayer
if (/* !this.worldObj.client && */ !this.entity.openContainer.canInteractWith(this.entity)) if (/* !this.worldObj.client && */ !this.entity.openContainer.canInteractWith(this.entity))
{ {
this.closeScreen(); this.show(null);
this.entity.openContainer = this.entity.inventoryContainer;
} }
while (!this.destroyedItemsNetCache.isEmpty()) while (!this.destroyedItemsNetCache.isEmpty())
@ -2599,32 +2555,6 @@ public class Player extends User implements Executor, IPlayer
} }
break; break;
// case SET_BEACON:
// if (this.entity.openContainer instanceof ContainerBeacon)
// {
// try
// {
// int k = packetIn.getAuxData() & 255;
// int l = packetIn.getAuxData() >> 8;
// ContainerBeacon containerbeacon = (ContainerBeacon)this.entity.openContainer;
// Slot slot = containerbeacon.getSlot(0);
//
// if (slot.getHasStack())
// {
// slot.decrStackSize(1);
// IInventory iinventory = containerbeacon.func_180611_e();
// iinventory.setField(1, k);
// iinventory.setField(2, l);
// iinventory.markDirty();
// }
// }
// catch (Exception exception)
// {
// SKC.error((String)"Konnte Leuchtfeuer nicht ändern", (Throwable)exception);
// }
// }
// break;
case SWING_ARM: case SWING_ARM:
this.entity.swingItem(); this.entity.swingItem();
// if(packetIn.getAuxData() != 0) // if(packetIn.getAuxData() != 0)
@ -2650,8 +2580,10 @@ public class Player extends User implements Executor, IPlayer
break; break;
case CLOSE_CONTAINER: case CLOSE_CONTAINER:
if(this.entity.openContainer.windowId == packetIn.getAuxData()) if(this.entity.openContainer.windowId == packetIn.getAuxData()) {
this.closeContainer(); this.entity.openContainer.onContainerClosed(this.entity);
this.entity.openContainer = this.entity.inventoryContainer;
}
break; break;
case CONFIRM_TRANSACTION: case CONFIRM_TRANSACTION:

View file

@ -112,13 +112,12 @@ import common.log.Log;
import common.rng.Random; import common.rng.Random;
import common.tags.TagObject; import common.tags.TagObject;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityBeacon; import common.tileentity.DeviceEffectGenerator;
import common.tileentity.TileEntityChest; import common.tileentity.TileEntityChest;
import common.tileentity.TileEntityComparator; import common.tileentity.TileEntityComparator;
import common.tileentity.TileEntityDaylightDetector; import common.tileentity.TileEntityDaylightDetector;
import common.tileentity.TileEntityDispenser; import common.tileentity.TileEntityDispenser;
import common.tileentity.TileEntityDropper; import common.tileentity.TileEntityDropper;
import common.tileentity.TileEntityEnchantmentTable;
import common.tileentity.TileEntityFurnace; import common.tileentity.TileEntityFurnace;
import common.tileentity.TileEntityHopper; import common.tileentity.TileEntityHopper;
import common.tileentity.TileEntitySign; import common.tileentity.TileEntitySign;
@ -374,8 +373,7 @@ public abstract class Converter {
mapTile(TileEntityDropper.class, "Dropper", "dropper"); mapTile(TileEntityDropper.class, "Dropper", "dropper");
mapTile(TileEntitySign.class, "Sign", "sign"); mapTile(TileEntitySign.class, "Sign", "sign");
// mapTile(TileEntityPiston.class, "Piston", "piston"); // mapTile(TileEntityPiston.class, "Piston", "piston");
mapTile(TileEntityEnchantmentTable.class, "EnchantTable", "enchanting_table"); mapTile(DeviceEffectGenerator.class, "Beacon", "beacon");
mapTile(TileEntityBeacon.class, "Beacon", "beacon");
mapTile(TileEntityDaylightDetector.class, "DLDetector", "daylight_detector"); mapTile(TileEntityDaylightDetector.class, "DLDetector", "daylight_detector");
mapTile(TileEntityHopper.class, "Hopper", "hopper"); mapTile(TileEntityHopper.class, "Hopper", "hopper");
mapTile(TileEntityComparator.class, "Comparator", "comparator"); mapTile(TileEntityComparator.class, "Comparator", "comparator");
@ -1174,7 +1172,7 @@ public abstract class Converter {
mapBlock(Blocks.spruce_stairs.getState().withProperty(BlockStairs.FACING, Facing.SOUTH).withProperty(BlockStairs.HALF, EnumHalf.TOP), 136, 6, 14); mapBlock(Blocks.spruce_stairs.getState().withProperty(BlockStairs.FACING, Facing.SOUTH).withProperty(BlockStairs.HALF, EnumHalf.TOP), 136, 6, 14);
mapBlock(Blocks.spruce_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH).withProperty(BlockStairs.HALF, EnumHalf.TOP), 136, 7, 15); mapBlock(Blocks.spruce_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH).withProperty(BlockStairs.HALF, EnumHalf.TOP), 136, 7, 15);
mapBlock(Blocks.obsidian, 137); mapBlock(Blocks.obsidian, 137);
mapBlock(Blocks.beacon, 138); mapBlock(Blocks.effect_generator, 138);
mapBlock(Blocks.cobblestone_wall, 139); mapBlock(Blocks.cobblestone_wall, 139);
mapBlock(Blocks.mossy_cobblestone_wall, 139, 1); mapBlock(Blocks.mossy_cobblestone_wall, 139, 1);
mapBlock(Blocks.flowerpot, 140); mapBlock(Blocks.flowerpot, 140);
@ -1214,10 +1212,10 @@ 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.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.NORTH), 145, 2, 6, 10, 14);
mapBlock(Blocks.anvil.getState().withProperty(BlockAnvil.FACING, Facing.EAST), 145, 3, 7, 11, 15); mapBlock(Blocks.anvil.getState().withProperty(BlockAnvil.FACING, Facing.EAST), 145, 3, 7, 11, 15);
mapBlock(Blocks.trapped_chest.getState().withProperty(BlockChest.FACING, Facing.NORTH), 146); mapBlock(Blocks.chest.getState().withProperty(BlockChest.FACING, Facing.NORTH), 146);
mapBlock(Blocks.trapped_chest.getState().withProperty(BlockChest.FACING, Facing.SOUTH), 146, 3, 9, 15); mapBlock(Blocks.chest.getState().withProperty(BlockChest.FACING, Facing.SOUTH), 146, 3, 9, 15);
mapBlock(Blocks.trapped_chest.getState().withProperty(BlockChest.FACING, Facing.WEST), 146, 4, 10); mapBlock(Blocks.chest.getState().withProperty(BlockChest.FACING, Facing.WEST), 146, 4, 10);
mapBlock(Blocks.trapped_chest.getState().withProperty(BlockChest.FACING, Facing.EAST), 146, 5, 11); mapBlock(Blocks.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, 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, 1), 147, 1);
mapBlock(Blocks.light_weighted_pressure_plate.getState().withProperty(BlockPressurePlateWeighted.POWER, 2), 147, 2); mapBlock(Blocks.light_weighted_pressure_plate.getState().withProperty(BlockPressurePlateWeighted.POWER, 2), 147, 2);

View file

@ -2,6 +2,7 @@ package server.worldgen.feature;
import common.block.Block; import common.block.Block;
import common.block.Material; import common.block.Material;
import common.block.tech.BlockChest;
import common.init.Blocks; import common.init.Blocks;
import common.item.RngLoot; import common.item.RngLoot;
import common.rng.Random; import common.rng.Random;
@ -9,6 +10,7 @@ import common.rng.WeightedList;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest; import common.tileentity.TileEntityChest;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.Facing;
import server.world.WorldServer; import server.world.WorldServer;
import server.worldgen.FeatureGenerator; import server.worldgen.FeatureGenerator;
import server.worldgen.LootConstants; import server.worldgen.LootConstants;
@ -49,10 +51,10 @@ public class WorldGenAbandonedChest extends FeatureGenerator
BlockPos blockpos = position.add(rand.zrange(4) - rand.zrange(4), rand.zrange(3) - rand.zrange(3), rand.zrange(4) - rand.zrange(4)); BlockPos blockpos = position.add(rand.zrange(4) - rand.zrange(4), rand.zrange(3) - rand.zrange(3), rand.zrange(4) - rand.zrange(4));
if (worldIn.isAirBlock(blockpos) && worldIn.isBlockSolid(blockpos.down())) if (worldIn.isAirBlock(blockpos) && worldIn.isBlockSolid(blockpos.down()))
{ {
worldIn.setState(blockpos, Blocks.chest.getState(), 2); worldIn.setState(blockpos, Blocks.chest.getState().withProperty(BlockChest.FACING, Facing.randHorizontal(rand)), 2);
TileEntity tileentity = worldIn.getTileEntity(blockpos); TileEntity tileentity = worldIn.getTileEntity(blockpos);
if(tileentity instanceof TileEntityChest) if(tileentity instanceof TileEntityChest chest)
RngLoot.generateChestContents(rand, this.items, (TileEntityChest)tileentity, this.amount); RngLoot.generateChestContents(rand, this.items, chest, this.amount);
return true; return true;
} }
} }

View file

@ -3,10 +3,10 @@ package server.worldgen.structure;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import common.block.tech.BlockChest;
import common.block.tech.BlockRail; import common.block.tech.BlockRail;
import common.block.tech.BlockRailBase; import common.block.tech.BlockRailBase;
import common.block.tech.BlockTorch; import common.block.tech.BlockTorch;
import common.entity.item.EntityChestCart;
import common.entity.npc.EntityArachnoid; import common.entity.npc.EntityArachnoid;
import common.init.Blocks; import common.init.Blocks;
import common.item.RngLoot; import common.item.RngLoot;
@ -14,6 +14,8 @@ import common.item.material.ItemEnchantedBook;
import common.rng.Random; import common.rng.Random;
import common.rng.WeightedList; import common.rng.WeightedList;
import common.tags.TagObject; import common.tags.TagObject;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.Facing; import common.util.Facing;
import common.vars.Vars; import common.vars.Vars;
@ -291,13 +293,12 @@ public class StructureMineshaft
{ {
BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z)); BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
if (boundingBoxIn.isVecInside(blockpos) && worldIn.getState(blockpos).getBlock() == Blocks.air) if (boundingBoxIn.isVecInside(blockpos) && worldIn.getState(blockpos).getBlock() == Blocks.air && worldIn.isBlockSolid(blockpos.down()))
{ {
BlockRailBase.EnumRailDirection i = rand.chance() ? BlockRailBase.EnumRailDirection.EAST_WEST : BlockRailBase.EnumRailDirection.NORTH_SOUTH; worldIn.setState(blockpos, Blocks.chest.getState().withProperty(BlockChest.FACING, Facing.randHorizontal(rand)), 2);
worldIn.setState(blockpos, this.getMetadataWithOffset(Blocks.rail.getState().withProperty(BlockRail.SHAPE, i)), 2); TileEntity tileentity = worldIn.getTileEntity(blockpos);
EntityChestCart entityminecartchest = new EntityChestCart(worldIn, (double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.5F), (double)((float)blockpos.getZ() + 0.5F)); if(tileentity instanceof TileEntityChest chest)
RngLoot.generateChestContents(rand, listIn, entityminecartchest, max); RngLoot.generateChestContents(rand, listIn, chest, max);
worldIn.spawnEntityInWorld(entityminecartchest);
return true; return true;
} }
else else