mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Made the way Phantom Tiles work more generic
This commit is contained in:
parent
945ad194ce
commit
de7c789071
6 changed files with 174 additions and 119 deletions
|
@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import ellpeck.actuallyadditions.ActuallyAdditions;
|
import ellpeck.actuallyadditions.ActuallyAdditions;
|
||||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||||
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
import ellpeck.actuallyadditions.tile.IPhantomTile;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityPhantomPlacer;
|
import ellpeck.actuallyadditions.tile.TileEntityPhantomPlacer;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityPhantomface;
|
import ellpeck.actuallyadditions.tile.TileEntityPhantomface;
|
||||||
import ellpeck.actuallyadditions.util.*;
|
import ellpeck.actuallyadditions.util.*;
|
||||||
|
@ -24,7 +24,7 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockPhantomface extends BlockContainerBase implements INameableItem{
|
public class BlockPhantom extends BlockContainerBase implements INameableItem{
|
||||||
|
|
||||||
public static final int FACE = 0;
|
public static final int FACE = 0;
|
||||||
public static final int PLACER = 1;
|
public static final int PLACER = 1;
|
||||||
|
@ -35,7 +35,7 @@ public class BlockPhantomface extends BlockContainerBase implements INameableIte
|
||||||
public int type;
|
public int type;
|
||||||
public int range;
|
public int range;
|
||||||
|
|
||||||
public BlockPhantomface(int type){
|
public BlockPhantom(int type){
|
||||||
super(Material.rock);
|
super(Material.rock);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.setHarvestLevel("pickaxe", 0);
|
this.setHarvestLevel("pickaxe", 0);
|
||||||
|
@ -43,8 +43,12 @@ public class BlockPhantomface extends BlockContainerBase implements INameableIte
|
||||||
this.setResistance(10.0F);
|
this.setResistance(10.0F);
|
||||||
this.setStepSound(soundTypeStone);
|
this.setStepSound(soundTypeStone);
|
||||||
|
|
||||||
if(type == FACE || type == LIQUIFACE || type == ENERGYFACE) this.range = ConfigIntValues.PHANTOMFACE_RANGE.getValue();
|
if(type == FACE || type == LIQUIFACE || type == ENERGYFACE){
|
||||||
else if(type == BREAKER || type == PLACER) this.range = ConfigIntValues.PHANTOM_PLACER_RANGE.getValue();
|
this.range = ConfigIntValues.PHANTOMFACE_RANGE.getValue();
|
||||||
|
}
|
||||||
|
else if(type == BREAKER || type == PLACER){
|
||||||
|
this.range = ConfigIntValues.PHANTOM_PLACER_RANGE.getValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,37 +62,22 @@ public class BlockPhantomface extends BlockContainerBase implements INameableIte
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
TileEntity tile = world.getTileEntity(x, y, z);
|
TileEntity tile = world.getTileEntity(x, y, z);
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
if(tile instanceof TileEntityPhantomface){
|
if(tile instanceof IPhantomTile){
|
||||||
TileEntityPhantomface phantom = (TileEntityPhantomface)tile;
|
IPhantomTile phantom = (IPhantomTile)tile;
|
||||||
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range));
|
if(player.isSneaking() || phantom.getGuiID() == -1){
|
||||||
if(phantom.hasBoundTile()){
|
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.getRange()));
|
||||||
int distance = (int)Vec3.createVectorHelper(x, y, z).distanceTo(Vec3.createVectorHelper(phantom.boundPosition.getX(), phantom.boundPosition.getY(), phantom.boundPosition.getZ()));
|
|
||||||
Item item = phantom.boundPosition.getItemBlock();
|
|
||||||
String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(phantom.boundPosition.getBlock(), 1, phantom.boundPosition.getMetadata()));
|
|
||||||
player.addChatComponentMessage(new ChatComponentText(StringUtil.localizeFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.blockInfo.desc", name, phantom.boundPosition.getX(), phantom.boundPosition.getY(), phantom.boundPosition.getZ(), distance)));
|
|
||||||
|
|
||||||
if(phantom.isBoundTileInRage()) player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedRange.desc")));
|
|
||||||
else player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc")));
|
|
||||||
}
|
|
||||||
else player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
|
|
||||||
}
|
|
||||||
|
|
||||||
else if(tile instanceof TileEntityPhantomPlacer){
|
|
||||||
if(player.isSneaking()){
|
|
||||||
TileEntityPhantomPlacer phantom = (TileEntityPhantomPlacer)tile;
|
|
||||||
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range));
|
|
||||||
if(phantom.hasBoundPosition()){
|
if(phantom.hasBoundPosition()){
|
||||||
int distance = (int)Vec3.createVectorHelper(x, y, z).distanceTo(Vec3.createVectorHelper(phantom.boundPosition.getX(), phantom.boundPosition.getY(), phantom.boundPosition.getZ()));
|
int distance = (int)Vec3.createVectorHelper(x, y, z).distanceTo(Vec3.createVectorHelper(phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ()));
|
||||||
Item item = phantom.boundPosition.getItemBlock();
|
Item item = phantom.getBoundPosition().getItemBlock();
|
||||||
String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(phantom.boundPosition.getBlock(), 1, phantom.boundPosition.getMetadata()));
|
String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(phantom.getBoundPosition().getBlock(), 1, phantom.getBoundPosition().getMetadata()));
|
||||||
player.addChatComponentMessage(new ChatComponentText(StringUtil.localizeFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.blockInfo.desc", name, phantom.boundPosition.getX(), phantom.boundPosition.getY(), phantom.boundPosition.getZ(), distance)));
|
player.addChatComponentMessage(new ChatComponentText(StringUtil.localizeFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance)));
|
||||||
|
|
||||||
if(phantom.isBoundPositionInRange()) player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedRange.desc")));
|
if(phantom.isBoundThingInRange()) player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedRange.desc")));
|
||||||
else player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc")));
|
else player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc")));
|
||||||
}
|
}
|
||||||
else player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
|
else player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
|
||||||
}
|
}
|
||||||
else player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.PHANTOM_PLACER.ordinal(), world, x, y, z);
|
else player.openGui(ActuallyAdditions.instance, phantom.getGuiID(), world, x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,11 +154,11 @@ public class BlockPhantomface extends BlockContainerBase implements INameableIte
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
||||||
BlockUtil.addInformation(theBlock, list, 2, "");
|
BlockUtil.addInformation(theBlock, list, 2, "");
|
||||||
if(KeyUtil.isShiftPressed()){
|
if(KeyUtil.isShiftPressed()){
|
||||||
if(((BlockPhantomface)this.theBlock).type == LIQUIFACE){
|
if(((BlockPhantom)this.theBlock).type == LIQUIFACE){
|
||||||
list.add(StringUtil.ORANGE+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomLiquiface.desc.3"));
|
list.add(StringUtil.ORANGE+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomLiquiface.desc.3"));
|
||||||
list.add(StringUtil.ORANGE+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomLiquiface.desc.4"));
|
list.add(StringUtil.ORANGE+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomLiquiface.desc.4"));
|
||||||
}
|
}
|
||||||
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + ((BlockPhantomface)theBlock).range);
|
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + ((BlockPhantom)theBlock).range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,20 +126,20 @@ public class InitBlocks{
|
||||||
blockCanolaPress = new BlockCanolaPress();
|
blockCanolaPress = new BlockCanolaPress();
|
||||||
BlockUtil.register(blockCanolaPress, BlockCanolaPress.TheItemBlock.class);
|
BlockUtil.register(blockCanolaPress, BlockCanolaPress.TheItemBlock.class);
|
||||||
|
|
||||||
blockPhantomface = new BlockPhantomface(BlockPhantomface.FACE);
|
blockPhantomface = new BlockPhantom(BlockPhantom.FACE);
|
||||||
BlockUtil.register(blockPhantomface, BlockPhantomface.TheItemBlock.class);
|
BlockUtil.register(blockPhantomface, BlockPhantom.TheItemBlock.class);
|
||||||
|
|
||||||
blockPhantomPlacer = new BlockPhantomface(BlockPhantomface.PLACER);
|
blockPhantomPlacer = new BlockPhantom(BlockPhantom.PLACER);
|
||||||
BlockUtil.register(blockPhantomPlacer, BlockPhantomface.TheItemBlock.class);
|
BlockUtil.register(blockPhantomPlacer, BlockPhantom.TheItemBlock.class);
|
||||||
|
|
||||||
blockPhantomLiquiface = new BlockPhantomface(BlockPhantomface.LIQUIFACE);
|
blockPhantomLiquiface = new BlockPhantom(BlockPhantom.LIQUIFACE);
|
||||||
BlockUtil.register(blockPhantomLiquiface, BlockPhantomface.TheItemBlock.class);
|
BlockUtil.register(blockPhantomLiquiface, BlockPhantom.TheItemBlock.class);
|
||||||
|
|
||||||
blockPhantomEnergyface = new BlockPhantomface(BlockPhantomface.ENERGYFACE);
|
blockPhantomEnergyface = new BlockPhantom(BlockPhantom.ENERGYFACE);
|
||||||
BlockUtil.register(blockPhantomEnergyface, BlockPhantomface.TheItemBlock.class);
|
BlockUtil.register(blockPhantomEnergyface, BlockPhantom.TheItemBlock.class);
|
||||||
|
|
||||||
blockPhantomBreaker = new BlockPhantomface(BlockPhantomface.BREAKER);
|
blockPhantomBreaker = new BlockPhantom(BlockPhantom.BREAKER);
|
||||||
BlockUtil.register(blockPhantomBreaker, BlockPhantomface.TheItemBlock.class);
|
BlockUtil.register(blockPhantomBreaker, BlockPhantom.TheItemBlock.class);
|
||||||
|
|
||||||
blockCoalGenerator = new BlockCoalGenerator();
|
blockCoalGenerator = new BlockCoalGenerator();
|
||||||
BlockUtil.register(blockCoalGenerator, BlockCoalGenerator.TheItemBlock.class);
|
BlockUtil.register(blockCoalGenerator, BlockCoalGenerator.TheItemBlock.class);
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package ellpeck.actuallyadditions.tile;
|
||||||
|
|
||||||
|
import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
|
|
||||||
|
public interface IPhantomTile{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return If the Phantom Tile is currently bound to anything
|
||||||
|
*/
|
||||||
|
boolean hasBoundPosition();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return If the Phantom Tile's bound position is in range
|
||||||
|
*/
|
||||||
|
boolean isBoundThingInRange();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The position this tile is bound to
|
||||||
|
*/
|
||||||
|
WorldPos getBoundPosition();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The ID of the GUI it opens, -1 if none
|
||||||
|
*/
|
||||||
|
int getGuiID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The range the tile currently has
|
||||||
|
*/
|
||||||
|
int getRange();
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package ellpeck.actuallyadditions.tile;
|
package ellpeck.actuallyadditions.tile;
|
||||||
|
|
||||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||||
|
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
||||||
import ellpeck.actuallyadditions.util.WorldPos;
|
import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -12,7 +13,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class TileEntityPhantomPlacer extends TileEntityInventoryBase{
|
public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements IPhantomTile{
|
||||||
|
|
||||||
public static class TileEntityPhantomBreaker extends TileEntityPhantomPlacer{
|
public static class TileEntityPhantomBreaker extends TileEntityPhantomPlacer{
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase{
|
||||||
this.boundPosition = null;
|
this.boundPosition = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.isBoundPositionInRange()){
|
if(this.isBoundThingInRange()){
|
||||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||||
if(this.currentTime > 0){
|
if(this.currentTime > 0){
|
||||||
this.currentTime--;
|
this.currentTime--;
|
||||||
|
@ -86,7 +87,20 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBoundPositionInRange(){
|
@Override
|
||||||
|
public boolean hasBoundPosition(){
|
||||||
|
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
||||||
|
if(this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IPhantomTile || (this.xCoord == this.boundPosition.getX() && this.yCoord == this.boundPosition.getY() && this.zCoord == this.boundPosition.getZ() && this.worldObj == this.boundPosition.getWorld())){
|
||||||
|
this.boundPosition = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return this.boundPosition.getWorld() == this.worldObj;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBoundThingInRange(){
|
||||||
if(this.hasBoundPosition()){
|
if(this.hasBoundPosition()){
|
||||||
int xDif = this.boundPosition.getX()-this.xCoord;
|
int xDif = this.boundPosition.getX()-this.xCoord;
|
||||||
int yDif = this.boundPosition.getY()-this.yCoord;
|
int yDif = this.boundPosition.getY()-this.yCoord;
|
||||||
|
@ -103,15 +117,19 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBoundPosition(){
|
@Override
|
||||||
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
public WorldPos getBoundPosition(){
|
||||||
if(this.xCoord == this.boundPosition.getX() && this.yCoord == this.boundPosition.getY() && this.zCoord == this.boundPosition.getZ() && this.worldObj == this.boundPosition.getWorld()){
|
return this.boundPosition;
|
||||||
this.boundPosition = null;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return this.boundPosition.getWorld() == this.worldObj;
|
|
||||||
|
@Override
|
||||||
|
public int getGuiID(){
|
||||||
|
return GuiHandler.GuiTypes.PHANTOM_PLACER.ordinal();
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
@Override
|
||||||
|
public int getRange(){
|
||||||
|
return this.range;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,7 +3,7 @@ package ellpeck.actuallyadditions.tile;
|
||||||
import cofh.api.energy.IEnergyHandler;
|
import cofh.api.energy.IEnergyHandler;
|
||||||
import cofh.api.energy.IEnergyProvider;
|
import cofh.api.energy.IEnergyProvider;
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import ellpeck.actuallyadditions.blocks.BlockPhantomface;
|
import ellpeck.actuallyadditions.blocks.BlockPhantom;
|
||||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||||
import ellpeck.actuallyadditions.util.WorldPos;
|
import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
|
@ -23,7 +23,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.FluidTankInfo;
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
|
|
||||||
public class TileEntityPhantomface extends TileEntityInventoryBase{
|
public class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile{
|
||||||
|
|
||||||
public WorldPos boundPosition;
|
public WorldPos boundPosition;
|
||||||
|
|
||||||
|
@ -50,29 +50,12 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
return newRange;
|
return newRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBoundTileInRage(){
|
|
||||||
if(this.hasBoundTile()){
|
|
||||||
int xDif = this.boundPosition.getX()-this.xCoord;
|
|
||||||
int yDif = this.boundPosition.getY()-this.yCoord;
|
|
||||||
int zDif = this.boundPosition.getZ()-this.zCoord;
|
|
||||||
|
|
||||||
if(xDif >= -this.range && xDif <= this.range){
|
|
||||||
if(yDif >= -this.range && yDif <= this.range){
|
|
||||||
if(zDif >= -this.range && zDif <= this.range){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity(){
|
public void updateEntity(){
|
||||||
if(!worldObj.isRemote){
|
if(!worldObj.isRemote){
|
||||||
this.range = upgradeRange(defaultRange, worldObj, xCoord, yCoord, zCoord);
|
this.range = upgradeRange(defaultRange, worldObj, xCoord, yCoord, zCoord);
|
||||||
|
|
||||||
if(!this.hasBoundTile()){
|
if(!this.hasBoundPosition()){
|
||||||
this.boundPosition = null;
|
this.boundPosition = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,21 +68,10 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBoundTile(){
|
|
||||||
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
|
||||||
if(this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof TileEntityPhantomface || (this.xCoord == this.boundPosition.getX() && this.yCoord == this.boundPosition.getY() && this.zCoord == this.boundPosition.getZ() && this.worldObj == this.boundPosition.getWorld())){
|
|
||||||
this.boundPosition = null;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return this.boundPosition.getWorld() == this.worldObj;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound compound){
|
public void writeToNBT(NBTTagCompound compound){
|
||||||
super.writeToNBT(compound);
|
super.writeToNBT(compound);
|
||||||
if(this.hasBoundTile()){
|
if(this.hasBoundPosition()){
|
||||||
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
|
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
|
||||||
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
|
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
|
||||||
compound.setInteger("ZCoordOfTileStored", boundPosition.getZ());
|
compound.setInteger("ZCoordOfTileStored", boundPosition.getZ());
|
||||||
|
@ -130,11 +102,56 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasBoundPosition(){
|
||||||
|
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
||||||
|
if(this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IPhantomTile || (this.xCoord == this.boundPosition.getX() && this.yCoord == this.boundPosition.getY() && this.zCoord == this.boundPosition.getZ() && this.worldObj == this.boundPosition.getWorld())){
|
||||||
|
this.boundPosition = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return this.boundPosition.getWorld() == this.worldObj;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBoundThingInRange(){
|
||||||
|
if(this.hasBoundPosition()){
|
||||||
|
int xDif = this.boundPosition.getX()-this.xCoord;
|
||||||
|
int yDif = this.boundPosition.getY()-this.yCoord;
|
||||||
|
int zDif = this.boundPosition.getZ()-this.zCoord;
|
||||||
|
|
||||||
|
if(xDif >= -this.range && xDif <= this.range){
|
||||||
|
if(yDif >= -this.range && yDif <= this.range){
|
||||||
|
if(zDif >= -this.range && zDif <= this.range){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorldPos getBoundPosition(){
|
||||||
|
return this.boundPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGuiID(){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRange(){
|
||||||
|
return this.range;
|
||||||
|
}
|
||||||
|
|
||||||
public static class TileEntityPhantomLiquiface extends TileEntityPhantomface implements IFluidHandler{
|
public static class TileEntityPhantomLiquiface extends TileEntityPhantomface implements IFluidHandler{
|
||||||
|
|
||||||
public TileEntityPhantomLiquiface(){
|
public TileEntityPhantomLiquiface(){
|
||||||
super("liquiface");
|
super("liquiface");
|
||||||
this.type = BlockPhantomface.LIQUIFACE;
|
this.type = BlockPhantom.LIQUIFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -142,7 +159,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if(!worldObj.isRemote){
|
if(!worldObj.isRemote){
|
||||||
if(worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && this.isBoundTileInRage() && this.getHandler() != null){
|
if(worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && this.isBoundThingInRange() && this.getHandler() != null){
|
||||||
this.pushFluid(ForgeDirection.UP);
|
this.pushFluid(ForgeDirection.UP);
|
||||||
this.pushFluid(ForgeDirection.DOWN);
|
this.pushFluid(ForgeDirection.DOWN);
|
||||||
this.pushFluid(ForgeDirection.NORTH);
|
this.pushFluid(ForgeDirection.NORTH);
|
||||||
|
@ -173,8 +190,8 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBoundTileInRage(){
|
public boolean isBoundThingInRange(){
|
||||||
return super.isBoundTileInRage() && this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IFluidHandler;
|
return super.isBoundThingInRange() && this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IFluidHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IFluidHandler getHandler(){
|
public IFluidHandler getHandler(){
|
||||||
|
@ -187,35 +204,35 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill){
|
public int fill(ForgeDirection from, FluidStack resource, boolean doFill){
|
||||||
if(this.isBoundTileInRage()) return this.getHandler().fill(from, resource, doFill);
|
if(this.isBoundThingInRange()) return this.getHandler().fill(from, resource, doFill);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){
|
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){
|
||||||
if(this.isBoundTileInRage()) return this.getHandler().drain(from, resource, doDrain);
|
if(this.isBoundThingInRange()) return this.getHandler().drain(from, resource, doDrain);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){
|
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){
|
||||||
if(this.isBoundTileInRage()) return this.getHandler().drain(from, maxDrain, doDrain);
|
if(this.isBoundThingInRange()) return this.getHandler().drain(from, maxDrain, doDrain);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canFill(ForgeDirection from, Fluid fluid){
|
public boolean canFill(ForgeDirection from, Fluid fluid){
|
||||||
return this.isBoundTileInRage() && this.getHandler().canFill(from, fluid);
|
return this.isBoundThingInRange() && this.getHandler().canFill(from, fluid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canDrain(ForgeDirection from, Fluid fluid){
|
public boolean canDrain(ForgeDirection from, Fluid fluid){
|
||||||
return this.isBoundTileInRage() && this.getHandler().canDrain(from, fluid);
|
return this.isBoundThingInRange() && this.getHandler().canDrain(from, fluid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidTankInfo[] getTankInfo(ForgeDirection from){
|
public FluidTankInfo[] getTankInfo(ForgeDirection from){
|
||||||
if(this.isBoundTileInRage()) return this.getHandler().getTankInfo(from);
|
if(this.isBoundThingInRange()) return this.getHandler().getTankInfo(from);
|
||||||
return new FluidTankInfo[0];
|
return new FluidTankInfo[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,12 +241,12 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
public TileEntityPhantomEnergyface(){
|
public TileEntityPhantomEnergyface(){
|
||||||
super("energyface");
|
super("energyface");
|
||||||
this.type = BlockPhantomface.ENERGYFACE;
|
this.type = BlockPhantom.ENERGYFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBoundTileInRage(){
|
public boolean isBoundThingInRange(){
|
||||||
return super.isBoundTileInRage() && (this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IEnergyReceiver || this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IEnergyProvider);
|
return super.isBoundThingInRange() && (this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IEnergyReceiver || this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IEnergyProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -237,7 +254,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if(!worldObj.isRemote){
|
if(!worldObj.isRemote){
|
||||||
if(this.isBoundTileInRage() && this.getProvider() != null){
|
if(this.isBoundThingInRange() && this.getProvider() != null){
|
||||||
this.pushEnergy(ForgeDirection.UP);
|
this.pushEnergy(ForgeDirection.UP);
|
||||||
this.pushEnergy(ForgeDirection.DOWN);
|
this.pushEnergy(ForgeDirection.DOWN);
|
||||||
this.pushEnergy(ForgeDirection.NORTH);
|
this.pushEnergy(ForgeDirection.NORTH);
|
||||||
|
@ -277,17 +294,17 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){
|
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){
|
||||||
return this.isBoundTileInRage() && this.getReceiver() != null ? this.getReceiver().receiveEnergy(from, maxReceive, simulate) : 0;
|
return this.isBoundThingInRange() && this.getReceiver() != null ? this.getReceiver().receiveEnergy(from, maxReceive, simulate) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate){
|
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate){
|
||||||
return this.isBoundTileInRage() && this.getProvider() != null ? this.getProvider().extractEnergy(from, maxExtract, simulate) : 0;
|
return this.isBoundThingInRange() && this.getProvider() != null ? this.getProvider().extractEnergy(from, maxExtract, simulate) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyStored(ForgeDirection from){
|
public int getEnergyStored(ForgeDirection from){
|
||||||
if(this.isBoundTileInRage()){
|
if(this.isBoundThingInRange()){
|
||||||
if(this.getProvider() != null) return this.getProvider().getEnergyStored(from);
|
if(this.getProvider() != null) return this.getProvider().getEnergyStored(from);
|
||||||
if(this.getReceiver() != null) return this.getReceiver().getEnergyStored(from);
|
if(this.getReceiver() != null) return this.getReceiver().getEnergyStored(from);
|
||||||
}
|
}
|
||||||
|
@ -296,7 +313,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxEnergyStored(ForgeDirection from){
|
public int getMaxEnergyStored(ForgeDirection from){
|
||||||
if(this.isBoundTileInRage()){
|
if(this.isBoundThingInRange()){
|
||||||
if(this.getProvider() != null) return this.getProvider().getMaxEnergyStored(from);
|
if(this.getProvider() != null) return this.getProvider().getMaxEnergyStored(from);
|
||||||
if(this.getReceiver() != null) return this.getReceiver().getMaxEnergyStored(from);
|
if(this.getReceiver() != null) return this.getReceiver().getMaxEnergyStored(from);
|
||||||
}
|
}
|
||||||
|
@ -305,7 +322,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnectEnergy(ForgeDirection from){
|
public boolean canConnectEnergy(ForgeDirection from){
|
||||||
if(this.isBoundTileInRage()){
|
if(this.isBoundThingInRange()){
|
||||||
if(this.getProvider() != null) return this.getProvider().canConnectEnergy(from);
|
if(this.getProvider() != null) return this.getProvider().canConnectEnergy(from);
|
||||||
if(this.getReceiver() != null) return this.getReceiver().canConnectEnergy(from);
|
if(this.getReceiver() != null) return this.getReceiver().canConnectEnergy(from);
|
||||||
}
|
}
|
||||||
|
@ -317,7 +334,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
public TileEntityPhantomItemface(){
|
public TileEntityPhantomItemface(){
|
||||||
super("phantomface");
|
super("phantomface");
|
||||||
this.type = BlockPhantomface.FACE;
|
this.type = BlockPhantom.FACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IInventory getInventory(){
|
public IInventory getInventory(){
|
||||||
|
@ -329,8 +346,8 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBoundTileInRage(){
|
public boolean isBoundThingInRange(){
|
||||||
return super.isBoundTileInRage() && this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IInventory;
|
return super.isBoundThingInRange() && this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IInventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISidedInventory getSided(){
|
public ISidedInventory getSided(){
|
||||||
|
@ -339,7 +356,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getInventoryStackLimit(){
|
public int getInventoryStackLimit(){
|
||||||
return this.isBoundTileInRage() ? this.getInventory().getInventoryStackLimit() : 0;
|
return this.isBoundThingInRange() ? this.getInventory().getInventoryStackLimit() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -349,33 +366,33 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
public boolean isItemValidForSlot(int i, ItemStack stack){
|
||||||
return this.isBoundTileInRage() && this.getInventory().isItemValidForSlot(i, stack);
|
return this.isBoundThingInRange() && this.getInventory().isItemValidForSlot(i, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlotOnClosing(int i){
|
public ItemStack getStackInSlotOnClosing(int i){
|
||||||
return this.isBoundTileInRage() ? this.getInventory().getStackInSlotOnClosing(i) : null;
|
return this.isBoundThingInRange() ? this.getInventory().getStackInSlotOnClosing(i) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInventorySlotContents(int i, ItemStack stack){
|
public void setInventorySlotContents(int i, ItemStack stack){
|
||||||
if(this.isBoundTileInRage()) this.getInventory().setInventorySlotContents(i, stack);
|
if(this.isBoundThingInRange()) this.getInventory().setInventorySlotContents(i, stack);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSizeInventory(){
|
public int getSizeInventory(){
|
||||||
return this.isBoundTileInRage() ? this.getInventory().getSizeInventory() : 0;
|
return this.isBoundThingInRange() ? this.getInventory().getSizeInventory() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlot(int i){
|
public ItemStack getStackInSlot(int i){
|
||||||
return this.isBoundTileInRage() ? this.getInventory().getStackInSlot(i) : null;
|
return this.isBoundThingInRange() ? this.getInventory().getStackInSlot(i) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack decrStackSize(int i, int j){
|
public ItemStack decrStackSize(int i, int j){
|
||||||
return this.isBoundTileInRage() ? this.getInventory().decrStackSize(i, j) : null;
|
return this.isBoundThingInRange() ? this.getInventory().decrStackSize(i, j) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -385,7 +402,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getAccessibleSlotsFromSide(int side){
|
public int[] getAccessibleSlotsFromSide(int side){
|
||||||
if(this.isBoundTileInRage()){
|
if(this.isBoundThingInRange()){
|
||||||
if(this.getSided() != null){
|
if(this.getSided() != null){
|
||||||
return this.getSided().getAccessibleSlotsFromSide(side);
|
return this.getSided().getAccessibleSlotsFromSide(side);
|
||||||
}
|
}
|
||||||
|
@ -402,12 +419,12 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
||||||
return this.isBoundTileInRage() && (this.getSided() == null || this.getSided().canInsertItem(slot, stack, side));
|
return this.isBoundThingInRange() && (this.getSided() == null || this.getSided().canInsertItem(slot, stack, side));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
||||||
return this.isBoundTileInRage() && (this.getSided() == null || this.getSided().canExtractItem(slot, stack, side));
|
return this.isBoundThingInRange() && (this.getSided() == null || this.getSided().canExtractItem(slot, stack, side));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,7 +314,7 @@ tooltip.actuallyadditions.phantom.boundTo.desc=Bound to
|
||||||
tooltip.actuallyadditions.phantom.connectedRange.desc=The Connection is fine and working.
|
tooltip.actuallyadditions.phantom.connectedRange.desc=The Connection is fine and working.
|
||||||
tooltip.actuallyadditions.phantom.connectedNoRange.desc=The Connection is obstructed: It is either not in Range, not in loaded Chunks or not the right type of Block for this Phantom Device.
|
tooltip.actuallyadditions.phantom.connectedNoRange.desc=The Connection is obstructed: It is either not in Range, not in loaded Chunks or not the right type of Block for this Phantom Device.
|
||||||
tooltip.actuallyadditions.phantom.notConnected.desc=This isn't connected to anything!
|
tooltip.actuallyadditions.phantom.notConnected.desc=This isn't connected to anything!
|
||||||
tooltip.actuallyadditions.phantom.blockInfo.desc=The connected Block is a %s at %s, %s, %s that is %s Blocks away.
|
tooltip.actuallyadditions.phantom.blockInfo.desc=The connected Block is %s at %s, %s, %s that is %s Blocks away.
|
||||||
|
|
||||||
tooltip.actuallyadditions.factory.notPart.desc=The Controller isn't part of the right Multi-Block! Look at the Controller's Description!
|
tooltip.actuallyadditions.factory.notPart.desc=The Controller isn't part of the right Multi-Block! Look at the Controller's Description!
|
||||||
tooltip.actuallyadditions.factory.works.desc=This Lava Factory is complete and can produce Lava!
|
tooltip.actuallyadditions.factory.works.desc=This Lava Factory is complete and can produce Lava!
|
||||||
|
|
Loading…
Reference in a new issue