toString methods for the EE3 tile entities, and fixing lighting for the Aludel and the Glass Bell
This commit is contained in:
parent
fc58391854
commit
9e15f7aeb8
9 changed files with 168 additions and 70 deletions
|
@ -10,6 +10,7 @@ import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
|
@ -74,6 +75,12 @@ public class BlockAludelBase extends BlockEE {
|
||||||
public void breakBlock(World world, int x, int y, int z, int id, int meta) {
|
public void breakBlock(World world, int x, int y, int z, int id, int meta) {
|
||||||
|
|
||||||
dropInventory(world, x, y, z);
|
dropInventory(world, x, y, z);
|
||||||
|
|
||||||
|
if (world.getBlockTileEntity(x, y + 1, z) instanceof TileGlassBell) {
|
||||||
|
world.markBlockForUpdate(x, y + 1, z);
|
||||||
|
world.updateAllLightTypes(x, y + 1, z);
|
||||||
|
}
|
||||||
|
|
||||||
super.breakBlock(world, x, y, z, id, meta);
|
super.breakBlock(world, x, y, z, id, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,13 +107,13 @@ public class BlockAludelBase extends BlockEE {
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, x, y, z, entityLiving, itemStack);
|
super.onBlockPlacedBy(world, x, y, z, entityLiving, itemStack);
|
||||||
|
|
||||||
if ((world.getBlockTileEntity(x, y + 1, z) != null) && (world.getBlockTileEntity(x, y + 1, z) instanceof TileGlassBell)) {
|
if (world.getBlockTileEntity(x, y + 1, z) != null && world.getBlockTileEntity(x, y + 1, z) instanceof TileGlassBell) {
|
||||||
|
|
||||||
TileGlassBell tileGlassBell = (TileGlassBell) world.getBlockTileEntity(x, y + 1, z);
|
TileGlassBell tileGlassBell = (TileGlassBell) world.getBlockTileEntity(x, y + 1, z);
|
||||||
|
|
||||||
tileGlassBell.setOrientation(ForgeDirection.UP);
|
tileGlassBell.setOrientation(ForgeDirection.UP);
|
||||||
|
|
||||||
if ((world.getBlockTileEntity(x, y, z) != null) && (world.getBlockTileEntity(x, y, z) instanceof TileAludel)) {
|
if (world.getBlockTileEntity(x, y, z) != null && world.getBlockTileEntity(x, y, z) instanceof TileAludel) {
|
||||||
|
|
||||||
TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y, z);
|
TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
|
@ -119,6 +126,12 @@ public class BlockAludelBase extends BlockEE {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private void dropInventory(World world, int x, int y, int z) {
|
private void dropInventory(World world, int x, int y, int z) {
|
||||||
|
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.pahimar.ee3.block;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
@ -81,7 +82,7 @@ public class BlockGlassBell extends BlockEE {
|
||||||
TileGlassBell tileGlassBell = (TileGlassBell) world.getBlockTileEntity(x, y, z);
|
TileGlassBell tileGlassBell = (TileGlassBell) world.getBlockTileEntity(x, y, z);
|
||||||
TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y - 1, z);
|
TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y - 1, z);
|
||||||
|
|
||||||
if ((tileAludel != null) && (tileGlassBell != null)) {
|
if (tileAludel != null && tileGlassBell != null) {
|
||||||
player.openGui(EquivalentExchange3.instance, GuiIds.ALUDEL, world, x, y - 1, z);
|
player.openGui(EquivalentExchange3.instance, GuiIds.ALUDEL, world, x, y - 1, z);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +103,7 @@ public class BlockGlassBell extends BlockEE {
|
||||||
((TileEE) world.getBlockTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
|
((TileEE) world.getBlockTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((world.getBlockTileEntity(x, y - 1, z) != null) && (world.getBlockTileEntity(x, y - 1, z) instanceof TileAludel)) {
|
if (world.getBlockTileEntity(x, y - 1, z) != null && world.getBlockTileEntity(x, y - 1, z) instanceof TileAludel) {
|
||||||
((TileEE) world.getBlockTileEntity(x, y, z)).setOrientation(ForgeDirection.UP);
|
((TileEE) world.getBlockTileEntity(x, y, z)).setOrientation(ForgeDirection.UP);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -124,6 +125,7 @@ public class BlockGlassBell extends BlockEE {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) {
|
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) {
|
||||||
|
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
if (tileEntity != null) {
|
if (tileEntity != null) {
|
||||||
|
@ -169,7 +171,28 @@ public class BlockGlassBell extends BlockEE {
|
||||||
@Override
|
@Override
|
||||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||||
|
|
||||||
return world.getBlockMetadata(x, y, z);
|
ItemStack itemStack;
|
||||||
|
|
||||||
|
if (world.getBlockTileEntity(x, y, z) instanceof TileGlassBell) {
|
||||||
|
|
||||||
|
TileGlassBell tileGlassBell = (TileGlassBell) world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if (world.getBlockTileEntity(x, y - 1, z) instanceof TileAludel) {
|
||||||
|
TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y - 1, z);
|
||||||
|
|
||||||
|
itemStack = tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX);
|
||||||
|
|
||||||
|
if (itemStack != null && itemStack.itemID < 4096)
|
||||||
|
return Block.lightValue[itemStack.itemID];
|
||||||
|
}
|
||||||
|
|
||||||
|
itemStack = tileGlassBell.getStackInSlot(TileGlassBell.DISPLAY_SLOT_INVENTORY_INDEX);
|
||||||
|
|
||||||
|
if (itemStack != null && itemStack.itemID < 4096)
|
||||||
|
return Block.lightValue[itemStack.itemID];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dropInventory(World world, int x, int y, int z) {
|
private void dropInventory(World world, int x, int y, int z) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class TileEntityAludelRenderer extends TileEntitySpecialRenderer {
|
||||||
|
|
||||||
TileEntity tileGlassBell = tileAludel.worldObj.getBlockTileEntity(tileAludel.xCoord, tileAludel.yCoord + 1, tileAludel.zCoord);
|
TileEntity tileGlassBell = tileAludel.worldObj.getBlockTileEntity(tileAludel.xCoord, tileAludel.yCoord + 1, tileAludel.zCoord);
|
||||||
|
|
||||||
if ((tileGlassBell != null) && (tileGlassBell instanceof TileGlassBell)) {
|
if (tileGlassBell != null && tileGlassBell instanceof TileGlassBell) {
|
||||||
if (tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX) != null) {
|
if (tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX) != null) {
|
||||||
|
|
||||||
float scaleFactor = getGhostItemScaleFactor(tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX));
|
float scaleFactor = getGhostItemScaleFactor(tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX));
|
||||||
|
@ -126,6 +126,7 @@ public class TileEntityAludelRenderer extends TileEntitySpecialRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getGhostItemScaleFactor(ItemStack itemStack) {
|
private float getGhostItemScaleFactor(ItemStack itemStack) {
|
||||||
|
|
||||||
float scaleFactor = 1.0F;
|
float scaleFactor = 1.0F;
|
||||||
|
|
||||||
if (itemStack != null) {
|
if (itemStack != null) {
|
||||||
|
|
|
@ -224,6 +224,7 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getGhostItemScaleFactor(ItemStack itemStack) {
|
private float getGhostItemScaleFactor(ItemStack itemStack) {
|
||||||
|
|
||||||
float scaleFactor = 1.0F;
|
float scaleFactor = 1.0F;
|
||||||
|
|
||||||
if (itemStack != null) {
|
if (itemStack != null) {
|
||||||
|
|
|
@ -240,4 +240,29 @@ public class TileAlchemicalChest extends TileEE implements IInventory {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
stringBuilder.append(super.toString());
|
||||||
|
|
||||||
|
stringBuilder.append("TileAlchemicalChest Data - ");
|
||||||
|
for (int i = 0; i < inventory.length; i++) {
|
||||||
|
if (i != 0) {
|
||||||
|
stringBuilder.append(", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inventory[i] != null) {
|
||||||
|
stringBuilder.append(String.format("inventory[%d]: %s", i, inventory[i].toString()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stringBuilder.append(String.format("inventory[%d]: empty", i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stringBuilder.append("\n");
|
||||||
|
|
||||||
|
return stringBuilder.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package com.pahimar.ee3.tileentity;
|
package com.pahimar.ee3.tileentity;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -10,7 +7,6 @@ import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.network.packet.Packet;
|
import net.minecraft.network.packet.Packet;
|
||||||
|
|
||||||
import com.pahimar.ee3.core.helper.ItemHelper;
|
import com.pahimar.ee3.core.helper.ItemHelper;
|
||||||
import com.pahimar.ee3.core.helper.LogHelper;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
import com.pahimar.ee3.lib.Strings;
|
||||||
import com.pahimar.ee3.network.PacketTypeHandler;
|
import com.pahimar.ee3.network.PacketTypeHandler;
|
||||||
import com.pahimar.ee3.network.packet.PacketTileWithItemUpdate;
|
import com.pahimar.ee3.network.packet.PacketTileWithItemUpdate;
|
||||||
|
@ -167,42 +163,43 @@ public class TileAludel extends TileEE implements IInventory {
|
||||||
|
|
||||||
ItemStack itemStack = getStackInSlot(INPUT_INVENTORY_INDEX);
|
ItemStack itemStack = getStackInSlot(INPUT_INVENTORY_INDEX);
|
||||||
|
|
||||||
if (itemStack != null && itemStack.stackSize > 0) {
|
if (itemStack != null && itemStack.stackSize > 0)
|
||||||
return PacketTypeHandler.populatePacket(new PacketTileWithItemUpdate(xCoord, yCoord, zCoord, orientation, state, customName, itemStack.itemID, itemStack.getItemDamage(), itemStack.stackSize, ItemHelper.getColor(itemStack)));
|
return PacketTypeHandler.populatePacket(new PacketTileWithItemUpdate(xCoord, yCoord, zCoord, orientation, state, customName, itemStack.itemID, itemStack.getItemDamage(), itemStack.stackSize, ItemHelper.getColor(itemStack)));
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return super.getDescriptionPacket();
|
return super.getDescriptionPacket();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInventoryChanged() {
|
public void onInventoryChanged() {
|
||||||
|
|
||||||
ItemStack itemStack = getStackInSlot(INPUT_INVENTORY_INDEX);
|
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
|
||||||
|
|
||||||
if ((itemStack != null) && (itemStack.itemID < 4096)) {
|
if (worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord) instanceof TileGlassBell) {
|
||||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, Block.lightValue[itemStack.itemID], 2);
|
worldObj.updateAllLightTypes(xCoord, yCoord + 1, zCoord);
|
||||||
}
|
|
||||||
else {
|
|
||||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
stringBuilder.append("TileEE Type: TileAludel\n");
|
|
||||||
stringBuilder.append(super.toString());
|
stringBuilder.append(super.toString());
|
||||||
|
|
||||||
|
stringBuilder.append("TileAludel Data - ");
|
||||||
for (int i = 0; i < inventory.length; i++) {
|
for (int i = 0; i < inventory.length; i++) {
|
||||||
|
if (i != 0) {
|
||||||
|
stringBuilder.append(", ");
|
||||||
|
}
|
||||||
|
|
||||||
if (inventory[i] != null) {
|
if (inventory[i] != null) {
|
||||||
stringBuilder.append("inventory[" + i + "]: " + inventory[i].toString() + "\n");
|
stringBuilder.append(String.format("inventory[%d]: %s", i, inventory[i].toString()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stringBuilder.append("inventory[" + i + "]: empty\n");
|
stringBuilder.append(String.format("inventory[%d]: empty", i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stringBuilder.append("\n");
|
||||||
|
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,4 +158,29 @@ public class TileCalcinator extends TileEE implements IInventory {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
stringBuilder.append(super.toString());
|
||||||
|
|
||||||
|
stringBuilder.append("TileCalcinator Data - ");
|
||||||
|
for (int i = 0; i < inventory.length; i++) {
|
||||||
|
if (i != 0) {
|
||||||
|
stringBuilder.append(", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inventory[i] != null) {
|
||||||
|
stringBuilder.append(String.format("inventory[%d]: %s", i, inventory[i].toString()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stringBuilder.append(String.format("inventory[%d]: empty", i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stringBuilder.append("\n");
|
||||||
|
|
||||||
|
return stringBuilder.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,12 +116,10 @@ public class TileEE extends TileEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
stringBuilder.append("x: " + xCoord + ", y: " + yCoord + ", z: " + zCoord + "\n");
|
stringBuilder.append(String.format("TileEE Data - xCoord: %d, yCoord: %d, zCoord: %d, customName: '%s', orientation: %s, state: %d\n", xCoord, yCoord, zCoord, customName, orientation, state));
|
||||||
stringBuilder.append("customName: " + customName + "\n");
|
|
||||||
stringBuilder.append("orientation: " + orientation.toString() + "\n");
|
|
||||||
stringBuilder.append("state: " + state + "\n");
|
|
||||||
|
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.pahimar.ee3.tileentity;
|
package com.pahimar.ee3.tileentity;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -152,24 +151,40 @@ public class TileGlassBell extends TileEE implements IInventory {
|
||||||
|
|
||||||
ItemStack itemStack = getStackInSlot(DISPLAY_SLOT_INVENTORY_INDEX);
|
ItemStack itemStack = getStackInSlot(DISPLAY_SLOT_INVENTORY_INDEX);
|
||||||
|
|
||||||
if (itemStack != null && itemStack.stackSize > 0) {
|
if (itemStack != null && itemStack.stackSize > 0)
|
||||||
return PacketTypeHandler.populatePacket(new PacketTileWithItemUpdate(xCoord, yCoord, zCoord, orientation, state, customName, itemStack.itemID, itemStack.getItemDamage(), itemStack.stackSize, ItemHelper.getColor(itemStack)));
|
return PacketTypeHandler.populatePacket(new PacketTileWithItemUpdate(xCoord, yCoord, zCoord, orientation, state, customName, itemStack.itemID, itemStack.getItemDamage(), itemStack.stackSize, ItemHelper.getColor(itemStack)));
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return super.getDescriptionPacket();
|
return super.getDescriptionPacket();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInventoryChanged() {
|
public void onInventoryChanged() {
|
||||||
|
|
||||||
ItemStack itemStack = getStackInSlot(DISPLAY_SLOT_INVENTORY_INDEX);
|
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
|
||||||
|
}
|
||||||
|
|
||||||
if ((itemStack != null) && (itemStack.itemID < 4096)) {
|
@Override
|
||||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, Block.lightValue[itemStack.itemID], 2);
|
public String toString() {
|
||||||
}
|
|
||||||
else {
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2);
|
|
||||||
|
stringBuilder.append(super.toString());
|
||||||
|
|
||||||
|
stringBuilder.append("TileGlassBell Data - ");
|
||||||
|
for (int i = 0; i < inventory.length; i++) {
|
||||||
|
if (i != 0) {
|
||||||
|
stringBuilder.append(", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inventory[i] != null) {
|
||||||
|
stringBuilder.append(String.format("inventory[%d]: %s", i, inventory[i].toString()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stringBuilder.append(String.format("inventory[%d]: empty", i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
stringBuilder.append("\n");
|
||||||
|
|
||||||
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue