Generified the Phantom Connector

This commit is contained in:
Ellpeck 2015-08-22 19:47:20 +02:00
parent ded48b524d
commit 383461d1f3
4 changed files with 18 additions and 21 deletions

View file

@ -2,8 +2,7 @@ package ellpeck.actuallyadditions.items;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.tile.TileEntityPhantomPlacer; import ellpeck.actuallyadditions.tile.IPhantomTile;
import ellpeck.actuallyadditions.tile.TileEntityPhantomface;
import ellpeck.actuallyadditions.util.*; import ellpeck.actuallyadditions.util.*;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -32,21 +31,10 @@ public class ItemPhantomConnector extends Item implements INameableItem{
//Passing Data to Phantoms //Passing Data to Phantoms
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if(tile != null){ if(tile != null){
//Passing to Face //Passing to Phantom
if(tile instanceof TileEntityPhantomface){ if(tile instanceof IPhantomTile){
if(this.checkHasConnection(stack, player, tile)){ if(this.checkHasConnection(stack, player, tile)){
((TileEntityPhantomface)tile).boundPosition = this.getStoredPosition(stack); ((IPhantomTile)tile).setBoundPosition(this.getStoredPosition(stack));
this.clearStorage(stack);
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc")));
return true;
}
return false;
}
//Passing to Placer
else if(tile instanceof TileEntityPhantomPlacer){
if(this.checkHasConnection(stack, player, tile)){
((TileEntityPhantomPlacer)tile).boundPosition = this.getStoredPosition(stack);
tile.markDirty();
this.clearStorage(stack); this.clearStorage(stack);
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc"))); player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc")));
return true; return true;
@ -66,11 +54,8 @@ public class ItemPhantomConnector extends Item implements INameableItem{
return true; return true;
} }
else{ else{
if(tile instanceof TileEntityPhantomPlacer){ if(tile instanceof IPhantomTile){
((TileEntityPhantomPlacer)tile).boundPosition = null; ((IPhantomTile)tile).setBoundPosition(null);
}
if(tile instanceof TileEntityPhantomface){
((TileEntityPhantomface)tile).boundPosition = null;
} }
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.unbound.desc"))); player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.unbound.desc")));
return false; return false;

View file

@ -28,4 +28,6 @@ public interface IPhantomTile{
* @return The range the tile currently has * @return The range the tile currently has
*/ */
int getRange(); int getRange();
void setBoundPosition(WorldPos pos);
} }

View file

@ -129,6 +129,11 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
return this.range; return this.range;
} }
@Override
public void setBoundPosition(WorldPos pos){
this.boundPosition = pos == null ? null : pos.copy();
}
@Override @Override
public void writeToNBT(NBTTagCompound compound){ public void writeToNBT(NBTTagCompound compound){
super.writeToNBT(compound); super.writeToNBT(compound);

View file

@ -145,6 +145,11 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
return this.range; return this.range;
} }
@Override
public void setBoundPosition(WorldPos pos){
this.boundPosition = pos == null ? null : pos.copy();
}
public static class TileEntityPhantomLiquiface extends TileEntityPhantomface implements IFluidHandler{ public static class TileEntityPhantomLiquiface extends TileEntityPhantomface implements IFluidHandler{
public TileEntityPhantomLiquiface(){ public TileEntityPhantomLiquiface(){