mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-29 18:28:34 +01:00
Added WorldPositions to not have to use ChunkCoordinates + a World anymore
This commit is contained in:
parent
f483197a69
commit
ff5f49c99c
12 changed files with 148 additions and 132 deletions
|
@ -2,10 +2,7 @@ package ellpeck.actuallyadditions.blocks;
|
||||||
|
|
||||||
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.util.BlockUtil;
|
import ellpeck.actuallyadditions.util.*;
|
||||||
import ellpeck.actuallyadditions.util.INameableItem;
|
|
||||||
import ellpeck.actuallyadditions.util.ModUtil;
|
|
||||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockPistonBase;
|
import net.minecraft.block.BlockPistonBase;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -15,7 +12,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ChunkCoordinates;
|
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -74,7 +70,7 @@ public class BlockLampPowerer extends Block implements INameableItem{
|
||||||
|
|
||||||
private void updateLamp(World world, int x, int y, int z){
|
private void updateLamp(World world, int x, int y, int z){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
ChunkCoordinates coords = WorldUtil.getCoordsFromSide(ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)), x, y, z);
|
WorldPos coords = WorldUtil.getCoordsFromSide(ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)), x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,8 @@ public class BlockPhantomface extends BlockContainerBase implements INameableIte
|
||||||
TileEntityPhantomface phantom = (TileEntityPhantomface)tile;
|
TileEntityPhantomface phantom = (TileEntityPhantomface)tile;
|
||||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range));
|
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range));
|
||||||
if(phantom.hasBoundTile()){
|
if(phantom.hasBoundTile()){
|
||||||
if(phantom.isBoundTileInRage()) player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedBlock.desc", phantom.boundPosition.posX, phantom.boundPosition.posY, phantom.boundPosition.posZ)));
|
if(phantom.isBoundTileInRage()) player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedBlock.desc", phantom.boundPosition.getX(), phantom.boundPosition.getY(), phantom.boundPosition.getZ())));
|
||||||
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc", phantom.boundPosition.posX, phantom.boundPosition.posY, phantom.boundPosition.posZ)));
|
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc", phantom.boundPosition.getX(), phantom.boundPosition.getY(), phantom.boundPosition.getZ())));
|
||||||
}
|
}
|
||||||
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
|
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
|
||||||
}
|
}
|
||||||
|
@ -72,8 +72,8 @@ public class BlockPhantomface extends BlockContainerBase implements INameableIte
|
||||||
TileEntityPhantomPlacer phantom = (TileEntityPhantomPlacer)tile;
|
TileEntityPhantomPlacer phantom = (TileEntityPhantomPlacer)tile;
|
||||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range));
|
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range));
|
||||||
if(phantom.hasBoundPosition()){
|
if(phantom.hasBoundPosition()){
|
||||||
if(phantom.isBoundPositionInRange()) player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedBlock.desc", phantom.boundPosition.posX, phantom.boundPosition.posY, phantom.boundPosition.posZ)));
|
if(phantom.isBoundPositionInRange()) player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedBlock.desc", phantom.boundPosition.getX(), phantom.boundPosition.getY(), phantom.boundPosition.getZ())));
|
||||||
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc", phantom.boundPosition.posX, phantom.boundPosition.posY, phantom.boundPosition.posZ)));
|
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc", phantom.boundPosition.getX(), phantom.boundPosition.getY(), phantom.boundPosition.getZ())));
|
||||||
}
|
}
|
||||||
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
|
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import net.minecraft.item.EnumAction;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ChunkCoordinates;
|
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -54,18 +53,18 @@ public class ItemLeafBlower extends Item implements INameableItem{
|
||||||
for(int reachY = (this.isAdvanced ? -range : -rangeUp); reachY < (this.isAdvanced ? range+1 : rangeUp+1); reachY++){
|
for(int reachY = (this.isAdvanced ? -range : -rangeUp); reachY < (this.isAdvanced ? range+1 : rangeUp+1); reachY++){
|
||||||
Block block = world.getBlock(x+reachX, y+reachY, z+reachZ);
|
Block block = world.getBlock(x+reachX, y+reachY, z+reachZ);
|
||||||
if(block != null && (block instanceof BlockBush || (this.isAdvanced && block instanceof BlockLeavesBase))){
|
if(block != null && (block instanceof BlockBush || (this.isAdvanced && block instanceof BlockLeavesBase))){
|
||||||
ChunkCoordinates theCoord = new ChunkCoordinates(x+reachX, y+reachY, z+reachZ);
|
WorldPos theCoord = new WorldPos(x+reachX, y+reachY, z+reachZ);
|
||||||
Block theBlock = world.getBlock(theCoord.posX, theCoord.posY, theCoord.posZ);
|
Block theBlock = world.getBlock(theCoord.getX(), theCoord.getY(), theCoord.getZ());
|
||||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
int meta = world.getBlockMetadata(theCoord.posX, theCoord.posY, theCoord.posZ);
|
int meta = world.getBlockMetadata(theCoord.getX(), theCoord.getY(), theCoord.getZ());
|
||||||
drops.addAll(theBlock.getDrops(world, theCoord.posX, theCoord.posY, theCoord.posZ, meta, 0));
|
drops.addAll(theBlock.getDrops(world, theCoord.getX(), theCoord.getY(), theCoord.getZ(), meta, 0));
|
||||||
|
|
||||||
world.setBlockToAir(theCoord.posX, theCoord.posY, theCoord.posZ);
|
world.setBlockToAir(theCoord.getX(), theCoord.getY(), theCoord.getZ());
|
||||||
if(this.hasParticles) world.playAuxSFX(2001, theCoord.posX, theCoord.posY, theCoord.posZ, Block.getIdFromBlock(theBlock)+(meta << 12));
|
if(this.hasParticles) world.playAuxSFX(2001, theCoord.getX(), theCoord.getY(), theCoord.getZ(), Block.getIdFromBlock(theBlock)+(meta << 12));
|
||||||
|
|
||||||
if(this.doesDrop){
|
if(this.doesDrop){
|
||||||
for(ItemStack theDrop : drops){
|
for(ItemStack theDrop : drops){
|
||||||
world.spawnEntityInWorld(new EntityItem(world, theCoord.posX + 0.5, theCoord.posY + 0.5, theCoord.posZ + 0.5, theDrop));
|
world.spawnEntityInWorld(new EntityItem(world, theCoord.getX() + 0.5, theCoord.getY() + 0.5, theCoord.getZ() + 0.5, theDrop));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -14,7 +14,6 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
import net.minecraft.util.ChunkCoordinates;
|
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -38,7 +37,6 @@ public class ItemPhantomConnector extends Item implements INameableItem{
|
||||||
if(tile instanceof TileEntityPhantomface){
|
if(tile instanceof TileEntityPhantomface){
|
||||||
if(this.checkHasConnection(stack, player, tile)){
|
if(this.checkHasConnection(stack, player, tile)){
|
||||||
((TileEntityPhantomface)tile).boundPosition = this.getStoredPosition(stack);
|
((TileEntityPhantomface)tile).boundPosition = this.getStoredPosition(stack);
|
||||||
((TileEntityPhantomface)tile).boundWorld = this.getStoredWorld(stack);
|
|
||||||
WorldUtil.updateTileAndTilesAround(tile);
|
WorldUtil.updateTileAndTilesAround(tile);
|
||||||
this.clearStorage(stack);
|
this.clearStorage(stack);
|
||||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc")));
|
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc")));
|
||||||
|
@ -50,7 +48,6 @@ public class ItemPhantomConnector extends Item implements INameableItem{
|
||||||
else if(tile instanceof TileEntityPhantomPlacer){
|
else if(tile instanceof TileEntityPhantomPlacer){
|
||||||
if(this.checkHasConnection(stack, player, tile)){
|
if(this.checkHasConnection(stack, player, tile)){
|
||||||
((TileEntityPhantomPlacer)tile).boundPosition = this.getStoredPosition(stack);
|
((TileEntityPhantomPlacer)tile).boundPosition = this.getStoredPosition(stack);
|
||||||
((TileEntityPhantomPlacer)tile).boundWorld = this.getStoredWorld(stack);
|
|
||||||
tile.markDirty();
|
tile.markDirty();
|
||||||
this.clearStorage(stack);
|
this.clearStorage(stack);
|
||||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc")));
|
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc")));
|
||||||
|
@ -67,16 +64,14 @@ public class ItemPhantomConnector extends Item implements INameableItem{
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkHasConnection(ItemStack stack, EntityPlayer player, TileEntity tile){
|
public boolean checkHasConnection(ItemStack stack, EntityPlayer player, TileEntity tile){
|
||||||
if(this.getStoredPosition(stack) != null && this.getStoredWorld(stack) != null){
|
if(this.getStoredPosition(stack) != null){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(tile instanceof TileEntityPhantomPlacer){
|
if(tile instanceof TileEntityPhantomPlacer){
|
||||||
((TileEntityPhantomPlacer)tile).boundWorld = null;
|
|
||||||
((TileEntityPhantomPlacer)tile).boundPosition = null;
|
((TileEntityPhantomPlacer)tile).boundPosition = null;
|
||||||
}
|
}
|
||||||
if(tile instanceof TileEntityPhantomface){
|
if(tile instanceof TileEntityPhantomface){
|
||||||
((TileEntityPhantomface)tile).boundWorld = null;
|
|
||||||
((TileEntityPhantomface)tile).boundPosition = null;
|
((TileEntityPhantomface)tile).boundPosition = null;
|
||||||
}
|
}
|
||||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".phantom.unbound.desc")));
|
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".phantom.unbound.desc")));
|
||||||
|
@ -86,7 +81,7 @@ public class ItemPhantomConnector extends Item implements INameableItem{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){
|
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){
|
||||||
if(this.getStoredPosition(stack) == null || this.getStoredWorld(stack) == null) this.clearStorage(stack);
|
if(this.getStoredPosition(stack) == null) this.clearStorage(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,23 +90,16 @@ public class ItemPhantomConnector extends Item implements INameableItem{
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkCoordinates getStoredPosition(ItemStack stack){
|
public WorldPos getStoredPosition(ItemStack stack){
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
if(tag != null){
|
if(tag != null){
|
||||||
int x = tag.getInteger("XCoordOfTileStored");
|
int x = tag.getInteger("XCoordOfTileStored");
|
||||||
int y = tag.getInteger("YCoordOfTileStored");
|
int y = tag.getInteger("YCoordOfTileStored");
|
||||||
int z = tag.getInteger("ZCoordOfTileStored");
|
int z = tag.getInteger("ZCoordOfTileStored");
|
||||||
|
World world = DimensionManager.getWorld(tag.getInteger("WorldOfTileStored"));
|
||||||
if(x == 0 && y == 0 && z == 0) return null;
|
if(x != 0 && y != 0 && z != 0 && world != null){
|
||||||
return new ChunkCoordinates(x, y, z);
|
return new WorldPos(x, y, z);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public World getStoredWorld(ItemStack stack){
|
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
|
||||||
if(tag != null){
|
|
||||||
return DimensionManager.getWorld(tag.getInteger("WorldOfTileStored"));
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -142,16 +130,18 @@ public class ItemPhantomConnector extends Item implements INameableItem{
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
||||||
ItemUtil.addInformation(this, list, 2, "");
|
ItemUtil.addInformation(this, list, 2, "");
|
||||||
ChunkCoordinates coords = this.getStoredPosition(stack);
|
WorldPos coords = this.getStoredPosition(stack);
|
||||||
World world = this.getStoredWorld(stack);
|
if(coords != null){
|
||||||
if(coords != null && world != null){
|
World world = coords.getWorld();
|
||||||
|
if(world != null){
|
||||||
list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.boundTo.desc")+":");
|
list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.boundTo.desc")+":");
|
||||||
list.add("X: " + coords.posX);
|
list.add("X: "+coords.getX());
|
||||||
list.add("Y: " + coords.posY);
|
list.add("Y: "+coords.getY());
|
||||||
list.add("Z: " + coords.posZ);
|
list.add("Z: "+coords.getZ());
|
||||||
list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.inWorld.desc")+" "+world.provider.dimensionId);
|
list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.inWorld.desc")+" "+world.provider.dimensionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IIcon getIcon(ItemStack stack, int pass){
|
public IIcon getIcon(ItemStack stack, int pass){
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package ellpeck.actuallyadditions.tile;
|
package ellpeck.actuallyadditions.tile;
|
||||||
|
|
||||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||||
|
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;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.ChunkCoordinates;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -45,22 +45,22 @@ public class TileEntityBreaker extends TileEntityInventoryBase{
|
||||||
if(this.currentTime <= 0){
|
if(this.currentTime <= 0){
|
||||||
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||||
|
|
||||||
ChunkCoordinates coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord);
|
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord);
|
||||||
if(coordsBlock != null){
|
if(coordsBlock != null){
|
||||||
Block blockToBreak = worldObj.getBlock(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ);
|
Block blockToBreak = worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
|
||||||
if(!this.isPlacer && blockToBreak != null && blockToBreak.getBlockHardness(worldObj, coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ) > -1.0F){
|
if(!this.isPlacer && blockToBreak != null && blockToBreak.getBlockHardness(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) > -1.0F){
|
||||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
int meta = worldObj.getBlockMetadata(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ);
|
int meta = worldObj.getBlockMetadata(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
|
||||||
drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ, meta, 0));
|
drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ(), meta, 0));
|
||||||
|
|
||||||
if(addToInventory(this.slots, drops, false)){
|
if(addToInventory(this.slots, drops, false)){
|
||||||
worldObj.playAuxSFX(2001, coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ, Block.getIdFromBlock(blockToBreak) + (meta << 12));
|
worldObj.playAuxSFX(2001, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ(), Block.getIdFromBlock(blockToBreak) + (meta << 12));
|
||||||
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord);
|
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord);
|
||||||
addToInventory(this.slots, drops, true);
|
addToInventory(this.slots, drops, true);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(this.isPlacer && worldObj.getBlock(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ).isReplaceable(worldObj, coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ)){
|
else if(this.isPlacer && worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()).isReplaceable(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ())){
|
||||||
int theSlot = testInventory(this.slots);
|
int theSlot = testInventory(this.slots);
|
||||||
this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, this.slots[theSlot]));
|
this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, this.slots[theSlot]));
|
||||||
if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0) this.slots[theSlot] = null;
|
if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0) this.slots[theSlot] = null;
|
||||||
|
|
|
@ -5,12 +5,12 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||||
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
|
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
|
||||||
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
|
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
|
||||||
|
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;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.ChunkCoordinates;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.*;
|
import net.minecraftforge.fluids.*;
|
||||||
|
|
||||||
|
@ -110,10 +110,10 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
|
||||||
if(this.currentTime <= 0){
|
if(this.currentTime <= 0){
|
||||||
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||||
|
|
||||||
ChunkCoordinates coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord);
|
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord);
|
||||||
if(coordsBlock != null){
|
if(coordsBlock != null){
|
||||||
Block blockToBreak = worldObj.getBlock(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ);
|
Block blockToBreak = worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
|
||||||
if(!this.isPlacer && blockToBreak != null && worldObj.getBlockMetadata(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ) == 0){
|
if(!this.isPlacer && blockToBreak != null && worldObj.getBlockMetadata(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) == 0){
|
||||||
if(blockToBreak instanceof IFluidBlock && ((IFluidBlock)blockToBreak).getFluid() != null){
|
if(blockToBreak instanceof IFluidBlock && ((IFluidBlock)blockToBreak).getFluid() != null){
|
||||||
if(this.tank.fill(new FluidStack(((IFluidBlock)blockToBreak).getFluid(), FluidContainerRegistry.BUCKET_VOLUME), false) >= FluidContainerRegistry.BUCKET_VOLUME){
|
if(this.tank.fill(new FluidStack(((IFluidBlock)blockToBreak).getFluid(), FluidContainerRegistry.BUCKET_VOLUME), false) >= FluidContainerRegistry.BUCKET_VOLUME){
|
||||||
this.tank.fill(new FluidStack(((IFluidBlock)blockToBreak).getFluid(), FluidContainerRegistry.BUCKET_VOLUME), true);
|
this.tank.fill(new FluidStack(((IFluidBlock)blockToBreak).getFluid(), FluidContainerRegistry.BUCKET_VOLUME), true);
|
||||||
|
@ -133,7 +133,7 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(this.isPlacer && worldObj.getBlock(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ).isReplaceable(worldObj, coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ)){
|
else if(this.isPlacer && worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()).isReplaceable(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ())){
|
||||||
if(this.tank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME){
|
if(this.tank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME){
|
||||||
if(this.tank.getFluid().getFluid().getBlock() != null){
|
if(this.tank.getFluid().getFluid().getBlock() != null){
|
||||||
Block block = worldObj.getBlock(xCoord+sideToManipulate.offsetX, yCoord+sideToManipulate.offsetY, zCoord+sideToManipulate.offsetZ);
|
Block block = worldObj.getBlock(xCoord+sideToManipulate.offsetX, yCoord+sideToManipulate.offsetY, zCoord+sideToManipulate.offsetZ);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package ellpeck.actuallyadditions.tile;
|
package ellpeck.actuallyadditions.tile;
|
||||||
|
|
||||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||||
|
import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockGrass;
|
import net.minecraft.block.BlockGrass;
|
||||||
import net.minecraft.block.IGrowable;
|
import net.minecraft.block.IGrowable;
|
||||||
import net.minecraft.util.ChunkCoordinates;
|
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
@ -18,13 +18,13 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{
|
||||||
public void updateEntity(){
|
public void updateEntity(){
|
||||||
if(!worldObj.isRemote){
|
if(!worldObj.isRemote){
|
||||||
if(worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord) && worldObj.isDaytime()){
|
if(worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord) && worldObj.isDaytime()){
|
||||||
ChunkCoordinates blockToFert = this.blockToFertilize();
|
WorldPos blockToFert = this.blockToFertilize();
|
||||||
if(blockToFert != null){
|
if(blockToFert != null){
|
||||||
if(this.timeUntilNextFert > 0){
|
if(this.timeUntilNextFert > 0){
|
||||||
this.timeUntilNextFert--;
|
this.timeUntilNextFert--;
|
||||||
if(timeUntilNextFert <= 0){
|
if(timeUntilNextFert <= 0){
|
||||||
worldObj.getBlock(blockToFert.posX, blockToFert.posY, blockToFert.posZ).updateTick(worldObj, blockToFert.posX, blockToFert.posY, blockToFert.posZ, worldObj.rand);
|
worldObj.getBlock(blockToFert.getX(), blockToFert.getY(), blockToFert.getZ()).updateTick(worldObj, blockToFert.getX(), blockToFert.getY(), blockToFert.getZ(), worldObj.rand);
|
||||||
worldObj.playAuxSFX(2005, blockToFert.posX, blockToFert.posY, blockToFert.posZ, 0);
|
worldObj.playAuxSFX(2005, blockToFert.getX(), blockToFert.getY(), blockToFert.getZ(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else this.timeUntilNextFert = this.timeUntilNextFertToSet+new Random().nextInt(this.timeUntilNextFertToSet);
|
else this.timeUntilNextFert = this.timeUntilNextFertToSet+new Random().nextInt(this.timeUntilNextFertToSet);
|
||||||
|
@ -33,12 +33,12 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkCoordinates blockToFertilize(){
|
public WorldPos blockToFertilize(){
|
||||||
for(int i = yCoord-1; i > 0; i--){
|
for(int i = yCoord-1; i > 0; i--){
|
||||||
Block block = worldObj.getBlock(xCoord, i, zCoord);
|
Block block = worldObj.getBlock(xCoord, i, zCoord);
|
||||||
if(block != null && !(worldObj.isAirBlock(xCoord, i, zCoord))){
|
if(block != null && !(worldObj.isAirBlock(xCoord, i, zCoord))){
|
||||||
if(block instanceof IGrowable && !(block instanceof BlockGrass)){
|
if(block instanceof IGrowable && !(block instanceof BlockGrass)){
|
||||||
return new ChunkCoordinates(xCoord, i, zCoord);
|
return new WorldPos(xCoord, i, zCoord);
|
||||||
}
|
}
|
||||||
else return null;
|
else return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@ package ellpeck.actuallyadditions.tile;
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyProvider;
|
import cofh.api.energy.IEnergyProvider;
|
||||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||||
|
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;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.util.ChunkCoordinates;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -27,10 +27,10 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
|
||||||
ArrayList<Integer> blocksAround = new ArrayList<Integer>();
|
ArrayList<Integer> blocksAround = new ArrayList<Integer>();
|
||||||
if(energyProducedPerTick <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){
|
if(energyProducedPerTick <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){
|
||||||
for(int i = 1; i <= 5; i++){
|
for(int i = 1; i <= 5; i++){
|
||||||
ChunkCoordinates coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionByRotatingSide(i), xCoord, yCoord, zCoord);
|
WorldPos coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionByRotatingSide(i), xCoord, yCoord, zCoord);
|
||||||
if(coords != null){
|
if(coords != null){
|
||||||
Block block = worldObj.getBlock(coords.posX, coords.posY, coords.posZ);
|
Block block = worldObj.getBlock(coords.getX(), coords.getY(), coords.getZ());
|
||||||
if(block != null && block.getMaterial() == Material.lava && worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ) == 0){
|
if(block != null && block.getMaterial() == Material.lava && worldObj.getBlockMetadata(coords.getX(), coords.getY(), coords.getZ()) == 0){
|
||||||
blocksAround.add(i);
|
blocksAround.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package ellpeck.actuallyadditions.tile;
|
package ellpeck.actuallyadditions.tile;
|
||||||
|
|
||||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||||
|
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;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.ChunkCoordinates;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
@ -23,8 +23,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkCoordinates boundPosition;
|
public WorldPos boundPosition;
|
||||||
public World boundWorld;
|
|
||||||
|
|
||||||
public int currentTime;
|
public int currentTime;
|
||||||
public final int timeNeeded = ConfigIntValues.PHANTOM_PLACER_TIME.getValue();
|
public final int timeNeeded = ConfigIntValues.PHANTOM_PLACER_TIME.getValue();
|
||||||
|
@ -50,7 +49,6 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase{
|
||||||
|
|
||||||
if(!this.hasBoundPosition()){
|
if(!this.hasBoundPosition()){
|
||||||
this.boundPosition = null;
|
this.boundPosition = null;
|
||||||
this.boundWorld = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.isBoundPositionInRange()){
|
if(this.isBoundPositionInRange()){
|
||||||
|
@ -59,24 +57,24 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase{
|
||||||
this.currentTime--;
|
this.currentTime--;
|
||||||
if(this.currentTime <= 0){
|
if(this.currentTime <= 0){
|
||||||
if(this.isBreaker){
|
if(this.isBreaker){
|
||||||
Block blockToBreak = boundWorld.getBlock(boundPosition.posX, boundPosition.posY, boundPosition.posZ);
|
Block blockToBreak = boundPosition.getWorld().getBlock(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||||
if(blockToBreak != null && blockToBreak.getBlockHardness(boundWorld, boundPosition.posX, boundPosition.posY, boundPosition.posZ) > -1.0F){
|
if(blockToBreak != null && blockToBreak.getBlockHardness(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) > -1.0F){
|
||||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
int meta = boundWorld.getBlockMetadata(boundPosition.posX, boundPosition.posY, boundPosition.posZ);
|
int meta = boundPosition.getWorld().getBlockMetadata(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||||
drops.addAll(blockToBreak.getDrops(boundWorld, boundPosition.posX, boundPosition.posY, boundPosition.posZ, meta, 0));
|
drops.addAll(blockToBreak.getDrops(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), meta, 0));
|
||||||
|
|
||||||
if(TileEntityBreaker.addToInventory(this.slots, drops, false)){
|
if(TileEntityBreaker.addToInventory(this.slots, drops, false)){
|
||||||
boundWorld.playAuxSFX(2001, boundPosition.posX, boundPosition.posY, boundPosition.posZ, Block.getIdFromBlock(blockToBreak) + (meta << 12));
|
boundPosition.getWorld().playAuxSFX(2001, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), Block.getIdFromBlock(blockToBreak)+(meta << 12));
|
||||||
WorldUtil.breakBlockAtSide(ForgeDirection.UNKNOWN, boundWorld, boundPosition.posX, boundPosition.posY, boundPosition.posZ);
|
WorldUtil.breakBlockAtSide(ForgeDirection.UNKNOWN, boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||||
TileEntityBreaker.addToInventory(this.slots, drops, true);
|
TileEntityBreaker.addToInventory(this.slots, drops, true);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(boundWorld.getBlock(boundPosition.posX, boundPosition.posY, boundPosition.posZ).isReplaceable(boundWorld, boundPosition.posX, boundPosition.posY, boundPosition.posZ)){
|
if(boundPosition.getWorld().getBlock(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()).isReplaceable(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ())){
|
||||||
int theSlot = TileEntityBreaker.testInventory(this.slots);
|
int theSlot = TileEntityBreaker.testInventory(this.slots);
|
||||||
this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(ForgeDirection.UNKNOWN, boundWorld, boundPosition.posX, boundPosition.posY, boundPosition.posZ, this.slots[theSlot]));
|
this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(ForgeDirection.UNKNOWN, boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), this.slots[theSlot]));
|
||||||
if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0) this.slots[theSlot] = null;
|
if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0) this.slots[theSlot] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,9 +88,9 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase{
|
||||||
|
|
||||||
public boolean isBoundPositionInRange(){
|
public boolean isBoundPositionInRange(){
|
||||||
if(this.hasBoundPosition()){
|
if(this.hasBoundPosition()){
|
||||||
int xDif = this.boundPosition.posX-this.xCoord;
|
int xDif = this.boundPosition.getX()-this.xCoord;
|
||||||
int yDif = this.boundPosition.posY-this.yCoord;
|
int yDif = this.boundPosition.getY()-this.yCoord;
|
||||||
int zDif = this.boundPosition.posZ-this.zCoord;
|
int zDif = this.boundPosition.getZ()-this.zCoord;
|
||||||
|
|
||||||
if(xDif >= -this.range && xDif <= this.range){
|
if(xDif >= -this.range && xDif <= this.range){
|
||||||
if(yDif >= -this.range && yDif <= this.range){
|
if(yDif >= -this.range && yDif <= this.range){
|
||||||
|
@ -104,13 +102,12 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBoundPosition(){
|
public boolean hasBoundPosition(){
|
||||||
if(this.boundPosition != null && this.boundWorld != null){
|
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
||||||
if(this.xCoord == this.boundPosition.posX && this.yCoord == this.boundPosition.posY && this.zCoord == this.boundPosition.posZ && this.worldObj == this.boundWorld){
|
if(this.xCoord == this.boundPosition.getX() && this.yCoord == this.boundPosition.getY() && this.zCoord == this.boundPosition.getZ() && this.worldObj == this.boundPosition.getWorld()){
|
||||||
this.boundPosition = null;
|
this.boundPosition = null;
|
||||||
this.boundWorld = null;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.boundWorld == this.worldObj;
|
return this.boundPosition.getWorld() == this.worldObj;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -120,10 +117,10 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase{
|
||||||
super.writeToNBT(compound);
|
super.writeToNBT(compound);
|
||||||
compound.setInteger("Time", currentTime);
|
compound.setInteger("Time", currentTime);
|
||||||
if(this.hasBoundPosition()){
|
if(this.hasBoundPosition()){
|
||||||
compound.setInteger("XCoordOfTileStored", boundPosition.posX);
|
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
|
||||||
compound.setInteger("YCoordOfTileStored", boundPosition.posY);
|
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
|
||||||
compound.setInteger("ZCoordOfTileStored", boundPosition.posZ);
|
compound.setInteger("ZCoordOfTileStored", boundPosition.getZ());
|
||||||
compound.setInteger("WorldOfTileStored", boundWorld.provider.dimensionId);
|
compound.setInteger("WorldOfTileStored", boundPosition.getWorld().provider.dimensionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,9 +130,9 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase{
|
||||||
int x = compound.getInteger("XCoordOfTileStored");
|
int x = compound.getInteger("XCoordOfTileStored");
|
||||||
int y = compound.getInteger("YCoordOfTileStored");
|
int y = compound.getInteger("YCoordOfTileStored");
|
||||||
int z = compound.getInteger("ZCoordOfTileStored");
|
int z = compound.getInteger("ZCoordOfTileStored");
|
||||||
if(x != 0 && y != 0 && z != 0){
|
World world = DimensionManager.getWorld(compound.getInteger("WorldOfTileStored"));
|
||||||
this.boundPosition = new ChunkCoordinates(x, y, z);
|
if(x != 0 && y != 0 && z != 0 && world != null){
|
||||||
this.boundWorld = DimensionManager.getWorld(compound.getInteger("WorldOfTileStored"));
|
this.boundPosition = new WorldPos(world, x, y, z);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import cofh.api.energy.IEnergyReceiver;
|
||||||
import ellpeck.actuallyadditions.blocks.BlockPhantomface;
|
import ellpeck.actuallyadditions.blocks.BlockPhantomface;
|
||||||
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.WorldUtil;
|
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -14,7 +15,6 @@ import net.minecraft.inventory.ISidedInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ChunkCoordinates;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
@ -25,8 +25,7 @@ import net.minecraftforge.fluids.IFluidHandler;
|
||||||
|
|
||||||
public class TileEntityPhantomface extends TileEntityInventoryBase{
|
public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
public ChunkCoordinates boundPosition;
|
public WorldPos boundPosition;
|
||||||
public World boundWorld;
|
|
||||||
|
|
||||||
public int type;
|
public int type;
|
||||||
|
|
||||||
|
@ -49,9 +48,9 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
public boolean isBoundTileInRage(){
|
public boolean isBoundTileInRage(){
|
||||||
if(this.hasBoundTile()){
|
if(this.hasBoundTile()){
|
||||||
int xDif = this.boundPosition.posX-this.xCoord;
|
int xDif = this.boundPosition.getX()-this.xCoord;
|
||||||
int yDif = this.boundPosition.posY-this.yCoord;
|
int yDif = this.boundPosition.getY()-this.yCoord;
|
||||||
int zDif = this.boundPosition.posZ-this.zCoord;
|
int zDif = this.boundPosition.getZ()-this.zCoord;
|
||||||
|
|
||||||
if(xDif >= -this.range && xDif <= this.range){
|
if(xDif >= -this.range && xDif <= this.range){
|
||||||
if(yDif >= -this.range && yDif <= this.range){
|
if(yDif >= -this.range && yDif <= this.range){
|
||||||
|
@ -69,19 +68,17 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
if(!this.hasBoundTile()){
|
if(!this.hasBoundTile()){
|
||||||
this.boundPosition = null;
|
this.boundPosition = null;
|
||||||
this.boundWorld = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBoundTile(){
|
public boolean hasBoundTile(){
|
||||||
if(this.boundPosition != null && this.boundWorld != null){
|
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
||||||
if(this.boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ) instanceof TileEntityPhantomface || (this.xCoord == this.boundPosition.posX && this.yCoord == this.boundPosition.posY && this.zCoord == this.boundPosition.posZ && this.worldObj == this.boundWorld)){
|
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;
|
this.boundPosition = null;
|
||||||
this.boundWorld = null;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.boundWorld == this.worldObj;
|
return this.boundPosition.getWorld() == this.worldObj;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -90,10 +87,10 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
public void writeToNBT(NBTTagCompound compound){
|
public void writeToNBT(NBTTagCompound compound){
|
||||||
super.writeToNBT(compound);
|
super.writeToNBT(compound);
|
||||||
if(this.hasBoundTile()){
|
if(this.hasBoundTile()){
|
||||||
compound.setInteger("XCoordOfTileStored", boundPosition.posX);
|
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
|
||||||
compound.setInteger("YCoordOfTileStored", boundPosition.posY);
|
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
|
||||||
compound.setInteger("ZCoordOfTileStored", boundPosition.posZ);
|
compound.setInteger("ZCoordOfTileStored", boundPosition.getZ());
|
||||||
compound.setInteger("WorldOfTileStored", boundWorld.provider.dimensionId);
|
compound.setInteger("WorldOfTileStored", boundPosition.getWorld().provider.dimensionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +100,9 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
int x = compound.getInteger("XCoordOfTileStored");
|
int x = compound.getInteger("XCoordOfTileStored");
|
||||||
int y = compound.getInteger("YCoordOfTileStored");
|
int y = compound.getInteger("YCoordOfTileStored");
|
||||||
int z = compound.getInteger("ZCoordOfTileStored");
|
int z = compound.getInteger("ZCoordOfTileStored");
|
||||||
if(x != 0 && y != 0 && z != 0){
|
World world = DimensionManager.getWorld(compound.getInteger("WorldOfTileStored"));
|
||||||
this.boundPosition = new ChunkCoordinates(x, y, z);
|
if(x != 0 && y != 0 && z != 0 && world != null){
|
||||||
this.boundWorld = DimensionManager.getWorld(compound.getInteger("WorldOfTileStored"));
|
this.boundPosition = new WorldPos(world, x, y, z);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,12 +161,12 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBoundTileInRage(){
|
public boolean isBoundTileInRage(){
|
||||||
return super.isBoundTileInRage() && this.boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ) instanceof IFluidHandler;
|
return super.isBoundTileInRage() && this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IFluidHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IFluidHandler getHandler(){
|
public IFluidHandler getHandler(){
|
||||||
if(this.boundPosition != null && this.boundWorld != null){
|
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
||||||
TileEntity tile = boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ);
|
TileEntity tile = boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||||
if(tile instanceof IFluidHandler) return (IFluidHandler)tile;
|
if(tile instanceof IFluidHandler) return (IFluidHandler)tile;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -219,7 +216,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBoundTileInRage(){
|
public boolean isBoundTileInRage(){
|
||||||
return super.isBoundTileInRage() && (this.boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ) instanceof IEnergyReceiver || this.boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ) instanceof IEnergyProvider);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -250,16 +247,16 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnergyProvider getProvider(){
|
public IEnergyProvider getProvider(){
|
||||||
if(this.boundPosition != null && this.boundWorld != null){
|
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
||||||
TileEntity tile = boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ);
|
TileEntity tile = boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||||
if(tile instanceof IEnergyProvider) return (IEnergyProvider)tile;
|
if(tile instanceof IEnergyProvider) return (IEnergyProvider)tile;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnergyReceiver getReceiver(){
|
public IEnergyReceiver getReceiver(){
|
||||||
if(this.boundPosition != null && this.boundWorld != null){
|
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
||||||
TileEntity tile = boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ);
|
TileEntity tile = boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||||
if(tile instanceof IEnergyReceiver) return (IEnergyReceiver)tile;
|
if(tile instanceof IEnergyReceiver) return (IEnergyReceiver)tile;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -311,8 +308,8 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
public IInventory getInventory(){
|
public IInventory getInventory(){
|
||||||
if(this.boundPosition != null && this.boundWorld != null){
|
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
||||||
TileEntity tile = boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ);
|
TileEntity tile = boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||||
if(tile instanceof IInventory) return (IInventory)tile;
|
if(tile instanceof IInventory) return (IInventory)tile;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -320,7 +317,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBoundTileInRage(){
|
public boolean isBoundTileInRage(){
|
||||||
return super.isBoundTileInRage() && this.boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ) instanceof IInventory;
|
return super.isBoundTileInRage() && this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IInventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISidedInventory getSided(){
|
public ISidedInventory getSided(){
|
||||||
|
|
38
src/main/java/ellpeck/actuallyadditions/util/WorldPos.java
Normal file
38
src/main/java/ellpeck/actuallyadditions/util/WorldPos.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package ellpeck.actuallyadditions.util;
|
||||||
|
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class WorldPos{
|
||||||
|
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int z;
|
||||||
|
private World world;
|
||||||
|
|
||||||
|
public WorldPos(World world, int x, int y, int z){
|
||||||
|
this.world = world;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldPos(int x, int y, int z){
|
||||||
|
this(null, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX(){
|
||||||
|
return this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getY(){
|
||||||
|
return this.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getZ(){
|
||||||
|
return this.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public World getWorld(){
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,6 @@ import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ChunkCoordinates;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraftforge.common.IPlantable;
|
import net.minecraftforge.common.IPlantable;
|
||||||
|
@ -20,9 +19,9 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
public class WorldUtil{
|
public class WorldUtil{
|
||||||
|
|
||||||
public static ChunkCoordinates getCoordsFromSide(ForgeDirection side, int x, int y, int z){
|
public static WorldPos getCoordsFromSide(ForgeDirection side, int x, int y, int z){
|
||||||
if(side == ForgeDirection.UNKNOWN) return null;
|
if(side == ForgeDirection.UNKNOWN) return null;
|
||||||
return new ChunkCoordinates(x+side.offsetX, y+side.offsetY, z+side.offsetZ);
|
return new WorldPos(x+side.offsetX, y+side.offsetY, z+side.offsetZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void breakBlockAtSide(ForgeDirection side, World world, int x, int y, int z){
|
public static void breakBlockAtSide(ForgeDirection side, World world, int x, int y, int z){
|
||||||
|
@ -30,9 +29,9 @@ public class WorldUtil{
|
||||||
world.setBlockToAir(x, y, z);
|
world.setBlockToAir(x, y, z);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ChunkCoordinates c = getCoordsFromSide(side, x, y, z);
|
WorldPos c = getCoordsFromSide(side, x, y, z);
|
||||||
if(c != null){
|
if(c != null){
|
||||||
world.setBlockToAir(c.posX, c.posY, c.posZ);
|
world.setBlockToAir(c.getX(), c.getY(), c.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,9 +103,9 @@ public class WorldUtil{
|
||||||
|
|
||||||
public static boolean dropItemAtSide(ForgeDirection side, World world, int x, int y, int z, ItemStack stack){
|
public static boolean dropItemAtSide(ForgeDirection side, World world, int x, int y, int z, ItemStack stack){
|
||||||
if(side != ForgeDirection.UNKNOWN){
|
if(side != ForgeDirection.UNKNOWN){
|
||||||
ChunkCoordinates coords = getCoordsFromSide(side, x, y, z);
|
WorldPos coords = getCoordsFromSide(side, x, y, z);
|
||||||
if(coords != null){
|
if(coords != null){
|
||||||
EntityItem item = new EntityItem(world, coords.posX+0.5, coords.posY+0.5, coords.posZ+0.5, stack);
|
EntityItem item = new EntityItem(world, coords.getX()+0.5, coords.getY()+0.5, coords.getZ()+0.5, stack);
|
||||||
item.motionX = 0;
|
item.motionX = 0;
|
||||||
item.motionY = 0;
|
item.motionY = 0;
|
||||||
item.motionZ = 0;
|
item.motionZ = 0;
|
||||||
|
@ -117,9 +116,9 @@ public class WorldUtil{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TileEntity getTileEntityFromSide(ForgeDirection side, World world, int x, int y, int z){
|
public static TileEntity getTileEntityFromSide(ForgeDirection side, World world, int x, int y, int z){
|
||||||
ChunkCoordinates c = getCoordsFromSide(side, x, y, z);
|
WorldPos c = getCoordsFromSide(side, x, y, z);
|
||||||
if(c != null){
|
if(c != null){
|
||||||
return world.getTileEntity(c.posX, c.posY, c.posZ);
|
return world.getTileEntity(c.getX(), c.getY(), c.getZ());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue