mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Removed World from WorldPos, renamed it to Position.
That fixed loads of issues.
This commit is contained in:
parent
ed2bbe226a
commit
8b20fc066e
30 changed files with 254 additions and 264 deletions
|
@ -14,7 +14,7 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.blocks.base.BlockBase;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPistonBase;
|
||||
|
@ -85,15 +85,15 @@ public class BlockLampPowerer extends BlockBase{
|
|||
|
||||
private void updateLamp(World world, int x, int y, int z){
|
||||
if(!world.isRemote){
|
||||
WorldPos coords = WorldUtil.getCoordsFromSide(ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)), world, x, y, z, 0);
|
||||
if(coords != null && coords.getBlock() instanceof BlockColoredLamp){
|
||||
Position coords = WorldUtil.getCoordsFromSide(ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)), x, y, z, 0);
|
||||
if(coords != null && coords.getBlock(world) instanceof BlockColoredLamp){
|
||||
if(world.isBlockIndirectlyGettingPowered(x, y, z)){
|
||||
if(!((BlockColoredLamp)coords.getBlock()).isOn){
|
||||
if(!((BlockColoredLamp)coords.getBlock(world)).isOn){
|
||||
world.setBlock(coords.getX(), coords.getY(), coords.getZ(), InitBlocks.blockColoredLampOn, world.getBlockMetadata(coords.getX(), coords.getY(), coords.getZ()), 2);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(((BlockColoredLamp)coords.getBlock()).isOn){
|
||||
if(((BlockColoredLamp)coords.getBlock(world)).isOn){
|
||||
world.setBlock(coords.getX(), coords.getY(), coords.getZ(), InitBlocks.blockColoredLamp, world.getBlockMetadata(coords.getX(), coords.getY(), coords.getZ()), 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,8 +126,8 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
|
|||
minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.GOLD+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc")+": "+phantom.getRange(), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-40, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
if(phantom.hasBoundPosition()){
|
||||
int distance = (int)Vec3.createVectorHelper(posHit.blockX, posHit.blockY, posHit.blockZ).distanceTo(Vec3.createVectorHelper(phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ()));
|
||||
Item item = phantom.getBoundPosition().getItemBlock();
|
||||
String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(phantom.getBoundPosition().getBlock(), 1, phantom.getBoundPosition().getMetadata()));
|
||||
Item item = phantom.getBoundPosition().getItemBlock(minecraft.theWorld);
|
||||
String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(phantom.getBoundPosition().getBlock(minecraft.theWorld), 1, phantom.getBoundPosition().getMetadata(minecraft.theWorld)));
|
||||
StringUtil.drawSplitStringWithShadow(minecraft.fontRenderer, StringUtil.localizeFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-30, 200, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
|
||||
if(phantom.isBoundThingInRange()){
|
||||
|
|
|
@ -14,8 +14,8 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.items.base.ItemEnergy;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.Util;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockGrass;
|
||||
import net.minecraft.block.IGrowable;
|
||||
|
@ -49,7 +49,7 @@ public class ItemGrowthRing extends ItemEnergy{
|
|||
|
||||
int energyUse = 550;
|
||||
if(equipped != null && equipped == stack && this.getEnergyStored(stack) >= energyUse){
|
||||
ArrayList<WorldPos> blocks = new ArrayList<WorldPos>();
|
||||
ArrayList<Position> blocks = new ArrayList<Position>();
|
||||
|
||||
if(stack.stackTagCompound == null){
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
@ -67,7 +67,7 @@ public class ItemGrowthRing extends ItemEnergy{
|
|||
int theZ = MathHelper.floor_double(player.posZ+z);
|
||||
Block theBlock = world.getBlock(theX, theY, theZ);
|
||||
if((theBlock instanceof IGrowable || theBlock instanceof IPlantable) && !(theBlock instanceof BlockGrass)){
|
||||
blocks.add(new WorldPos(world, theX, theY, theZ));
|
||||
blocks.add(new Position(theX, theY, theZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,14 +76,14 @@ public class ItemGrowthRing extends ItemEnergy{
|
|||
//Fertilizing the Blocks
|
||||
if(!blocks.isEmpty()){
|
||||
for(int i = 0; i < 45; i++){
|
||||
WorldPos pos = blocks.get(Util.RANDOM.nextInt(blocks.size()));
|
||||
Position pos = blocks.get(Util.RANDOM.nextInt(blocks.size()));
|
||||
|
||||
int metaBefore = pos.getMetadata();
|
||||
pos.getBlock().updateTick(world, pos.getX(), pos.getY(), pos.getZ(), Util.RANDOM);
|
||||
int metaBefore = pos.getMetadata(world);
|
||||
pos.getBlock(world).updateTick(world, pos.getX(), pos.getY(), pos.getZ(), Util.RANDOM);
|
||||
|
||||
//Show Particles if Metadata changed
|
||||
if(pos.getMetadata() != metaBefore){
|
||||
pos.getWorld().playAuxSFX(2005, pos.getX(), pos.getY(), pos.getZ(), 0);
|
||||
if(pos.getMetadata(world) != metaBefore){
|
||||
world.playAuxSFX(2005, pos.getX(), pos.getY(), pos.getZ(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ import ellpeck.actuallyadditions.items.base.ItemBase;
|
|||
import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityLaserRelay;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -48,13 +48,13 @@ public class ItemLaserWrench extends ItemBase{
|
|||
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".laser.stored.desc")));
|
||||
}
|
||||
else{
|
||||
WorldPos savedPos = ItemPhantomConnector.getStoredPosition(stack);
|
||||
WorldPos otherPos = new WorldPos(world, x, y, z);
|
||||
if(savedPos.getTileEntity() instanceof TileEntityLaserRelay && LaserRelayConnectionHandler.getInstance().addConnection(savedPos, otherPos)){
|
||||
Position savedPos = ItemPhantomConnector.getStoredPosition(stack);
|
||||
Position otherPos = new Position(x, y, z);
|
||||
if(ItemPhantomConnector.getStoredWorld(stack) == world && savedPos.getTileEntity(world) instanceof TileEntityLaserRelay && LaserRelayConnectionHandler.getInstance().addConnection(savedPos, otherPos)){
|
||||
ItemPhantomConnector.clearStorage(stack);
|
||||
|
||||
((TileEntityLaserRelay)savedPos.getTileEntity()).sendUpdate();
|
||||
((TileEntityLaserRelay)otherPos.getTileEntity()).sendUpdate();
|
||||
((TileEntityLaserRelay)savedPos.getTileEntity(world)).sendUpdate();
|
||||
((TileEntityLaserRelay)otherPos.getTileEntity(world)).sendUpdate();
|
||||
|
||||
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".laser.connected.desc")));
|
||||
}
|
||||
|
@ -84,13 +84,12 @@ public class ItemLaserWrench extends ItemBase{
|
|||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
||||
WorldPos coords = ItemPhantomConnector.getStoredPosition(stack);
|
||||
Position coords = ItemPhantomConnector.getStoredPosition(stack);
|
||||
if(coords != null){
|
||||
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".boundTo.desc")+":");
|
||||
list.add("X: "+coords.getX());
|
||||
list.add("Y: "+coords.getY());
|
||||
list.add("Z: "+coords.getZ());
|
||||
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".inWorld.desc")+" "+coords.getWorldID());
|
||||
list.add(EnumChatFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".clearStorage.desc"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
|
||||
import ellpeck.actuallyadditions.items.base.ItemBase;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockBush;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
@ -92,7 +92,7 @@ public class ItemLeafBlower extends ItemBase{
|
|||
* @param z The Z Position of the Player
|
||||
*/
|
||||
public void breakStuff(World world, int x, int y, int z){
|
||||
ArrayList<WorldPos> breakPositions = new ArrayList<WorldPos>();
|
||||
ArrayList<Position> breakPositions = new ArrayList<Position>();
|
||||
|
||||
int rangeSides = 5;
|
||||
int rangeUp = 1;
|
||||
|
@ -102,7 +102,7 @@ public class ItemLeafBlower extends ItemBase{
|
|||
//The current Block to break
|
||||
Block block = world.getBlock(x+reachX, y+reachY, z+reachZ);
|
||||
if(block != null && (block instanceof BlockBush || (this.isAdvanced && block.isLeaves(world, x+reachX, y+reachY, z+reachZ)))){
|
||||
breakPositions.add(new WorldPos(world, x+reachX, y+reachY, z+reachZ));
|
||||
breakPositions.add(new Position(x+reachX, y+reachY, z+reachZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class ItemLeafBlower extends ItemBase{
|
|||
if(!breakPositions.isEmpty()){
|
||||
Collections.shuffle(breakPositions);
|
||||
|
||||
WorldPos theCoord = breakPositions.get(0);
|
||||
Position theCoord = breakPositions.get(0);
|
||||
Block theBlock = world.getBlock(theCoord.getX(), theCoord.getY(), theCoord.getZ());
|
||||
|
||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
|
|
|
@ -16,8 +16,8 @@ import ellpeck.actuallyadditions.items.base.ItemBase;
|
|||
import ellpeck.actuallyadditions.tile.IPhantomTile;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -29,6 +29,7 @@ import net.minecraft.util.ChatComponentText;
|
|||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -47,7 +48,7 @@ public class ItemPhantomConnector extends ItemBase{
|
|||
if(tile != null){
|
||||
//Passing to Phantom
|
||||
if(tile instanceof IPhantomTile){
|
||||
if(this.checkHasConnection(stack, player, tile)){
|
||||
if(this.checkHasConnection(stack, player, tile) && getStoredWorld(stack) == world){
|
||||
((IPhantomTile)tile).setBoundPosition(getStoredPosition(stack));
|
||||
if(tile instanceof TileEntityBase){
|
||||
((TileEntityBase)tile).sendUpdate();
|
||||
|
@ -79,20 +80,27 @@ public class ItemPhantomConnector extends ItemBase{
|
|||
}
|
||||
}
|
||||
|
||||
public static WorldPos getStoredPosition(ItemStack stack){
|
||||
public static Position getStoredPosition(ItemStack stack){
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
if(tag != null){
|
||||
int x = tag.getInteger("XCoordOfTileStored");
|
||||
int y = tag.getInteger("YCoordOfTileStored");
|
||||
int z = tag.getInteger("ZCoordOfTileStored");
|
||||
int world = tag.getInteger("WorldOfTileStored");
|
||||
if(!(x == 0 && y == 0 && z == 0)){
|
||||
return new WorldPos(world, x, y, z);
|
||||
return new Position(x, y, z);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static World getStoredWorld(ItemStack stack){
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
if(tag != null){
|
||||
return DimensionManager.getWorld(tag.getInteger("WorldOfTileStored"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void clearStorage(ItemStack stack){
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
@ -127,13 +135,12 @@ public class ItemPhantomConnector extends ItemBase{
|
|||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
||||
WorldPos coords = getStoredPosition(stack);
|
||||
Position coords = getStoredPosition(stack);
|
||||
if(coords != null){
|
||||
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".boundTo.desc")+":");
|
||||
list.add("X: "+coords.getX());
|
||||
list.add("Y: "+coords.getY());
|
||||
list.add("Z: "+coords.getZ());
|
||||
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".inWorld.desc")+" "+coords.getWorldID());
|
||||
list.add(EnumChatFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".clearStorage.desc"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
package ellpeck.actuallyadditions.items.lens;
|
||||
|
||||
import ellpeck.actuallyadditions.tile.TileEntityAtomicReconstructor;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public abstract class Lens{
|
||||
|
||||
protected Item lensItem;
|
||||
|
||||
public abstract boolean invoke(WorldPos hitBlock, TileEntityAtomicReconstructor tile);
|
||||
public abstract boolean invoke(Position hitBlock, TileEntityAtomicReconstructor tile);
|
||||
|
||||
public abstract float[] getColor();
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ package ellpeck.actuallyadditions.items.lens;
|
|||
|
||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityAtomicReconstructor;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.Util;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -53,15 +53,15 @@ public class LensColor extends Lens{
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean invoke(WorldPos hitBlock, TileEntityAtomicReconstructor tile){
|
||||
public boolean invoke(Position hitBlock, TileEntityAtomicReconstructor tile){
|
||||
if(hitBlock != null){
|
||||
if(Util.arrayContains(CONVERTABLE_BLOCKS, hitBlock.getBlock()) >= 0 && tile.storage.getEnergyStored() >= ENERGY_USE){
|
||||
int meta = hitBlock.getMetadata();
|
||||
if(Util.arrayContains(CONVERTABLE_BLOCKS, hitBlock.getBlock(tile.getWorldObj())) >= 0 && tile.storage.getEnergyStored() >= ENERGY_USE){
|
||||
int meta = hitBlock.getMetadata(tile.getWorldObj());
|
||||
if(meta >= 15){
|
||||
hitBlock.setMetadata(0, 2);
|
||||
hitBlock.setMetadata(tile.getWorldObj(), 0, 2);
|
||||
}
|
||||
else{
|
||||
hitBlock.setMetadata(meta+1, 2);
|
||||
hitBlock.setMetadata(tile.getWorldObj(), meta+1, 2);
|
||||
}
|
||||
tile.storage.extractEnergy(ENERGY_USE, false);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ package ellpeck.actuallyadditions.items.lens;
|
|||
|
||||
import ellpeck.actuallyadditions.misc.DamageSources;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityAtomicReconstructor;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class LensDeath extends Lens{
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean invoke(WorldPos hitBlock, TileEntityAtomicReconstructor tile){
|
||||
public boolean invoke(Position hitBlock, TileEntityAtomicReconstructor tile){
|
||||
int use = 150; //Per Block (because it doesn't only activate when something is hit like the other lenses!)
|
||||
if(tile.storage.getEnergyStored() >= use){
|
||||
tile.storage.extractEnergy(use, false);
|
||||
|
@ -33,7 +33,7 @@ public class LensDeath extends Lens{
|
|||
}
|
||||
}
|
||||
|
||||
return hitBlock != null && !hitBlock.getBlock().isAir(hitBlock.getWorld(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ());
|
||||
return hitBlock != null && !hitBlock.getBlock(tile.getWorldObj()).isAir(tile.getWorldObj(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
package ellpeck.actuallyadditions.items.lens;
|
||||
|
||||
import ellpeck.actuallyadditions.tile.TileEntityAtomicReconstructor;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
|
||||
public class LensDetonation extends Lens{
|
||||
|
||||
@Override
|
||||
public boolean invoke(WorldPos hitBlock, TileEntityAtomicReconstructor tile){
|
||||
if(hitBlock != null && !hitBlock.getBlock().isAir(hitBlock.getWorld(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ())){
|
||||
public boolean invoke(Position hitBlock, TileEntityAtomicReconstructor tile){
|
||||
if(hitBlock != null && !hitBlock.getBlock(tile.getWorldObj()).isAir(tile.getWorldObj(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ())){
|
||||
int use = 500000;
|
||||
if(tile.storage.getEnergyStored() >= use){
|
||||
tile.getWorldObj().newExplosion(null, hitBlock.getX()+0.5, hitBlock.getY()+0.5, hitBlock.getZ()+0.5, 10F, true, true);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
package ellpeck.actuallyadditions.items.lens;
|
||||
|
||||
import ellpeck.actuallyadditions.tile.TileEntityAtomicReconstructor;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
@ -25,24 +25,24 @@ public class LensNone extends Lens{
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean invoke(WorldPos hitBlock, TileEntityAtomicReconstructor tile){
|
||||
if(hitBlock != null && !hitBlock.getBlock().isAir(hitBlock.getWorld(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ())){
|
||||
public boolean invoke(Position hitBlock, TileEntityAtomicReconstructor tile){
|
||||
if(hitBlock != null && !hitBlock.getBlock(tile.getWorldObj()).isAir(tile.getWorldObj(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ())){
|
||||
int range = 2;
|
||||
|
||||
//Converting the Blocks
|
||||
for(int reachX = -range; reachX < range+1; reachX++){
|
||||
for(int reachZ = -range; reachZ < range+1; reachZ++){
|
||||
for(int reachY = -range; reachY < range+1; reachY++){
|
||||
WorldPos pos = new WorldPos(tile.getWorldObj(), hitBlock.getX()+reachX, hitBlock.getY()+reachY, hitBlock.getZ()+reachZ);
|
||||
ArrayList<LensNoneRecipeHandler.Recipe> recipes = LensNoneRecipeHandler.getRecipesFor(new ItemStack(pos.getBlock(), 1, pos.getMetadata()));
|
||||
Position pos = new Position(hitBlock.getX()+reachX, hitBlock.getY()+reachY, hitBlock.getZ()+reachZ);
|
||||
ArrayList<LensNoneRecipeHandler.Recipe> recipes = LensNoneRecipeHandler.getRecipesFor(new ItemStack(pos.getBlock(tile.getWorldObj()), 1, pos.getMetadata(tile.getWorldObj())));
|
||||
for(LensNoneRecipeHandler.Recipe recipe : recipes){
|
||||
if(recipe != null && tile.storage.getEnergyStored() >= recipe.energyUse){
|
||||
List<ItemStack> outputs = recipe.getOutputs();
|
||||
if(outputs != null && !outputs.isEmpty()){
|
||||
ItemStack output = outputs.get(0);
|
||||
if(output.getItem() instanceof ItemBlock){
|
||||
tile.getWorldObj().playAuxSFX(2001, pos.getX(), pos.getY(), pos.getZ(), Block.getIdFromBlock(pos.getBlock())+(pos.getMetadata() << 12));
|
||||
pos.setBlock(Block.getBlockFromItem(output.getItem()), output.getItemDamage(), 2);
|
||||
tile.getWorldObj().playAuxSFX(2001, pos.getX(), pos.getY(), pos.getZ(), Block.getIdFromBlock(pos.getBlock(tile.getWorldObj()))+(pos.getMetadata(tile.getWorldObj()) << 12));
|
||||
pos.setBlock(tile.getWorldObj(), Block.getBlockFromItem(output.getItem()), output.getItemDamage(), 2);
|
||||
}
|
||||
else{
|
||||
EntityItem item = new EntityItem(tile.getWorldObj(), pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, output.copy());
|
||||
|
|
|
@ -13,12 +13,13 @@ package ellpeck.actuallyadditions.misc;
|
|||
import cofh.api.energy.IEnergyReceiver;
|
||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityLaserRelay;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class LaserRelayConnectionHandler{
|
||||
|
@ -60,7 +61,7 @@ public class LaserRelayConnectionHandler{
|
|||
/**
|
||||
* Gets all Connections for a Relay
|
||||
*/
|
||||
public ConcurrentSet<ConnectionPair> getConnectionsFor(WorldPos relay){
|
||||
public ConcurrentSet<ConnectionPair> getConnectionsFor(Position relay){
|
||||
ConcurrentSet<ConnectionPair> allPairs = new ConcurrentSet<ConnectionPair>();
|
||||
for(Network aNetwork : this.networks){
|
||||
for(ConnectionPair pair : aNetwork.connections){
|
||||
|
@ -75,7 +76,7 @@ public class LaserRelayConnectionHandler{
|
|||
/**
|
||||
* Removes a Relay from its Network
|
||||
*/
|
||||
public void removeRelayFromNetwork(WorldPos relay){
|
||||
public void removeRelayFromNetwork(Position relay){
|
||||
Network network = this.getNetworkFor(relay);
|
||||
if(network != null){
|
||||
//Setup new network (so that splitting a network will cause it to break into two)
|
||||
|
@ -93,7 +94,7 @@ public class LaserRelayConnectionHandler{
|
|||
/**
|
||||
* Gets a Network for a Relay
|
||||
*/
|
||||
public Network getNetworkFor(WorldPos relay){
|
||||
public Network getNetworkFor(Position relay){
|
||||
for(Network aNetwork : this.networks){
|
||||
for(ConnectionPair pair : aNetwork.connections){
|
||||
if(pair.contains(relay)){
|
||||
|
@ -108,9 +109,9 @@ public class LaserRelayConnectionHandler{
|
|||
* Adds a new connection between two relays
|
||||
* (Puts it into the correct network!)
|
||||
*/
|
||||
public boolean addConnection(WorldPos firstRelay, WorldPos secondRelay){
|
||||
public boolean addConnection(Position firstRelay, Position secondRelay){
|
||||
int distance = (int)firstRelay.toVec().distanceTo(secondRelay.toVec());
|
||||
if(distance > TileEntityLaserRelay.MAX_DISTANCE || firstRelay.isEqual(secondRelay) || firstRelay.getWorld() != secondRelay.getWorld()){
|
||||
if(distance > TileEntityLaserRelay.MAX_DISTANCE || firstRelay.isEqual(secondRelay)){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -160,21 +161,21 @@ public class LaserRelayConnectionHandler{
|
|||
//System.out.println("Merged Two Networks!");
|
||||
}
|
||||
|
||||
public int transferEnergyToReceiverInNeed(WorldPos energyGottenFrom, Network network, int maxTransfer, boolean simulate){
|
||||
public int transferEnergyToReceiverInNeed(World world, Position energyGottenFrom, Network network, int maxTransfer, boolean simulate){
|
||||
int transmitted = 0;
|
||||
//Go through all of the connections in the network
|
||||
for(ConnectionPair pair : network.connections){
|
||||
WorldPos[] relays = new WorldPos[]{pair.firstRelay, pair.secondRelay};
|
||||
Position[] relays = new Position[]{pair.firstRelay, pair.secondRelay};
|
||||
//Go through both relays in the connection
|
||||
for(WorldPos relay : relays){
|
||||
for(Position relay : relays){
|
||||
if(relay != null){
|
||||
//Get every side of the relay
|
||||
for(int i = 0; i <= 5; i++){
|
||||
ForgeDirection side = ForgeDirection.getOrientation(i);
|
||||
//Get the Position at the side
|
||||
WorldPos pos = WorldUtil.getCoordsFromSide(side, relay.getWorld(), relay.getX(), relay.getY(), relay.getZ(), 0);
|
||||
Position pos = WorldUtil.getCoordsFromSide(side, relay.getX(), relay.getY(), relay.getZ(), 0);
|
||||
if(!pos.isEqual(energyGottenFrom)){
|
||||
TileEntity tile = pos.getTileEntity();
|
||||
TileEntity tile = pos.getTileEntity(world);
|
||||
if(tile instanceof IEnergyReceiver && !(tile instanceof TileEntityLaserRelay)){
|
||||
IEnergyReceiver receiver = (IEnergyReceiver)tile;
|
||||
if(receiver.canConnectEnergy(side.getOpposite())){
|
||||
|
@ -202,26 +203,29 @@ public class LaserRelayConnectionHandler{
|
|||
|
||||
public static class ConnectionPair{
|
||||
|
||||
public WorldPos firstRelay;
|
||||
public WorldPos secondRelay;
|
||||
public Position firstRelay;
|
||||
public Position secondRelay;
|
||||
|
||||
public ConnectionPair(WorldPos firstRelay, WorldPos secondRelay){
|
||||
public ConnectionPair(Position firstRelay, Position secondRelay){
|
||||
this.firstRelay = firstRelay;
|
||||
this.secondRelay = secondRelay;
|
||||
}
|
||||
|
||||
public static ConnectionPair readFromNBT(NBTTagCompound compound){
|
||||
WorldPos[] pos = new WorldPos[2];
|
||||
for(int i = 0; i < pos.length; i++){
|
||||
int anX = compound.getInteger("x"+i);
|
||||
int aY = compound.getInteger("y"+i);
|
||||
int aZ = compound.getInteger("z"+i);
|
||||
pos[i] = new WorldPos(compound.getInteger("world"+i), anX, aY, aZ);
|
||||
if(compound != null){
|
||||
Position[] pos = new Position[2];
|
||||
for(int i = 0; i < pos.length; i++){
|
||||
int anX = compound.getInteger("x"+i);
|
||||
int aY = compound.getInteger("y"+i);
|
||||
int aZ = compound.getInteger("z"+i);
|
||||
pos[i] = new Position(anX, aY, aZ);
|
||||
}
|
||||
return new ConnectionPair(pos[0], pos[1]);
|
||||
}
|
||||
return new ConnectionPair(pos[0], pos[1]);
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean contains(WorldPos relay){
|
||||
public boolean contains(Position relay){
|
||||
return (this.firstRelay != null && this.firstRelay.isEqual(relay)) || (this.secondRelay != null && this.secondRelay.isEqual(relay));
|
||||
}
|
||||
|
||||
|
@ -233,8 +237,7 @@ public class LaserRelayConnectionHandler{
|
|||
public NBTTagCompound writeToNBT(){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
for(int i = 0; i < 2; i++){
|
||||
WorldPos relay = i == 0 ? this.firstRelay : this.secondRelay;
|
||||
compound.setInteger("world"+i, relay.getWorldID());
|
||||
Position relay = i == 0 ? this.firstRelay : this.secondRelay;
|
||||
compound.setInteger("x"+i, relay.getX());
|
||||
compound.setInteger("y"+i, relay.getY());
|
||||
compound.setInteger("z"+i, relay.getZ());
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
package ellpeck.actuallyadditions.tile;
|
||||
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
|
||||
public interface IPhantomTile{
|
||||
|
||||
|
@ -27,9 +27,9 @@ public interface IPhantomTile{
|
|||
/**
|
||||
* @return The position this tile is bound to
|
||||
*/
|
||||
WorldPos getBoundPosition();
|
||||
Position getBoundPosition();
|
||||
|
||||
void setBoundPosition(WorldPos pos);
|
||||
void setBoundPosition(Position pos);
|
||||
|
||||
/**
|
||||
* @return The ID of the GUI it opens, -1 if none
|
||||
|
|
|
@ -21,7 +21,7 @@ import ellpeck.actuallyadditions.items.lens.Lenses;
|
|||
import ellpeck.actuallyadditions.network.PacketHandler;
|
||||
import ellpeck.actuallyadditions.network.PacketParticle;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -73,7 +73,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
|||
Lens currentLens = this.getCurrentLens();
|
||||
int distance = currentLens.getDistance();
|
||||
for(int i = 0; i < distance; i++){
|
||||
WorldPos hitBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, i);
|
||||
Position hitBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord, i);
|
||||
|
||||
if(currentLens.invoke(hitBlock, this)){
|
||||
this.shootLaser(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
package ellpeck.actuallyadditions.tile;
|
||||
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockAir;
|
||||
|
@ -69,7 +69,7 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst
|
|||
private void doWork(){
|
||||
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
|
||||
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, 0);
|
||||
Position coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord, 0);
|
||||
if(coordsBlock != null){
|
||||
Block blockToBreak = worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
|
||||
if(!this.isPlacer && blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) > -1.0F){
|
||||
|
|
|
@ -14,7 +14,7 @@ import cofh.api.energy.EnergyStorage;
|
|||
import cofh.api.energy.IEnergyReceiver;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockAir;
|
||||
|
@ -66,7 +66,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
|||
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
|
||||
for(int i = 0; i < RANGE; i++){
|
||||
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, i);
|
||||
Position coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord, i);
|
||||
if(coordsBlock != null){
|
||||
Block blockToBreak = worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
|
||||
if(blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) > -1.0F){
|
||||
|
|
|
@ -12,7 +12,7 @@ package ellpeck.actuallyadditions.tile;
|
|||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -56,7 +56,7 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
|
|||
private void doWork(){
|
||||
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
|
||||
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, 0);
|
||||
Position coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord, 0);
|
||||
if(coordsBlock != null){
|
||||
Block blockToBreak = worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
|
||||
if(!this.isPlacer && blockToBreak != null && worldObj.getBlockMetadata(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) == 0 && FluidContainerRegistry.BUCKET_VOLUME <= this.tank.getCapacity()-this.tank.getFluidAmount()){
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
package ellpeck.actuallyadditions.tile;
|
||||
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.Util;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockGrass;
|
||||
import net.minecraft.block.IGrowable;
|
||||
|
@ -30,12 +30,12 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{
|
|||
if(this.timeUntilNextFert > 0){
|
||||
this.timeUntilNextFert--;
|
||||
if(timeUntilNextFert <= 0){
|
||||
WorldPos blockToFert = this.blockToFertilize();
|
||||
Position blockToFert = this.blockToFertilize();
|
||||
if(blockToFert != null){
|
||||
int metaBefore = blockToFert.getMetadata();
|
||||
int metaBefore = blockToFert.getMetadata(worldObj);
|
||||
worldObj.getBlock(blockToFert.getX(), blockToFert.getY(), blockToFert.getZ()).updateTick(worldObj, blockToFert.getX(), blockToFert.getY(), blockToFert.getZ(), Util.RANDOM);
|
||||
|
||||
if(blockToFert.getMetadata() != metaBefore){
|
||||
if(blockToFert.getMetadata(worldObj) != metaBefore){
|
||||
worldObj.playAuxSFX(2005, blockToFert.getX(), blockToFert.getY(), blockToFert.getZ(), 0);
|
||||
}
|
||||
}
|
||||
|
@ -49,12 +49,12 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{
|
|||
}
|
||||
}
|
||||
|
||||
public WorldPos blockToFertilize(){
|
||||
public Position blockToFertilize(){
|
||||
for(int i = yCoord-1; i > 0; i--){
|
||||
Block block = worldObj.getBlock(xCoord, i, zCoord);
|
||||
if(block != null && !(worldObj.isAirBlock(xCoord, i, zCoord))){
|
||||
if((block instanceof IGrowable || block instanceof IPlantable) && !(block instanceof BlockGrass)){
|
||||
return new WorldPos(worldObj, xCoord, i, zCoord);
|
||||
return new Position(xCoord, i, zCoord);
|
||||
}
|
||||
else{
|
||||
return null;
|
||||
|
|
|
@ -14,8 +14,8 @@ import cofh.api.energy.EnergyStorage;
|
|||
import cofh.api.energy.IEnergyProvider;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.Util;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -38,7 +38,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
|
|||
ArrayList<Integer> blocksAround = new ArrayList<Integer>();
|
||||
if(ENERGY_PRODUCE <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){
|
||||
for(int i = 1; i <= 5; i++){
|
||||
WorldPos coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionBySidesInOrder(i), worldObj, xCoord, yCoord, zCoord, 0);
|
||||
Position coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionBySidesInOrder(i), xCoord, yCoord, zCoord, 0);
|
||||
if(coords != null){
|
||||
Block block = worldObj.getBlock(coords.getX(), coords.getY(), coords.getZ());
|
||||
if(block != null && block.getMaterial() == Material.lava && worldObj.getBlockMetadata(coords.getX(), coords.getY(), coords.getZ()) == 0){
|
||||
|
|
|
@ -17,8 +17,8 @@ import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
|
|||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||
import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler;
|
||||
import ellpeck.actuallyadditions.network.PacketParticle;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.Util;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -44,7 +44,7 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void renderParticles(){
|
||||
if(Util.RANDOM.nextInt(2) == 0){
|
||||
WorldPos thisPos = new WorldPos(this.getWorldObj(), this.xCoord, this.yCoord, this.zCoord);
|
||||
Position thisPos = new Position(this.xCoord, this.yCoord, this.zCoord);
|
||||
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(thisPos);
|
||||
if(network != null){
|
||||
for(LaserRelayConnectionHandler.ConnectionPair aPair : network.connections){
|
||||
|
@ -60,7 +60,7 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
|||
public Packet getDescriptionPacket(){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
|
||||
WorldPos thisPos = new WorldPos(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
Position thisPos = new Position(this.xCoord, this.yCoord, this.zCoord);
|
||||
ConcurrentSet<LaserRelayConnectionHandler.ConnectionPair> connections = LaserRelayConnectionHandler.getInstance().getConnectionsFor(thisPos);
|
||||
|
||||
if(connections != null){
|
||||
|
@ -76,7 +76,7 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
|||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){
|
||||
WorldPos thisPos = new WorldPos(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
Position thisPos = new Position(this.xCoord, this.yCoord, this.zCoord);
|
||||
if(pkt != null && pkt.func_148857_g() != null){
|
||||
LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(thisPos);
|
||||
|
||||
|
@ -94,12 +94,12 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
|||
@Override
|
||||
public void invalidate(){
|
||||
super.invalidate();
|
||||
LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(new WorldPos(this.worldObj, this.xCoord, this.yCoord, this.zCoord));
|
||||
LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(new Position(this.xCoord, this.yCoord, this.zCoord));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){
|
||||
return this.transmitEnergy(WorldUtil.getCoordsFromSide(from, worldObj, xCoord, yCoord, zCoord, 0), maxReceive, simulate);
|
||||
return this.transmitEnergy(WorldUtil.getCoordsFromSide(from, xCoord, yCoord, zCoord, 0), maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -112,12 +112,12 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
|||
return 0;
|
||||
}
|
||||
|
||||
public int transmitEnergy(WorldPos blockFrom, int maxTransmit, boolean simulate){
|
||||
public int transmitEnergy(Position blockFrom, int maxTransmit, boolean simulate){
|
||||
int transmitted = 0;
|
||||
if(maxTransmit > 0){
|
||||
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(new WorldPos(this.worldObj, this.xCoord, this.yCoord, this.zCoord));
|
||||
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(new Position(this.xCoord, this.yCoord, this.zCoord));
|
||||
if(network != null){
|
||||
transmitted = LaserRelayConnectionHandler.getInstance().transferEnergyToReceiverInNeed(blockFrom, network, Math.min(ConfigIntValues.LASER_RELAY_MAX_TRANSFER.getValue(), maxTransmit), simulate);
|
||||
transmitted = LaserRelayConnectionHandler.getInstance().transferEnergyToReceiverInNeed(worldObj, blockFrom, network, Math.min(ConfigIntValues.LASER_RELAY_MAX_TRANSFER.getValue(), maxTransmit), simulate);
|
||||
}
|
||||
}
|
||||
return transmitted;
|
||||
|
|
|
@ -17,7 +17,7 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.network.PacketHandler;
|
||||
import ellpeck.actuallyadditions.network.PacketParticle;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -45,14 +45,14 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
|
|||
this.nextUseCounter = 0;
|
||||
|
||||
if(ENERGY_PRODUCED <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){
|
||||
ArrayList<WorldPos> breakPositions = new ArrayList<WorldPos>();
|
||||
ArrayList<Position> breakPositions = new ArrayList<Position>();
|
||||
|
||||
for(int reachX = -RANGE; reachX < RANGE+1; reachX++){
|
||||
for(int reachZ = -RANGE; reachZ < RANGE+1; reachZ++){
|
||||
for(int reachY = -RANGE; reachY < RANGE+1; reachY++){
|
||||
Block block = this.worldObj.getBlock(this.xCoord+reachX, this.yCoord+reachY, this.zCoord+reachZ);
|
||||
if(block != null && block.isLeaves(this.worldObj, this.xCoord+reachX, this.yCoord+reachY, this.zCoord+reachZ)){
|
||||
breakPositions.add(new WorldPos(this.worldObj, this.xCoord+reachX, this.yCoord+reachY, this.zCoord+reachZ));
|
||||
breakPositions.add(new Position(this.xCoord+reachX, this.yCoord+reachY, this.zCoord+reachZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
|
|||
|
||||
if(!breakPositions.isEmpty()){
|
||||
Collections.shuffle(breakPositions);
|
||||
WorldPos theCoord = breakPositions.get(0);
|
||||
Position theCoord = breakPositions.get(0);
|
||||
|
||||
Block theBlock = this.worldObj.getBlock(theCoord.getX(), theCoord.getY(), theCoord.getZ());
|
||||
int meta = this.worldObj.getBlockMetadata(theCoord.getX(), theCoord.getY(), theCoord.getZ());
|
||||
|
|
|
@ -62,8 +62,8 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
|
|||
}
|
||||
|
||||
public IEnergyProvider getProvider(){
|
||||
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
||||
TileEntity tile = boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
if(this.boundPosition != null){
|
||||
TileEntity tile = worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
if(tile instanceof IEnergyProvider){
|
||||
return (IEnergyProvider)tile;
|
||||
}
|
||||
|
@ -72,8 +72,8 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
|
|||
}
|
||||
|
||||
public IEnergyReceiver getReceiver(){
|
||||
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
||||
TileEntity tile = boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
if(this.boundPosition != null){
|
||||
TileEntity tile = worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
if(tile instanceof IEnergyReceiver){
|
||||
return (IEnergyReceiver)tile;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
|
|||
|
||||
@Override
|
||||
public boolean isBoundThingInRange(){
|
||||
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);
|
||||
return super.isBoundThingInRange() && (worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IEnergyReceiver || worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IEnergyProvider);
|
||||
}
|
||||
|
||||
private void pushEnergy(ForgeDirection side){
|
||||
|
|
|
@ -80,7 +80,7 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface{
|
|||
|
||||
@Override
|
||||
public boolean isBoundThingInRange(){
|
||||
return super.isBoundThingInRange() && this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IInventory;
|
||||
return super.isBoundThingInRange() && worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IInventory;
|
||||
}
|
||||
|
||||
public ISidedInventory getSided(){
|
||||
|
@ -88,8 +88,8 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface{
|
|||
}
|
||||
|
||||
public IInventory getInventory(){
|
||||
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
||||
TileEntity tile = boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
if(this.boundPosition != null){
|
||||
TileEntity tile = worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
if(tile instanceof IInventory){
|
||||
return (IInventory)tile;
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
|||
}
|
||||
|
||||
public IFluidHandler getHandler(){
|
||||
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
|
||||
TileEntity tile = boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
if(this.boundPosition != null){
|
||||
TileEntity tile = worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
if(tile instanceof IFluidHandler){
|
||||
return (IFluidHandler)tile;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
|||
|
||||
@Override
|
||||
public boolean isBoundThingInRange(){
|
||||
return super.isBoundThingInRange() && this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IFluidHandler;
|
||||
return super.isBoundThingInRange() && worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IFluidHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,8 +14,8 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
||||
import ellpeck.actuallyadditions.network.PacketParticle;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.Util;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -28,7 +28,7 @@ import java.util.ArrayList;
|
|||
public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements IPhantomTile, IRedstoneToggle{
|
||||
|
||||
public static final int RANGE = 3;
|
||||
public WorldPos boundPosition;
|
||||
public Position boundPosition;
|
||||
public int currentTime;
|
||||
public int range;
|
||||
public boolean isBreaker;
|
||||
|
@ -83,36 +83,36 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
|||
|
||||
@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.provider.dimensionId == this.boundPosition.getWorld().provider.dimensionId)){
|
||||
if(this.boundPosition != null){
|
||||
if(this.worldObj.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.provider.dimensionId == this.worldObj.provider.dimensionId)){
|
||||
this.boundPosition = null;
|
||||
return false;
|
||||
}
|
||||
return this.worldObj.provider.dimensionId == this.boundPosition.getWorld().provider.dimensionId;
|
||||
return this.worldObj.provider.dimensionId == this.worldObj.provider.dimensionId;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void doWork(){
|
||||
if(this.isBreaker){
|
||||
Block blockToBreak = boundPosition.getWorld().getBlock(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
if(blockToBreak != null && blockToBreak.getBlockHardness(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) > -1.0F){
|
||||
Block blockToBreak = worldObj.getBlock(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
if(blockToBreak != null && blockToBreak.getBlockHardness(worldObj, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) > -1.0F){
|
||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
int meta = boundPosition.getWorld().getBlockMetadata(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
drops.addAll(blockToBreak.getDrops(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), meta, 0));
|
||||
int meta = worldObj.getBlockMetadata(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
drops.addAll(blockToBreak.getDrops(worldObj, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), meta, 0));
|
||||
|
||||
if(WorldUtil.addToInventory(this, drops, false)){
|
||||
boundPosition.getWorld().playAuxSFX(2001, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), Block.getIdFromBlock(blockToBreak)+(meta << 12));
|
||||
WorldUtil.breakBlockAtSide(ForgeDirection.UNKNOWN, boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
worldObj.playAuxSFX(2001, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), Block.getIdFromBlock(blockToBreak)+(meta << 12));
|
||||
WorldUtil.breakBlockAtSide(ForgeDirection.UNKNOWN, worldObj, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
WorldUtil.addToInventory(this, drops, true);
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(boundPosition.getWorld().getBlock(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()).isReplaceable(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ())){
|
||||
if(worldObj.getBlock(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()).isReplaceable(worldObj, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ())){
|
||||
int theSlot = WorldUtil.findFirstFilledSlot(this.slots);
|
||||
this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(ForgeDirection.UNKNOWN, boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), this.slots[theSlot]));
|
||||
this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(ForgeDirection.UNKNOWN, worldObj, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), this.slots[theSlot]));
|
||||
if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0){
|
||||
this.slots[theSlot] = null;
|
||||
}
|
||||
|
@ -145,12 +145,12 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public WorldPos getBoundPosition(){
|
||||
public Position getBoundPosition(){
|
||||
return this.boundPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoundPosition(WorldPos pos){
|
||||
public void setBoundPosition(Position pos){
|
||||
this.boundPosition = pos == null ? null : pos.copy();
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,6 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
|||
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
|
||||
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
|
||||
compound.setInteger("ZCoordOfTileStored", boundPosition.getZ());
|
||||
compound.setInteger("WorldOfTileStored", boundPosition.getWorld().provider.dimensionId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,10 +181,9 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
|||
int x = compound.getInteger("XCoordOfTileStored");
|
||||
int y = compound.getInteger("YCoordOfTileStored");
|
||||
int z = compound.getInteger("ZCoordOfTileStored");
|
||||
int world = compound.getInteger("WorldOfTileStored");
|
||||
this.range = compound.getInteger("Range");
|
||||
if(!(x == 0 && y == 0 && z == 0)){
|
||||
this.boundPosition = new WorldPos(world, x, y, z);
|
||||
this.boundPosition = new Position(x, y, z);
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import ellpeck.actuallyadditions.blocks.BlockPhantom;
|
||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||
import ellpeck.actuallyadditions.network.PacketParticle;
|
||||
import ellpeck.actuallyadditions.util.Position;
|
||||
import ellpeck.actuallyadditions.util.Util;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -27,11 +27,11 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
|
||||
public static final int RANGE = 16;
|
||||
public static final float[] COLORS = new float[]{93F/255F, 43F/255F, 181F/255F};
|
||||
public WorldPos boundPosition;
|
||||
public Position boundPosition;
|
||||
public BlockPhantom.Type type;
|
||||
public int range;
|
||||
private int rangeBefore;
|
||||
private WorldPos boundPosBefore;
|
||||
private Position boundPosBefore;
|
||||
private Block boundBlockBefore;
|
||||
|
||||
public TileEntityPhantomface(String name){
|
||||
|
@ -48,10 +48,10 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
this.boundPosition = null;
|
||||
}
|
||||
|
||||
if(this.boundPosition != this.boundPosBefore || (this.boundPosition != null && this.boundPosition.getBlock() != this.boundBlockBefore) || this.rangeBefore != this.range){
|
||||
if(this.boundPosition != this.boundPosBefore || (this.boundPosition != null && this.boundPosition.getBlock(worldObj) != this.boundBlockBefore) || this.rangeBefore != this.range){
|
||||
this.rangeBefore = this.range;
|
||||
this.boundPosBefore = this.boundPosition;
|
||||
this.boundBlockBefore = this.boundPosition == null ? null : this.boundPosition.getBlock();
|
||||
this.boundBlockBefore = this.boundPosition == null ? null : this.boundPosition.getBlock(worldObj);
|
||||
|
||||
this.getWorldObj().markBlockForUpdate(this.xCoord+1, this.yCoord, this.zCoord);
|
||||
this.getWorldObj().markBlockForUpdate(this.xCoord-1, this.yCoord, this.zCoord);
|
||||
|
@ -78,7 +78,6 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
|
||||
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
|
||||
compound.setInteger("ZCoordOfTileStored", boundPosition.getZ());
|
||||
compound.setInteger("WorldOfTileStored", boundPosition.getWorld().provider.dimensionId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +90,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
int world = compound.getInteger("WorldOfTileStored");
|
||||
this.range = compound.getInteger("Range");
|
||||
if(!(x == 0 && y == 0 && z == 0)){
|
||||
this.boundPosition = new WorldPos(world, x, y, z);
|
||||
this.boundPosition = new Position(x, y, z);
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
|
@ -112,12 +111,12 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
|
||||
@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.provider.dimensionId == this.boundPosition.getWorld().provider.dimensionId)){
|
||||
if(this.boundPosition != null){
|
||||
if(worldObj.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.boundPosition = null;
|
||||
return false;
|
||||
}
|
||||
return this.worldObj.provider.dimensionId == this.boundPosition.getWorld().provider.dimensionId;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -147,12 +146,12 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
}
|
||||
|
||||
@Override
|
||||
public WorldPos getBoundPosition(){
|
||||
public Position getBoundPosition(){
|
||||
return this.boundPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoundPosition(WorldPos pos){
|
||||
public void setBoundPosition(Position pos){
|
||||
this.boundPosition = pos == null ? null : pos.copy();
|
||||
}
|
||||
|
||||
|
|
91
src/main/java/ellpeck/actuallyadditions/util/Position.java
Normal file
91
src/main/java/ellpeck/actuallyadditions/util/Position.java
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* This file ("WorldPos.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.util;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Position{
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
public Position(int x, int y, int z){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public TileEntity getTileEntity(World world){
|
||||
return world != null ? world.getTileEntity(this.x, this.y, this.z) : null;
|
||||
}
|
||||
|
||||
public Material getMaterial(World world){
|
||||
return world != null ? world.getBlock(this.x, this.y, this.z).getMaterial() : null;
|
||||
}
|
||||
|
||||
public Item getItemBlock(World world){
|
||||
return world != null ? Item.getItemFromBlock(this.getBlock(world)) : null;
|
||||
}
|
||||
|
||||
public Block getBlock(World world){
|
||||
return world != null ? world.getBlock(this.x, this.y, this.z) : null;
|
||||
}
|
||||
|
||||
public int getMetadata(World world){
|
||||
return world != null ? world.getBlockMetadata(this.x, this.y, this.z) : 0;
|
||||
}
|
||||
|
||||
public void setMetadata(World world, int meta, int flag){
|
||||
if(world != null){
|
||||
world.setBlockMetadataWithNotify(this.x, this.y, this.z, meta, flag);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEqual(Position pos){
|
||||
return pos != null && this.x == pos.getX() && this.y == pos.getY() && this.z == pos.getZ();
|
||||
}
|
||||
|
||||
public int getX(){
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY(){
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getZ(){
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public void setBlock(World world, Block block, int meta, int flag){
|
||||
if(world != null){
|
||||
world.setBlock(this.x, this.y, this.z, block, meta, flag);
|
||||
}
|
||||
}
|
||||
|
||||
public Position copy(){
|
||||
return new Position(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "["+this.x+", "+this.y+", "+this.z+"]";
|
||||
}
|
||||
|
||||
public Vec3 toVec(){
|
||||
return Vec3.createVectorHelper(this.x, this.y, this.z);
|
||||
}
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
* This file ("WorldPos.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.util;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
public class WorldPos{
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private int worldID;
|
||||
|
||||
public WorldPos(World world, int x, int y, int z){
|
||||
this(world.provider.dimensionId, x, y, z);
|
||||
}
|
||||
|
||||
public WorldPos(int worldID, int x, int y, int z){
|
||||
this.worldID = worldID;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public int getWorldID(){
|
||||
return this.worldID;
|
||||
}
|
||||
|
||||
public TileEntity getTileEntity(){
|
||||
return this.getWorld() != null ? this.getWorld().getTileEntity(this.x, this.y, this.z) : null;
|
||||
}
|
||||
|
||||
public World getWorld(){
|
||||
return DimensionManager.getWorld(this.worldID);
|
||||
}
|
||||
|
||||
public Material getMaterial(){
|
||||
return this.getWorld() != null ? this.getWorld().getBlock(this.x, this.y, this.z).getMaterial() : null;
|
||||
}
|
||||
|
||||
public Item getItemBlock(){
|
||||
return this.getWorld() != null ? Item.getItemFromBlock(this.getBlock()) : null;
|
||||
}
|
||||
|
||||
public Block getBlock(){
|
||||
return this.getWorld() != null ? this.getWorld().getBlock(this.x, this.y, this.z) : null;
|
||||
}
|
||||
|
||||
public int getMetadata(){
|
||||
return this.getWorld() != null ? this.getWorld().getBlockMetadata(this.x, this.y, this.z) : 0;
|
||||
}
|
||||
|
||||
public void setMetadata(int meta, int flag){
|
||||
if(this.getWorld() != null){
|
||||
this.getWorld().setBlockMetadataWithNotify(this.x, this.y, this.z, meta, flag);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEqual(WorldPos pos){
|
||||
return pos != null && this.x == pos.getX() && this.y == pos.getY() && this.z == pos.getZ() && this.getWorld() == pos.getWorld();
|
||||
}
|
||||
|
||||
public int getX(){
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY(){
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getZ(){
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public void setBlock(Block block, int meta, int flag){
|
||||
if(this.getWorld() != null){
|
||||
this.getWorld().setBlock(this.x, this.y, this.z, block, meta, flag);
|
||||
}
|
||||
}
|
||||
|
||||
public WorldPos copy(){
|
||||
return new WorldPos(this.getWorld(), this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "["+this.x+", "+this.y+", "+this.z+" in world "+this.worldID+"]";
|
||||
}
|
||||
|
||||
public Vec3 toVec(){
|
||||
return Vec3.createVectorHelper(this.x, this.y, this.z);
|
||||
}
|
||||
}
|
|
@ -61,17 +61,17 @@ public class WorldUtil{
|
|||
world.setBlockToAir(x, y, z);
|
||||
return;
|
||||
}
|
||||
WorldPos c = getCoordsFromSide(side, world, x, y, z, offset);
|
||||
Position c = getCoordsFromSide(side, x, y, z, offset);
|
||||
if(c != null){
|
||||
world.setBlockToAir(c.getX(), c.getY(), c.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
public static WorldPos getCoordsFromSide(ForgeDirection side, World world, int x, int y, int z, int offset){
|
||||
public static Position getCoordsFromSide(ForgeDirection side, int x, int y, int z, int offset){
|
||||
if(side == ForgeDirection.UNKNOWN){
|
||||
return null;
|
||||
}
|
||||
return new WorldPos(world, x+side.offsetX*(offset+1), y+side.offsetY*(offset+1), z+side.offsetZ*(offset+1));
|
||||
return new Position(x+side.offsetX*(offset+1), y+side.offsetY*(offset+1), z+side.offsetZ*(offset+1));
|
||||
}
|
||||
|
||||
public static void pushEnergy(World world, int x, int y, int z, ForgeDirection side, EnergyStorage storage){
|
||||
|
@ -85,7 +85,7 @@ public class WorldUtil{
|
|||
}
|
||||
|
||||
public static TileEntity getTileEntityFromSide(ForgeDirection side, World world, int x, int y, int z){
|
||||
WorldPos c = getCoordsFromSide(side, world, x, y, z, 0);
|
||||
Position c = getCoordsFromSide(side, x, y, z, 0);
|
||||
if(c != null){
|
||||
return world.getTileEntity(c.getX(), c.getY(), c.getZ());
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public class WorldUtil{
|
|||
|
||||
public static boolean dropItemAtSide(ForgeDirection side, World world, int x, int y, int z, ItemStack stack){
|
||||
if(side != ForgeDirection.UNKNOWN){
|
||||
WorldPos coords = getCoordsFromSide(side, world, x, y, z, 0);
|
||||
Position coords = getCoordsFromSide(side, x, y, z, 0);
|
||||
if(coords != null){
|
||||
EntityItem item = new EntityItem(world, coords.getX()+0.5, coords.getY()+0.5, coords.getZ()+0.5, stack);
|
||||
item.motionX = 0;
|
||||
|
|
|
@ -330,7 +330,6 @@ tooltip.actuallyadditions.onSuffix.desc=On
|
|||
tooltip.actuallyadditions.phantom.connected.desc=<Block connected!>
|
||||
tooltip.actuallyadditions.phantom.stored.desc=<Block stored to this Connector!>
|
||||
tooltip.actuallyadditions.phantom.unbound.desc=The Connection was cleared!
|
||||
tooltip.actuallyadditions.inWorld.desc=In World
|
||||
tooltip.actuallyadditions.boundTo.desc=Bound to
|
||||
tooltip.actuallyadditions.clearStorage.desc=Place in Crafting Grid to clear storage!
|
||||
tooltip.actuallyadditions.phantom.connectedRange.desc=The Connection is fine and working.
|
||||
|
|
Loading…
Reference in a new issue