mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
corporea, mana, and string tile entities
This commit is contained in:
1 parent
999705294d
commit
c2f1a9ab17
24 files changed
+325
-269
No files matched your search
@@ -15,6 +15,8 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
public abstract class TileSimpleInventory extends TileMod implements IInventory {
|
||||
|
||||
@@ -90,7 +92,7 @@ public abstract class TileSimpleInventory extends TileMod implements IInventory
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64;
|
||||
return worldObj.getTileEntity(getPos()) != this ? false : entityplayer.getDistanceSq(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D) <= 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,17 +101,40 @@ public abstract class TileSimpleInventory extends TileMod implements IInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
public boolean hasCustomName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
public void openInventory(EntityPlayer player) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
public void closeInventory(EntityPlayer player) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value) {}
|
||||
|
||||
@Override
|
||||
public int getFieldCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
// todo 1.8
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDisplayName() {
|
||||
return new ChatComponentText(getCommandSenderName()); // todo 1.8
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import vazkii.botania.common.block.tile.TileSimpleInventory;
|
||||
public abstract class TileCorporeaBase extends TileSimpleInventory {
|
||||
|
||||
public ICorporeaSpark getSpark() {
|
||||
return CorporeaHelper.getSparkForBlock(worldObj, , xCoord);
|
||||
return CorporeaHelper.getSparkForBlock(worldObj, getPos());
|
||||
}
|
||||
|
||||
}
|
||||
+6
-5
@@ -15,13 +15,14 @@ import java.util.List;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import vazkii.botania.api.corporea.CorporeaHelper;
|
||||
import vazkii.botania.api.corporea.ICorporeaRequestor;
|
||||
import vazkii.botania.api.corporea.ICorporeaSpark;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorporeaRequestor {
|
||||
public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorporeaRequestor, IUpdatePlayerListBox {
|
||||
|
||||
private static final String TAG_REQUEST_TARGET = "requestTarget";
|
||||
private static final String TAG_ITEM_COUNT = "itemCount";
|
||||
@@ -34,7 +35,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
|
||||
public int compValue = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void update() {
|
||||
++ticks;
|
||||
if(ticks % 20 == 0)
|
||||
updateCount();
|
||||
@@ -92,7 +93,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
|
||||
|
||||
private void onUpdateCount() {
|
||||
compValue = getComparatorValue();
|
||||
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
|
||||
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,7 +131,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
public String getCommandSenderName() {
|
||||
return LibBlockNames.CORPOREA_CRYSTAL_CUBE;
|
||||
}
|
||||
|
||||
@@ -144,7 +145,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
|
||||
boolean did = false;
|
||||
for(ItemStack reqStack : stacks)
|
||||
if(requestTarget != null) {
|
||||
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack);
|
||||
EntityItem item = new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, reqStack);
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
itemCount -= reqStack.stackSize;
|
||||
did = true;
|
||||
|
||||
@@ -18,7 +18,7 @@ import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import vazkii.botania.api.corporea.CorporeaHelper;
|
||||
import vazkii.botania.api.corporea.ICorporeaRequestor;
|
||||
import vazkii.botania.api.corporea.ICorporeaSpark;
|
||||
@@ -51,11 +51,11 @@ public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaReq
|
||||
1, 16, 32, 64
|
||||
};
|
||||
|
||||
for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
List<EntityItemFrame> frames = worldObj.getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, xCoord + dir.offsetX + 1, yCoord + dir.offsetY + 1, zCoord + dir.offsetZ + 1));
|
||||
for(EnumFacing dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
List<EntityItemFrame> frames = worldObj.getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB(pos.offset(dir), pos.offset(dir).add(1, 1, 1)));
|
||||
for(EntityItemFrame frame : frames) {
|
||||
int orientation = frame.hangingDirection;
|
||||
if(orientationToDir[orientation] == dir.ordinal()) {
|
||||
EnumFacing orientation = frame.facingDirection;
|
||||
if(orientation == dir) {
|
||||
ItemStack stack = frame.getDisplayedItem();
|
||||
if(stack != null) {
|
||||
ItemStack copy = stack.copy();
|
||||
@@ -80,7 +80,7 @@ public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaReq
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
public String getCommandSenderName() {
|
||||
return LibBlockNames.CORPOREA_FUNNEL;
|
||||
}
|
||||
|
||||
@@ -89,18 +89,18 @@ public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaReq
|
||||
if(!(request instanceof ItemStack))
|
||||
return;
|
||||
|
||||
IInventory inv = InventoryHelper.getInventory(worldObj, , xCoord);
|
||||
IInventory inv = InventoryHelper.getInventory(worldObj, getPos());
|
||||
if(inv == null)
|
||||
inv = InventoryHelper.getInventory(worldObj, , xCoord);
|
||||
inv = InventoryHelper.getInventory(worldObj, getPos());
|
||||
|
||||
List<ItemStack> stacks = CorporeaHelper.requestItem(request, count, spark, true, true);
|
||||
spark.onItemsRequested(stacks);
|
||||
for(ItemStack reqStack : stacks)
|
||||
if(request != null) {
|
||||
if(inv != null && reqStack.stackSize == InventoryHelper.testInventoryInsertion(inv, reqStack, ForgeDirection.UP))
|
||||
if(inv != null && reqStack.stackSize == InventoryHelper.testInventoryInsertion(inv, reqStack, EnumFacing.UP))
|
||||
InventoryHelper.insertItemIntoInventory(inv, reqStack);
|
||||
else {
|
||||
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack);
|
||||
EntityItem item = new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, reqStack);
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
@@ -44,7 +45,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequestor {
|
||||
public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequestor, IUpdatePlayerListBox {
|
||||
|
||||
public static final double RADIUS = 2.5;
|
||||
|
||||
@@ -151,12 +152,10 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ
|
||||
public boolean hasCloseby;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
double x = xCoord + 0.5;
|
||||
double y = yCoord + 0.5;
|
||||
double z = zCoord + 0.5;
|
||||
public void update() {
|
||||
double x = pos.getX() + 0.5;
|
||||
double y = pos.getY() + 0.5;
|
||||
double z = pos.getZ() + 0.5;
|
||||
|
||||
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(x - RADIUS, y - RADIUS, z - RADIUS, x + RADIUS, y + RADIUS, z + RADIUS));
|
||||
hasCloseby = false;
|
||||
@@ -197,7 +196,7 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
public String getCommandSenderName() {
|
||||
return LibBlockNames.CORPOREA_INDEX;
|
||||
}
|
||||
|
||||
@@ -210,13 +209,13 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ
|
||||
spark.onItemsRequested(stacks);
|
||||
for(ItemStack stack : stacks)
|
||||
if(stack != null) {
|
||||
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack);
|
||||
EntityItem item = new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, stack);
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isInRangeOfIndex(EntityPlayer player, TileCorporeaIndex index) {
|
||||
return player.worldObj.provider.dimensionId == index.worldObj.provider.dimensionId && MathHelper.pointDistancePlane(index.xCoord + 0.5, index.zCoord + 0.5, player.posX, player.posZ) < RADIUS && Math.abs(index.yCoord + 0.5 - player.posY + (player.worldObj.isRemote ? 0 : 1.6)) < 5;
|
||||
return player.worldObj.provider.getDimensionId() == index.worldObj.provider.getDimensionId() && MathHelper.pointDistancePlane(index.getPos().getX() + 0.5, index.getPos().getZ() + 0.5, player.posX, player.posZ) < RADIUS && Math.abs(index.getPos().getY() + 0.5 - player.posY + (player.worldObj.isRemote ? 0 : 1.6)) < 5;
|
||||
}
|
||||
|
||||
public static void addPattern(String pattern, IRegexStacker stacker) {
|
||||
|
||||
+10
-10
@@ -18,7 +18,7 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import vazkii.botania.api.corporea.CorporeaHelper;
|
||||
import vazkii.botania.api.corporea.ICorporeaInterceptor;
|
||||
import vazkii.botania.api.corporea.ICorporeaSpark;
|
||||
@@ -38,7 +38,7 @@ public class TileCorporeaInterceptor extends TileCorporeaBase implements ICorpor
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
public String getCommandSenderName() {
|
||||
return LibBlockNames.CORPOREA_INTERCEPTOR;
|
||||
}
|
||||
|
||||
@@ -58,13 +58,13 @@ public class TileCorporeaInterceptor extends TileCorporeaBase implements ICorpor
|
||||
|
||||
if(missing > 0 && getBlockMetadata() == 0) {
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2);
|
||||
worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType(), 2);
|
||||
worldObj.scheduleUpdate(getPos(), getBlockType(), 2);
|
||||
|
||||
TileEntity requestor = (TileEntity) source.getSparkInventory();
|
||||
for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ);
|
||||
for(EnumFacing dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
TileEntity tile = worldObj.getTileEntity(pos.offset(dir));
|
||||
if(tile != null && tile instanceof TileCorporeaRetainer)
|
||||
((TileCorporeaRetainer) tile).setPendingRequest(requestor.xCoord, requestor.yCoord, requestor.zCoord, request, count);
|
||||
((TileCorporeaRetainer) tile).setPendingRequest(requestor.getPos(), request, count);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -93,11 +93,11 @@ public class TileCorporeaInterceptor extends TileCorporeaBase implements ICorpor
|
||||
3, 4, 2, 5
|
||||
};
|
||||
|
||||
for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
List<EntityItemFrame> frames = worldObj.getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, xCoord + dir.offsetX + 1, yCoord + dir.offsetY + 1, zCoord + dir.offsetZ + 1));
|
||||
for(EnumFacing dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
List<EntityItemFrame> frames = worldObj.getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB(pos.offset(dir), pos.offset(dir).add(1, 1, 1)));
|
||||
for(EntityItemFrame frame : frames) {
|
||||
int orientation = frame.hangingDirection;
|
||||
if(orientationToDir[orientation] == dir.ordinal())
|
||||
EnumFacing orientation = frame.facingDirection;
|
||||
if(orientation == dir)
|
||||
filter.add(frame.getDisplayedItem());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ package vazkii.botania.common.block.tile.corporea;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import vazkii.botania.api.corporea.CorporeaHelper;
|
||||
import vazkii.botania.api.corporea.ICorporeaRequestor;
|
||||
import vazkii.botania.api.corporea.ICorporeaSpark;
|
||||
@@ -34,21 +35,19 @@ public class TileCorporeaRetainer extends TileMod {
|
||||
private static final int REQUEST_STRING = 2;
|
||||
|
||||
boolean pendingRequest = false;
|
||||
int requestX, requestY, requestZ;
|
||||
BlockPos requestPos;
|
||||
Object request;
|
||||
int requestCount;
|
||||
|
||||
public void setPendingRequest(int x, int y, int z, Object request, int requestCount) {
|
||||
public void setPendingRequest(BlockPos pos, Object request, int requestCount) {
|
||||
if(pendingRequest)
|
||||
return;
|
||||
|
||||
requestX = x;
|
||||
requestY = y;
|
||||
requestZ = z;
|
||||
requestPos = pos;
|
||||
this.request = request;
|
||||
this.requestCount = requestCount;
|
||||
pendingRequest = true;
|
||||
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
|
||||
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
|
||||
}
|
||||
|
||||
public boolean hasPendingRequest() {
|
||||
@@ -59,14 +58,14 @@ public class TileCorporeaRetainer extends TileMod {
|
||||
if(!hasPendingRequest())
|
||||
return;
|
||||
|
||||
ICorporeaSpark spark = CorporeaHelper.getSparkForBlock(worldObj, , requestX);
|
||||
ICorporeaSpark spark = CorporeaHelper.getSparkForBlock(worldObj, requestPos);
|
||||
if(spark != null) {
|
||||
IInventory inv = spark.getSparkInventory();
|
||||
if(inv != null && inv instanceof ICorporeaRequestor) {
|
||||
ICorporeaRequestor requestor = (ICorporeaRequestor) inv;
|
||||
requestor.doCorporeaRequest(request, requestCount, spark);
|
||||
pendingRequest = false;
|
||||
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
|
||||
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,9 +75,9 @@ public class TileCorporeaRetainer extends TileMod {
|
||||
super.writeCustomNBT(cmp);
|
||||
|
||||
cmp.setBoolean(TAG_PENDING_REQUEST, pendingRequest);
|
||||
cmp.setInteger(TAG_REQUEST_X, requestX);
|
||||
cmp.setInteger(TAG_REQUEST_Y, requestY);
|
||||
cmp.setInteger(TAG_REQUEST_Z, requestZ);
|
||||
cmp.setInteger(TAG_REQUEST_X, requestPos.getX());
|
||||
cmp.setInteger(TAG_REQUEST_Y, requestPos.getY());
|
||||
cmp.setInteger(TAG_REQUEST_Z, requestPos.getZ());
|
||||
|
||||
int reqType = REQUEST_NULL;
|
||||
if(request != null)
|
||||
@@ -104,9 +103,10 @@ public class TileCorporeaRetainer extends TileMod {
|
||||
super.readCustomNBT(cmp);
|
||||
|
||||
pendingRequest = cmp.getBoolean(TAG_PENDING_REQUEST);
|
||||
requestX = cmp.getInteger(TAG_REQUEST_X);
|
||||
requestY = cmp.getInteger(TAG_REQUEST_Y);
|
||||
requestZ = cmp.getInteger(TAG_REQUEST_Z);
|
||||
int x = cmp.getInteger(TAG_REQUEST_X);
|
||||
int y = cmp.getInteger(TAG_REQUEST_Y);
|
||||
int z = cmp.getInteger(TAG_REQUEST_Z);
|
||||
requestPos = new BlockPos(x, y, z);
|
||||
|
||||
int reqType = cmp.getInteger(TAG_REQUEST_TYPE);
|
||||
switch (reqType) {
|
||||
|
||||
@@ -10,16 +10,19 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import net.minecraft.block.BlockFurnace;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.common.block.subtile.functional.SubTileExoflame;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
|
||||
public class TileBellows extends TileMod {
|
||||
public class TileBellows extends TileMod implements IUpdatePlayerListBox {
|
||||
|
||||
private static final String TAG_ACTIVE = "active";
|
||||
|
||||
@@ -33,7 +36,7 @@ public class TileBellows extends TileMod {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void update() {
|
||||
boolean disable = true;
|
||||
TileEntity tile = getLinkedTile();
|
||||
if(!active && tile instanceof TilePool) {
|
||||
@@ -53,39 +56,41 @@ public class TileBellows extends TileMod {
|
||||
|
||||
if(movePos < max && active && moving >= 0F) {
|
||||
if(moving == 0F)
|
||||
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "botania:bellows", 0.1F, 3F);
|
||||
worldObj.playSoundEffect(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, "botania:bellows", 0.1F, 3F);
|
||||
|
||||
if(tile instanceof TileEntityFurnace) {
|
||||
TileEntityFurnace furnace = (TileEntityFurnace) tile;
|
||||
if(SubTileExoflame.canFurnaceSmelt(furnace)) {
|
||||
furnace.furnaceCookTime = Math.min(199, furnace.furnaceCookTime + 20);
|
||||
furnace.furnaceBurnTime = Math.max(0, furnace.furnaceBurnTime - 10);
|
||||
furnace.setField(2, Math.min(199, furnace.getField(2) + 20)); // cookTime
|
||||
furnace.setField(0, Math.max(0, furnace.getField(0) - 10)); // burnTime
|
||||
}
|
||||
|
||||
if(furnace.getBlockType() == Blocks.lit_furnace) {
|
||||
// Copypasta from BlockFurnace
|
||||
int x = furnace.xCoord;
|
||||
int y = furnace.yCoord;
|
||||
int z = furnace.zCoord;
|
||||
int l = worldObj.getBlockMetadata(x, y, z);
|
||||
float f = x + 0.5F;
|
||||
float f1 = y + 0.0F + worldObj.rand.nextFloat() * 6.0F / 16.0F;
|
||||
float f2 = z + 0.5F;
|
||||
float f3 = 0.52F;
|
||||
float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F;
|
||||
EnumFacing enumfacing = (EnumFacing)worldObj.getBlockState(furnace.getPos()).getValue(BlockFurnace.FACING);
|
||||
double d0 = (double)pos.getX() + 0.5D;
|
||||
double d1 = (double)pos.getY() + worldObj.rand.nextDouble() * 6.0D / 16.0D;
|
||||
double d2 = (double)pos.getZ() + 0.5D;
|
||||
double d3 = 0.52D;
|
||||
double d4 = worldObj.rand.nextDouble() * 0.6D - 0.3D;
|
||||
|
||||
if(l == 4) {
|
||||
worldObj.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
worldObj.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
} else if(l == 5) {
|
||||
worldObj.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
worldObj.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
} else if(l == 2) {
|
||||
worldObj.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
worldObj.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
} else if(l == 3) {
|
||||
worldObj.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
worldObj.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
switch (enumfacing)
|
||||
{
|
||||
case WEST:
|
||||
worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||
worldObj.spawnParticle(EnumParticleTypes.FLAME, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||
break;
|
||||
case EAST:
|
||||
worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||
worldObj.spawnParticle(EnumParticleTypes.FLAME, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||
break;
|
||||
case NORTH:
|
||||
worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||
worldObj.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||
break;
|
||||
case SOUTH:
|
||||
worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||
worldObj.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,13 +112,12 @@ public class TileBellows extends TileMod {
|
||||
}
|
||||
}
|
||||
|
||||
super.updateEntity();
|
||||
}
|
||||
|
||||
public TileEntity getLinkedTile() {
|
||||
int meta = getBlockMetadata();
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(meta);
|
||||
return worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ);
|
||||
EnumFacing dir = EnumFacing.getFront(meta); // todo 1.8 states
|
||||
return worldObj.getTileEntity(getPos().offset(dir));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,7 +135,7 @@ public class TileBellows extends TileMod {
|
||||
boolean diff = this.active != active;
|
||||
this.active = active;
|
||||
if(diff)
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,23 +13,24 @@ package vazkii.botania.common.block.tile.mana;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.api.mana.IManaReceiver;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileDistributor extends TileMod implements IManaReceiver {
|
||||
public class TileDistributor extends TileMod implements IManaReceiver, IUpdatePlayerListBox {
|
||||
|
||||
List<IManaReceiver> validPools = new ArrayList();
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void update() {
|
||||
validPools.clear();
|
||||
for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
TileEntity tileAt = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ);
|
||||
for(EnumFacing dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
TileEntity tileAt = worldObj.getTileEntity(pos.offset(dir));
|
||||
if(tileAt != null && tileAt instanceof IManaPool) {
|
||||
IManaReceiver receiver = (IManaReceiver) tileAt;
|
||||
if(!receiver.isFull())
|
||||
@@ -56,7 +57,7 @@ public class TileDistributor extends TileMod implements IManaReceiver {
|
||||
for(IManaReceiver pool : validPools) {
|
||||
pool.recieveMana(manaForEach);
|
||||
TileEntity tile = (TileEntity) pool;
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , tile.xCoord);
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, tile.getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,25 +10,26 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.mana.IManaCollisionGhost;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
|
||||
public class TileManaDetector extends TileMod implements IManaCollisionGhost {
|
||||
public class TileManaDetector extends TileMod implements IManaCollisionGhost, IUpdatePlayerListBox {
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void update() {
|
||||
if(!worldObj.isRemote) {
|
||||
int meta = getBlockMetadata();
|
||||
int expectedMeta = worldObj.getEntitiesWithinAABB(IManaBurst.class, new AxisAlignedBB(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)).size() != 0 ? 1 : 0;
|
||||
int expectedMeta = worldObj.getEntitiesWithinAABB(IManaBurst.class, new AxisAlignedBB(pos, pos.add(1, 1, 1))).size() != 0 ? 1 : 0;
|
||||
if(meta != expectedMeta)
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, expectedMeta, 1 | 2);
|
||||
|
||||
if(expectedMeta == 1)
|
||||
for(int i = 0; i < 4; i++)
|
||||
Botania.proxy.sparkleFX(getWorld(), xCoord + Math.random(), yCoord + Math.random(), zCoord + Math.random(), 1F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5);
|
||||
Botania.proxy.sparkleFX(getWorld(), pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 1F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,6 @@ import vazkii.botania.common.block.tile.TileMod;
|
||||
|
||||
public class TileManaVoid extends TileMod implements IClientManaHandler {
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentMana() {
|
||||
return 0;
|
||||
@@ -35,7 +30,7 @@ public class TileManaVoid extends TileMod implements IClientManaHandler {
|
||||
public void recieveMana(int mana) {
|
||||
if(mana > 0)
|
||||
for(int i = 0; i < 10; i++)
|
||||
Botania.proxy.sparkleFX(getWorld(), xCoord + Math.random(), yCoord + Math.random(), zCoord + Math.random(), 0.2F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5);
|
||||
Botania.proxy.sparkleFX(getWorld(), pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0.2F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,10 +25,11 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -58,7 +59,7 @@ import vazkii.botania.common.item.ItemManaTablet;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLocked, ISparkAttachable, IThrottledPacket {
|
||||
public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLocked, ISparkAttachable, IThrottledPacket, IUpdatePlayerListBox {
|
||||
|
||||
public static final int MAX_MANA = 1000000;
|
||||
public static final int MAX_MANA_DILLUTED = 10000;
|
||||
@@ -99,7 +100,7 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
|
||||
@Override
|
||||
public boolean isFull() {
|
||||
Block blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord);
|
||||
Block blockBelow = worldObj.getBlockState(pos.down()).getBlock();
|
||||
return blockBelow != ModBlocks.manaVoid && getCurrentMana() >= manaCap;
|
||||
}
|
||||
|
||||
@@ -109,7 +110,7 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
|
||||
this.mana = Math.max(0, Math.min(getCurrentMana() + mana, manaCap));
|
||||
if(full == mana < 0) {
|
||||
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
|
||||
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
|
||||
markDispatchable();
|
||||
}
|
||||
}
|
||||
@@ -141,7 +142,7 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
item.setDead();
|
||||
}
|
||||
|
||||
if(item.age > 100 && item.age < 130 || !catalystsRegistered)
|
||||
if(item.getAge() > 100 && item.getAge() < 130 || !catalystsRegistered)
|
||||
return false;
|
||||
|
||||
for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) {
|
||||
@@ -156,7 +157,7 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
item.setDead();
|
||||
|
||||
ItemStack output = recipe.getOutput().copy();
|
||||
EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output);
|
||||
EntityItem outputItem = new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, output);
|
||||
outputItem.age = 105;
|
||||
worldObj.spawnEntityInWorld(outputItem);
|
||||
}
|
||||
@@ -174,7 +175,7 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
|
||||
public void craftingFanciness() {
|
||||
if(soundTicks == 0) {
|
||||
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:manaPoolCraft", 0.4F, 4F);
|
||||
worldObj.playSoundEffect(pos.getX(), pos.getY(), pos.getZ(), "botania:manaPoolCraft", 0.4F, 4F);
|
||||
soundTicks = 6;
|
||||
}
|
||||
|
||||
@@ -182,12 +183,12 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
float red = (float) Math.random();
|
||||
float green = (float) Math.random();
|
||||
float blue = (float) Math.random();
|
||||
Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10);
|
||||
Botania.proxy.sparkleFX(worldObj, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void update() {
|
||||
boolean wasDoingTransfer = isDoingTransfer;
|
||||
isDoingTransfer = false;
|
||||
if(manaCap == -1)
|
||||
@@ -203,7 +204,7 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
double particleChance = 1F - (double) getCurrentMana() / (double) manaCap * 0.1;
|
||||
Color color = new Color(0x00C6FF);
|
||||
if(Math.random() > particleChance)
|
||||
Botania.proxy.wispFX(worldObj, xCoord + 0.3 + Math.random() * 0.5, yCoord + 0.6 + Math.random() * 0.25, zCoord + Math.random(), color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random() / 3F, (float) -Math.random() / 25F, 2F);
|
||||
Botania.proxy.wispFX(worldObj, pos.getX() + 0.3 + Math.random() * 0.5, pos.getY() + 0.6 + Math.random() * 0.25, pos.getZ() + Math.random(), color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random() / 3F, (float) -Math.random() / 25F, 2F);
|
||||
}
|
||||
|
||||
if(sendPacket && ticks % 10 == 0) {
|
||||
@@ -211,11 +212,11 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
sendPacket = false;
|
||||
}
|
||||
|
||||
alchemy = worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.alchemyCatalyst;
|
||||
conjuration = worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.conjurationCatalyst;
|
||||
alchemy = worldObj.getBlockState(pos.down()).getBlock() == ModBlocks.alchemyCatalyst;
|
||||
conjuration = worldObj.getBlockState(pos.down()).getBlock() == ModBlocks.conjurationCatalyst;
|
||||
catalystsRegistered = true;
|
||||
|
||||
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1));
|
||||
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)));
|
||||
for(EntityItem item : items) {
|
||||
if(item.isDead)
|
||||
continue;
|
||||
@@ -228,8 +229,8 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
|
||||
int bellowCount = 0;
|
||||
if(outputting)
|
||||
for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ);
|
||||
for(EnumFacing dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
TileEntity tile = worldObj.getTileEntity(pos.offset(dir));
|
||||
if(tile != null && tile instanceof TileBellows && ((TileBellows) tile).getLinkedTile() == this)
|
||||
bellowCount++;
|
||||
}
|
||||
@@ -324,7 +325,7 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
|
||||
if(player.isSneaking()) {
|
||||
outputting = !outputting;
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
@@ -332,7 +333,7 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
writeCustomNBT(nbttagcompound);
|
||||
nbttagcompound.setInteger(TAG_KNOWN_MANA, getCurrentMana());
|
||||
if(player instanceof EntityPlayerMP)
|
||||
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound));
|
||||
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S35PacketUpdateTileEntity(pos, -999, nbttagcompound));
|
||||
}
|
||||
|
||||
worldObj.playSoundAtEntity(player, "botania:ding", 0.11F, 1F);
|
||||
@@ -361,8 +362,8 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
ItemManaTablet.setStackCreative(tablet);
|
||||
|
||||
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, tablet, x - 20, y);
|
||||
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, pool, x + 26, y);
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(tablet, x - 20, y);
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(pool, x + 26, y);
|
||||
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
@@ -406,7 +407,7 @@ public class TilePool extends TileMod implements IManaPool, IDyablePool, IKeyLoc
|
||||
|
||||
@Override
|
||||
public ISparkEntity getAttachedSpark() {
|
||||
List<ISparkEntity> sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, new AxisAlignedBB(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1));
|
||||
List<ISparkEntity> sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, new AxisAlignedBB(pos.up(), pos.up().add(1, 1, 1)));
|
||||
if(sparks.size() == 1) {
|
||||
Entity e = (Entity) sparks.get(0);
|
||||
return (ISparkEntity) e;
|
||||
|
||||
@@ -13,6 +13,7 @@ package vazkii.botania.common.block.tile.mana;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.mana.BurstProperties;
|
||||
import vazkii.botania.api.mana.ILens;
|
||||
@@ -60,22 +61,22 @@ public class TilePrism extends TileSimpleInventory implements IManaCollisionGhos
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
public String getCommandSenderName() {
|
||||
return LibBlockNames.PRISM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int p_94128_1_) {
|
||||
public int[] getSlotsForFace(EnumFacing p_94128_1_) {
|
||||
return new int[] { 0 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) {
|
||||
public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, EnumFacing p_102007_3_) {
|
||||
return p_102007_2_.getItem() instanceof ILens;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) {
|
||||
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, EnumFacing p_102008_3_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
|
||||
public class TilePump extends TileMod {
|
||||
public class TilePump extends TileMod implements IUpdatePlayerListBox {
|
||||
|
||||
private static final String TAG_ACTIVE = "active";
|
||||
|
||||
@@ -30,10 +31,10 @@ public class TilePump extends TileMod {
|
||||
int lastComparator = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void update() {
|
||||
hasRedstone = false;
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal());
|
||||
for(EnumFacing dir : EnumFacing.VALUES) {
|
||||
int redstoneSide = worldObj.getRedstonePower(pos.offset(dir), dir);
|
||||
if(redstoneSide > 0) {
|
||||
hasRedstone = true;
|
||||
break;
|
||||
@@ -72,10 +73,8 @@ public class TilePump extends TileMod {
|
||||
hasCartOnTop = false;
|
||||
|
||||
if(comparator != lastComparator)
|
||||
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
|
||||
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
|
||||
lastComparator = comparator;
|
||||
|
||||
super.updateEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,7 +92,7 @@ public class TilePump extends TileMod {
|
||||
boolean diff = this.active != active;
|
||||
this.active = active;
|
||||
if(diff)
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,16 +11,21 @@
|
||||
package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import vazkii.botania.api.mana.IManaReceiver;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Optional.Interface(iface = "cofh.api.energy.IEnergyConnection", modid = "CoFHAPI|energy")
|
||||
public class TileRFGenerator extends TileMod implements IManaReceiver, IEnergyConnection {
|
||||
public class TileRFGenerator extends TileMod implements IManaReceiver, IEnergyConnection, IUpdatePlayerListBox {
|
||||
|
||||
private static final int CONVERSION_RATE = 10;
|
||||
private static final int MAX_MANA = 1280 * CONVERSION_RATE;
|
||||
@@ -30,7 +35,7 @@ public class TileRFGenerator extends TileMod implements IManaReceiver, IEnergyCo
|
||||
int mana = 0;
|
||||
|
||||
// Thanks to skyboy for help with this cuz I'm a noob with RF
|
||||
private IEnergyReceiver[] receiverCache;
|
||||
private EnumMap<EnumFacing, IEnergyReceiver> receiverCache;
|
||||
private boolean deadCache;
|
||||
|
||||
@Override
|
||||
@@ -43,8 +48,7 @@ public class TileRFGenerator extends TileMod implements IManaReceiver, IEnergyCo
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "CoFHAPI|energy")
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
public void update() {
|
||||
if(!worldObj.isRemote) {
|
||||
if(deadCache)
|
||||
reCache();
|
||||
@@ -58,14 +62,14 @@ public class TileRFGenerator extends TileMod implements IManaReceiver, IEnergyCo
|
||||
@Optional.Method(modid = "CoFHAPI|energy")
|
||||
protected final int transmitEnergy(int energy) {
|
||||
if(receiverCache != null)
|
||||
for(int i = receiverCache.length; i-- > 0;) {
|
||||
IEnergyReceiver tile = receiverCache[i];
|
||||
for(Map.Entry<EnumFacing, IEnergyReceiver> e : receiverCache.entrySet()) {
|
||||
// todo 1.8 this iteration was in explicit reverse order. was there a reason?
|
||||
IEnergyReceiver tile = e.getValue();
|
||||
if(tile == null)
|
||||
continue;
|
||||
|
||||
ForgeDirection from = ForgeDirection.VALID_DIRECTIONS[i];
|
||||
if(tile.receiveEnergy(from, energy, true) > 0)
|
||||
energy -= tile.receiveEnergy(from, energy, false);
|
||||
if(tile.receiveEnergy(e.getKey(), energy, true) > 0)
|
||||
energy -= tile.receiveEnergy(e.getKey(), energy, false);
|
||||
|
||||
if(energy <= 0)
|
||||
return 0;
|
||||
@@ -77,39 +81,39 @@ public class TileRFGenerator extends TileMod implements IManaReceiver, IEnergyCo
|
||||
@Optional.Method(modid = "CoFHAPI|energy")
|
||||
private void reCache() {
|
||||
if(deadCache) {
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
onNeighborTileChange(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
for(EnumFacing dir : EnumFacing.VALUES)
|
||||
onNeighborTileChange(pos.offset(dir));
|
||||
deadCache = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "CoFHAPI|energy")
|
||||
public void onNeighborTileChange(int x, int y, int z) {
|
||||
TileEntity tile = worldObj.getTileEntity(x, y, z);
|
||||
public void onNeighborTileChange(BlockPos pos) {
|
||||
TileEntity tile = worldObj.getTileEntity(pos);
|
||||
|
||||
if(x < xCoord)
|
||||
addCache(tile, 5);
|
||||
else if(x > xCoord)
|
||||
addCache(tile, 4);
|
||||
else if(z < zCoord)
|
||||
addCache(tile, 3);
|
||||
else if(z > zCoord)
|
||||
addCache(tile, 2);
|
||||
else if(y < yCoord)
|
||||
addCache(tile, 1);
|
||||
else if(y > yCoord)
|
||||
addCache(tile, 0);
|
||||
if(pos.getX() < getPos().getX())
|
||||
addCache(tile, EnumFacing.EAST);
|
||||
else if(pos.getX() > getPos().getX())
|
||||
addCache(tile, EnumFacing.WEST);
|
||||
else if(pos.getZ() < getPos().getZ())
|
||||
addCache(tile, EnumFacing.SOUTH);
|
||||
else if(pos.getZ() > getPos().getZ())
|
||||
addCache(tile, EnumFacing.NORTH);
|
||||
else if(pos.getY() < getPos().getY())
|
||||
addCache(tile, EnumFacing.UP);
|
||||
else if(pos.getY() > getPos().getY())
|
||||
addCache(tile, EnumFacing.DOWN);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "CoFHAPI|energy")
|
||||
private void addCache(TileEntity tile, int side) {
|
||||
private void addCache(TileEntity tile, EnumFacing side) {
|
||||
if(receiverCache != null)
|
||||
receiverCache[side] = null;
|
||||
receiverCache.remove(side);
|
||||
|
||||
if(tile instanceof IEnergyReceiver && ((IEnergyReceiver)tile).canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[side])) {
|
||||
if(tile instanceof IEnergyReceiver && ((IEnergyReceiver)tile).canConnectEnergy(side)) {
|
||||
if(receiverCache == null)
|
||||
receiverCache = new IEnergyReceiver[6];
|
||||
receiverCache[side] = (IEnergyReceiver)tile;
|
||||
receiverCache = new EnumMap<EnumFacing, IEnergyReceiver>(EnumFacing.class);
|
||||
receiverCache.put(side, (IEnergyReceiver)tile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +148,7 @@ public class TileRFGenerator extends TileMod implements IManaReceiver, IEnergyCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
public boolean canConnectEnergy(EnumFacing from) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -57,7 +57,7 @@ import vazkii.botania.common.entity.EntityManaBurst;
|
||||
import vazkii.botania.common.entity.EntityManaBurst.PositionProperties;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class TileSpreader extends TileSimpleInventory implements IManaCollector, IWandBindable, IKeyLocked, IThrottledPacket, IManaSpreader, IRedirectable {
|
||||
public class TileSpreader extends TileSimpleInventory implements IManaCollector, IWandBindable, IKeyLocked, IThrottledPacket, IManaSpreader, IRedirectable, IUpdatePlayerListBox {
|
||||
|
||||
private static final int MAX_MANA = 1000;
|
||||
private static final int ULTRA_MAX_MANA = 6400;
|
||||
@@ -162,7 +162,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void update() {
|
||||
boolean inNetwork = ManaNetworkHandler.instance.isCollectorIn(this);
|
||||
boolean wasInNetwork = inNetwork;
|
||||
if(!inNetwork && !isInvalid()) {
|
||||
@@ -172,8 +172,8 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
|
||||
boolean redstone = false;
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
TileEntity tileAt = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
for(EnumFacing dir : EnumFacing.VALUES) {
|
||||
TileEntity tileAt = worldObj.getTileEntity(pos.offset(dir));
|
||||
if(tileAt instanceof IManaPool) {
|
||||
IManaPool pool = (IManaPool) tileAt;
|
||||
if(wasInNetwork && (pool != receiver || isRedstone())) {
|
||||
@@ -190,7 +190,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
}
|
||||
}
|
||||
|
||||
int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal());
|
||||
int redstoneSide = worldObj.getRedstonePower(pos.offset(dir), dir);
|
||||
if(redstoneSide > 0)
|
||||
redstone = true;
|
||||
}
|
||||
@@ -243,7 +243,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
|
||||
if(receiverLastTick != receiver && !worldObj.isRemote) {
|
||||
requestsClientUpdate = true;
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
|
||||
}
|
||||
|
||||
redstoneLastTick = redstone;
|
||||
@@ -274,9 +274,9 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
cmp.setString(TAG_INPUT_KEY, inputKey);
|
||||
cmp.setString(TAG_OUTPUT_KEY, outputKey);
|
||||
|
||||
cmp.setInteger(TAG_FORCE_CLIENT_BINDING_X, receiver == null ? 0 : ((TileEntity) receiver).xCoord);
|
||||
cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Y, receiver == null ? -1 : ((TileEntity) receiver).yCoord);
|
||||
cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Z, receiver == null ? 0 : ((TileEntity) receiver).zCoord);
|
||||
cmp.setInteger(TAG_FORCE_CLIENT_BINDING_X, receiver == null ? 0 : ((TileEntity) receiver).getPos().getX());
|
||||
cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Y, receiver == null ? -1 : ((TileEntity) receiver).getPos().getY());
|
||||
cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Z, receiver == null ? 0 : ((TileEntity) receiver).getPos().getZ());
|
||||
|
||||
cmp.setBoolean(TAG_MAPMAKER_OVERRIDE, mapmakerOverride);
|
||||
cmp.setInteger(TAG_FORCED_COLOR, mmForcedColor);
|
||||
@@ -336,7 +336,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
int y = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_Y);
|
||||
int z = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_Z);
|
||||
if(y != -1) {
|
||||
TileEntity tile = worldObj.getTileEntity(x, y, z);
|
||||
TileEntity tile = worldObj.getTileEntity(new BlockPos(x, y, z));
|
||||
if(tile instanceof IManaReceiver)
|
||||
receiver = (IManaReceiver) tile;
|
||||
else receiver = null;
|
||||
@@ -367,17 +367,17 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
writeCustomNBT(nbttagcompound);
|
||||
nbttagcompound.setInteger(TAG_KNOWN_MANA, mana);
|
||||
if(player instanceof EntityPlayerMP)
|
||||
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound));
|
||||
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S35PacketUpdateTileEntity(pos, -999, nbttagcompound));
|
||||
}
|
||||
worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F);
|
||||
} else {
|
||||
MovingObjectPosition pos = raytraceFromEntity(worldObj, player, true, 5);
|
||||
if(pos != null && pos.hitVec != null && !worldObj.isRemote) {
|
||||
double x = pos.hitVec.xCoord - xCoord - 0.5;
|
||||
double y = pos.hitVec.yCoord - yCoord - 0.5;
|
||||
double z = pos.hitVec.zCoord - zCoord - 0.5;
|
||||
double x = pos.hitVec.xCoord - getPos().getX() - 0.5;
|
||||
double y = pos.hitVec.yCoord - getPos().getY() - 0.5;
|
||||
double z = pos.hitVec.zCoord - getPos().getZ() - 0.5;
|
||||
|
||||
if(pos.sideHit != 0 && pos.sideHit != 1) {
|
||||
if(pos.sideHit != EnumFacing.DOWN && pos.sideHit != EnumFacing.UP) {
|
||||
Vector3 clickVector = new Vector3(x, 0, z);
|
||||
Vector3 relative = new Vector3(-0.5, 0, 0);
|
||||
double angle = Math.acos(clickVector.dotProduct(relative) / (relative.mag() * clickVector.mag())) * 180D / Math.PI;
|
||||
@@ -392,7 +392,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
|
||||
checkForReceiver();
|
||||
requestsClientUpdate = true;
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -424,7 +424,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
worldObj.spawnEntityInWorld(burst);
|
||||
burst.ping();
|
||||
if(!ConfigHandler.silentSpreaders)
|
||||
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:spreaderFire", 0.05F * (paddingColor != -1 ? 0.2F : 1F), 0.7F + 0.3F * (float) Math.random());
|
||||
worldObj.playSoundEffect(pos.getX(), pos.getY(), pos.getZ(), "botania:spreaderFire", 0.05F * (paddingColor != -1 ? 0.2F : 1F), 0.7F + 0.3F * (float) Math.random());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -531,7 +531,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
if (player instanceof EntityPlayerMP)
|
||||
d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
|
||||
Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
|
||||
return world.func_147447_a(vec3, vec31, par3, !par3, par3);
|
||||
return world.rayTraceBlocks(vec3, vec31, par3, !par3, par3);
|
||||
}
|
||||
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res) {
|
||||
@@ -550,7 +550,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
|
||||
mc.fontRendererObj.drawStringWithShadow(lensName, x + 20, y + 5, color);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, lens, x, y);
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(lens, x, y);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
@@ -558,7 +558,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
|
||||
if(receiver != null) {
|
||||
TileEntity receiverTile = (TileEntity) receiver;
|
||||
ItemStack recieverStack = new ItemStack(worldObj.getBlock(receiverTile.xCoord, receiverTile.yCoord, receiverTile.zCoord), 1, receiverTile.getBlockMetadata());
|
||||
ItemStack recieverStack = new ItemStack(worldObj.getBlockState(receiverTile.getPos()).getBlock(), 1, receiverTile.getBlockMetadata());
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
if(recieverStack != null && recieverStack.getItem() != null) {
|
||||
@@ -569,7 +569,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
|
||||
mc.fontRendererObj.drawStringWithShadow(stackName, x + 20, y + 5, color);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y);
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(recieverStack, x, y);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
|
||||
@@ -599,7 +599,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
public String getCommandSenderName() {
|
||||
return LibBlockNames.SPREADER;
|
||||
}
|
||||
|
||||
@@ -616,7 +616,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
@Override
|
||||
public void markDirty() {
|
||||
checkForReceiver();
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -625,7 +625,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
return null;
|
||||
|
||||
TileEntity tile = (TileEntity) receiver;
|
||||
return new BlockPos(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
return tile.getPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -651,11 +651,11 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
@Override
|
||||
public boolean bindTo(EntityPlayer player, ItemStack wand, BlockPos pos, EnumFacing side) {
|
||||
Vector3 thisVec = Vector3.fromTileEntityCenter(this);
|
||||
Vector3 blockVec = new Vector3(x + 0.5, y + 0.5, z + 0.5);
|
||||
Vector3 blockVec = new Vector3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||
|
||||
AxisAlignedBB axis = player.worldObj.getBlock(x, y, z).getCollisionBoundingBoxFromPool(player.worldObj, x, y, z);
|
||||
AxisAlignedBB axis = player.worldObj.getBlockState(pos).getBlock().getCollisionBoundingBox(player.worldObj, pos, player.worldObj.getBlockState(pos));
|
||||
if(axis == null)
|
||||
axis = new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1);
|
||||
axis = new AxisAlignedBB(pos, pos.add(1, 1, 1));
|
||||
|
||||
if(!blockVec.isInside(axis))
|
||||
blockVec = new Vector3(axis.minX + (axis.maxX - axis.minX) / 2, axis.minY + (axis.maxY - axis.minY) / 2, axis.minZ + (axis.maxZ - axis.minZ) / 2);
|
||||
|
||||
@@ -15,16 +15,17 @@ import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
|
||||
public class TileTurntable extends TileMod {
|
||||
public class TileTurntable extends TileMod implements IUpdatePlayerListBox {
|
||||
|
||||
private static final String TAG_SPEED = "speed";
|
||||
private static final String TAG_BACKWARDS = "backwards";
|
||||
@@ -33,17 +34,17 @@ public class TileTurntable extends TileMod {
|
||||
boolean backwards = false;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void update() {
|
||||
boolean redstone = false;
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal());
|
||||
for(EnumFacing dir : EnumFacing.VALUES) {
|
||||
int redstoneSide = worldObj.getRedstonePower(pos.offset(dir), dir);
|
||||
if(redstoneSide > 0)
|
||||
redstone = true;
|
||||
}
|
||||
|
||||
if(!redstone) {
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
|
||||
TileEntity tile = worldObj.getTileEntity(pos.up());
|
||||
if(tile instanceof TileSpreader) {
|
||||
TileSpreader spreader = (TileSpreader) tile;
|
||||
spreader.rotationX += speed * (backwards ? -1 : 1);
|
||||
@@ -73,7 +74,7 @@ public class TileTurntable extends TileMod {
|
||||
if(player.isSneaking())
|
||||
backwards = !backwards;
|
||||
else speed = speed == 6 ? 1 : speed + 1;
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, , xCoord);
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
|
||||
}
|
||||
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res) {
|
||||
|
||||
@@ -12,43 +12,39 @@ package vazkii.botania.common.block.tile.string;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import vazkii.botania.api.wand.ITileBound;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
|
||||
public abstract class TileRedString extends TileMod implements ITileBound {
|
||||
public abstract class TileRedString extends TileMod implements ITileBound, IUpdatePlayerListBox {
|
||||
|
||||
private BlockPos binding;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
ForgeDirection dir = getOrientation();
|
||||
int x = xCoord;
|
||||
int y = yCoord;
|
||||
int z = zCoord;
|
||||
public void update() {
|
||||
EnumFacing dir = getOrientation();
|
||||
BlockPos pos_ = getPos();
|
||||
int range = getRange();
|
||||
BlockPos currBinding = getBinding();
|
||||
setBinding(null);
|
||||
|
||||
for(int i = 0; i < range; i++) {
|
||||
x += dir.offsetX;
|
||||
y += dir.offsetY;
|
||||
z += dir.offsetZ;
|
||||
if(worldObj.isAirBlock(x, y, z))
|
||||
pos_ = pos_.offset(dir);
|
||||
if(worldObj.isAirBlock(pos_))
|
||||
continue;
|
||||
|
||||
TileEntity tile = worldObj.getTileEntity(x, y, z);
|
||||
TileEntity tile = worldObj.getTileEntity(pos_);
|
||||
if(tile instanceof TileRedString)
|
||||
continue;
|
||||
|
||||
if(acceptBlock(x, y, z)) {
|
||||
setBinding(new BlockPos(x, y, z));
|
||||
if(currBinding == null || currBinding.posX != x || currBinding.posY != y || currBinding.posZ != z)
|
||||
onBound(x, y, z);
|
||||
if(acceptBlock(pos_)) {
|
||||
setBinding(new BlockPos(pos_));
|
||||
if(currBinding == null || !currBinding.equals(pos_))
|
||||
onBound(pos_);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -58,9 +54,9 @@ public abstract class TileRedString extends TileMod implements ITileBound {
|
||||
return 8;
|
||||
}
|
||||
|
||||
public abstract boolean acceptBlock(int x, int y, int z);
|
||||
public abstract boolean acceptBlock(BlockPos pos);
|
||||
|
||||
public void onBound(int x, int y, int z) {
|
||||
public void onBound(BlockPos pos) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@@ -78,18 +74,18 @@ public abstract class TileRedString extends TileMod implements ITileBound {
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
public ForgeDirection getOrientation() {
|
||||
return ForgeDirection.getOrientation(getBlockMetadata());
|
||||
public EnumFacing getOrientation() {
|
||||
return EnumFacing.getFront(getBlockMetadata()); // todo 1.8 states?
|
||||
}
|
||||
|
||||
public TileEntity getTileAtBinding() {
|
||||
BlockPos binding = getBinding();
|
||||
return binding == null ? null : worldObj.getTileEntity(binding.posX, binding.posY, binding.posZ);
|
||||
return binding == null ? null : worldObj.getTileEntity(binding);
|
||||
}
|
||||
|
||||
public Block getBlockAtBinding() {
|
||||
BlockPos binding = getBinding();
|
||||
return binding == null ? Blocks.air : worldObj.getBlock(binding.posX, binding.posY, binding.posZ);
|
||||
return binding == null ? Blocks.air : worldObj.getBlockState(binding).getBlock();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,28 +12,26 @@ package vazkii.botania.common.block.tile.string;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public class TileRedStringComparator extends TileRedString {
|
||||
|
||||
int comparatorValue = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
public void update() {
|
||||
BlockPos binding = getBinding();
|
||||
ForgeDirection dir = getOrientation();
|
||||
EnumFacing dir = getOrientation();
|
||||
Block block = getBlockAtBinding();
|
||||
int origVal = comparatorValue;
|
||||
|
||||
if(block.hasComparatorInputOverride()) {
|
||||
int val = block.getComparatorInputOverride(worldObj, binding.posX, binding.posY, binding.posZ, dir.getOpposite().ordinal());
|
||||
int val = block.getComparatorInputOverride(worldObj, binding);
|
||||
comparatorValue = val;
|
||||
} else comparatorValue = 0;
|
||||
|
||||
if(origVal != comparatorValue)
|
||||
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
|
||||
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
|
||||
}
|
||||
|
||||
public int getComparatorValue() {
|
||||
@@ -41,8 +39,8 @@ public class TileRedStringComparator extends TileRedString {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptBlock(int x, int y, int z) {
|
||||
Block block = worldObj.getBlock(x, y, z);
|
||||
public boolean acceptBlock(BlockPos pos) {
|
||||
Block block = worldObj.getBlockState(pos).getBlock();
|
||||
return block.hasComparatorInputOverride();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,14 +15,18 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import vazkii.botania.common.core.helper.InventoryHelper;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class TileRedStringContainer extends TileRedString implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public boolean acceptBlock(int x, int y, int z) {
|
||||
TileEntity inv = worldObj.getTileEntity(x, y, z);
|
||||
public boolean acceptBlock(BlockPos pos) {
|
||||
TileEntity inv = worldObj.getTileEntity(pos);
|
||||
return inv != null && inv instanceof IInventory;
|
||||
}
|
||||
|
||||
@@ -58,15 +62,21 @@ public class TileRedStringContainer extends TileRedString implements ISidedInven
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
public String getCommandSenderName() {
|
||||
IInventory inv = getInventory();
|
||||
return inv != null ? inv.getInventoryName() : LibBlockNames.RED_STRING_CONTAINER;
|
||||
return inv != null ? inv.getCommandSenderName() : LibBlockNames.RED_STRING_CONTAINER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
public boolean hasCustomName() {
|
||||
IInventory inv = getInventory();
|
||||
return inv != null ? inv.hasCustomInventoryName() : false;
|
||||
return inv != null ? inv.hasCustomName() : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDisplayName() {
|
||||
IInventory inv = getInventory();
|
||||
return inv != null ? inv.getDisplayName() : new ChatComponentText(getCommandSenderName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,17 +92,17 @@ public class TileRedStringContainer extends TileRedString implements ISidedInven
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
public void openInventory(EntityPlayer player) {
|
||||
IInventory inv = getInventory();
|
||||
if(inv != null)
|
||||
inv.openInventory();
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
public void closeInventory(EntityPlayer player) {
|
||||
IInventory inv = getInventory();
|
||||
if(inv != null)
|
||||
inv.closeInventory();
|
||||
inv.closeInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,19 +112,39 @@ public class TileRedStringContainer extends TileRedString implements ISidedInven
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
IInventory inv = getInventory();
|
||||
return inv instanceof ISidedInventory ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(side) : inv instanceof IInventory ? InventoryHelper.buildSlotsForLinearInventory(inv) : new int[0];
|
||||
public int getField(int id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side) {
|
||||
public void setField(int id, int value) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
IInventory inv = getInventory();
|
||||
return inv instanceof ISidedInventory ? ((ISidedInventory) inv).getSlotsForFace(side) : inv instanceof IInventory ? InventoryHelper.buildSlotsForLinearInventory(inv) : new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side) {
|
||||
IInventory inv = getInventory();
|
||||
return inv instanceof ISidedInventory ? ((ISidedInventory) inv).canInsertItem(slot, stack, side) : true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side) {
|
||||
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side) {
|
||||
IInventory inv = getInventory();
|
||||
return inv instanceof ISidedInventory ? ((ISidedInventory) inv).canExtractItem(slot, stack, side) : true;
|
||||
}
|
||||
|
||||
@@ -17,17 +17,17 @@ import net.minecraft.util.BlockPos;
|
||||
public class TileRedStringDispenser extends TileRedStringContainer {
|
||||
|
||||
@Override
|
||||
public boolean acceptBlock(int x, int y, int z) {
|
||||
TileEntity tile = worldObj.getTileEntity(x, y, z);
|
||||
public boolean acceptBlock(BlockPos pos) {
|
||||
TileEntity tile = worldObj.getTileEntity(pos);
|
||||
return tile != null && tile instanceof TileEntityDispenser;
|
||||
}
|
||||
|
||||
public void tickDispenser() {
|
||||
BlockPos bind = getBinding();
|
||||
if(bind != null) {
|
||||
TileEntity tile = worldObj.getTileEntity(bind.posX, bind.posY, bind.posZ);
|
||||
TileEntity tile = worldObj.getTileEntity(bind);
|
||||
if(tile instanceof TileEntityDispenser)
|
||||
worldObj.scheduleBlockUpdate(bind.posX, bind.posY, bind.posZ, tile.getBlockType(), tile.getBlockType().tickRate(worldObj));
|
||||
worldObj.scheduleUpdate(bind, tile.getBlockType(), tile.getBlockType().tickRate(worldObj));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ public class TileRedStringFertilizer extends TileRedString {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptBlock(int x, int y, int z) {
|
||||
return worldObj.getBlock(x, y, z) instanceof IGrowable;
|
||||
public boolean acceptBlock(BlockPos pos) {
|
||||
return worldObj.getBlockState(pos).getBlock() instanceof IGrowable;
|
||||
}
|
||||
|
||||
}
|
||||
+10
-11
@@ -15,31 +15,30 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileRedStringInterceptor extends TileRedString {
|
||||
public class TileRedStringInterceptor extends TileRedString implements IUpdatePlayerListBox {
|
||||
|
||||
public static List<TileRedStringInterceptor> interceptors = new ArrayList();
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
public void update() {
|
||||
if(!interceptors.contains(this))
|
||||
interceptors.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptBlock(int x, int y, int z) {
|
||||
return worldObj.getTileEntity(x, y, z) != null;
|
||||
public boolean acceptBlock(BlockPos pos) {
|
||||
return worldObj.getTileEntity(pos) != null;
|
||||
}
|
||||
|
||||
public boolean removeFromList() {
|
||||
return !tileEntityInvalid && worldObj.getTileEntity(xCoord, yCoord, zCoord) == this;
|
||||
return !tileEntityInvalid && worldObj.getTileEntity(pos) == this;
|
||||
}
|
||||
|
||||
public static void onInteract(EntityPlayer player, World world, int x, int y, int z) {
|
||||
public static void onInteract(EntityPlayer player, World world, BlockPos pos) {
|
||||
List<TileRedStringInterceptor> remove = new ArrayList();
|
||||
boolean did = false;
|
||||
|
||||
@@ -51,12 +50,12 @@ public class TileRedStringInterceptor extends TileRedString {
|
||||
|
||||
if(inter.worldObj == world) {
|
||||
BlockPos coords = inter.getBinding();
|
||||
if(coords != null && coords.posX == x && coords.posY == y && coords.posZ == z) {
|
||||
if(coords != null && coords.equals(pos)) {
|
||||
if(!world.isRemote) {
|
||||
Block block = inter.getBlockType();
|
||||
int meta = inter.getBlockMetadata();
|
||||
world.setBlockMetadataWithNotify(inter.xCoord, inter.yCoord, inter.zCoord, meta | 8, 1 | 2);
|
||||
world.scheduleBlockUpdate(inter.xCoord, inter.yCoord, inter.zCoord, block, block.tickRate(world));
|
||||
world.scheduleUpdate(inter.getPos(), block, block.tickRate(world));
|
||||
}
|
||||
|
||||
did = true;
|
||||
@@ -68,7 +67,7 @@ public class TileRedStringInterceptor extends TileRedString {
|
||||
if(did) {
|
||||
if(world.isRemote)
|
||||
player.swingItem();
|
||||
else world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "random.click", 0.3F, 0.6F);
|
||||
else world.playSoundEffect(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, "random.click", 0.3F, 0.6F);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,17 +15,18 @@ import net.minecraft.block.BlockDoublePlant;
|
||||
import net.minecraft.block.BlockFlower;
|
||||
import net.minecraft.block.BlockMushroom;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import vazkii.botania.api.subtile.ISubTileContainer;
|
||||
|
||||
public class TileRedStringRelay extends TileRedString {
|
||||
|
||||
@Override
|
||||
public boolean acceptBlock(int x, int y, int z) {
|
||||
if(x == xCoord && y == yCoord + 1 && z == zCoord)
|
||||
public boolean acceptBlock(BlockPos pos) {
|
||||
if(pos.equals(getPos().up()))
|
||||
return false;
|
||||
|
||||
Block block = worldObj.getBlock(x, y, z);
|
||||
TileEntity tile = worldObj.getTileEntity(x, y, z);
|
||||
Block block = worldObj.getBlockState(pos).getBlock();
|
||||
TileEntity tile = worldObj.getTileEntity(pos);
|
||||
return (block instanceof BlockFlower || block instanceof BlockMushroom || block instanceof BlockDoublePlant) && (tile == null || !(tile instanceof ISubTileContainer));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user