mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Remove Position.
Don't need it.
This commit is contained in:
parent
6ee039fcc2
commit
f602eccca0
96 changed files with 604 additions and 658 deletions
|
@ -1,115 +0,0 @@
|
||||||
/*
|
|
||||||
* This file ("Position.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://ellpeck.de/actaddlicense/
|
|
||||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
||||||
*
|
|
||||||
* © 2016 Ellpeck
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.api;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.BlockPos;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.util.Vec3;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This utility class describes a position in the world
|
|
||||||
*/
|
|
||||||
public class Position extends BlockPos{
|
|
||||||
|
|
||||||
public Position(int x, int y, int z){
|
|
||||||
super(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntity getTileEntity(IBlockAccess world){
|
|
||||||
return world != null ? world.getTileEntity(this) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material getMaterial(IBlockAccess world){
|
|
||||||
if(world != null){
|
|
||||||
Block block = this.getBlock(world);
|
|
||||||
if(block != null){
|
|
||||||
return block.getMaterial();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Item getItemBlock(IBlockAccess world){
|
|
||||||
return world != null ? Item.getItemFromBlock(this.getBlock(world)) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block getBlock(IBlockAccess world){
|
|
||||||
if(world != null){
|
|
||||||
IBlockState state = this.getBlockState(world);
|
|
||||||
if(state != null){
|
|
||||||
return state.getBlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMetadata(IBlockAccess world){
|
|
||||||
return this.getBlock(world).getMetaFromState(this.getBlockState(world));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMetadata(World world, int meta, int flag){
|
|
||||||
if(world != null){
|
|
||||||
world.setBlockState(this, this.getBlock(world).getStateFromMeta(meta), flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setBlock(World world, Block block, int meta, int flag){
|
|
||||||
return world.setBlockState(this, block.getStateFromMeta(meta), flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEqual(Position pos){
|
|
||||||
return pos != null && this.getX() == pos.getX() && this.getY() == pos.getY() && this.getZ() == pos.getZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Position copy(){
|
|
||||||
return new Position(this.getX(), this.getY(), this.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString(){
|
|
||||||
return "["+this.getX()+", "+this.getY()+", "+this.getZ()+"]";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vec3 toVec(){
|
|
||||||
return new Vec3(this.getX(), this.getY(), this.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBlockState getBlockState(IBlockAccess world){
|
|
||||||
return world != null ? world.getBlockState(this) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Position getOffsetPosition(EnumFacing side){
|
|
||||||
return new Position(this.getX()+side.getFrontOffsetX(), this.getY()+side.getFrontOffsetY(), this.getZ()+side.getFrontOffsetZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Position getOffsetPosition(int x, int y, int z){
|
|
||||||
return new Position(this.getX()+x, this.getY()+y, this.getZ()+z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Position fromTileEntity(TileEntity tile){
|
|
||||||
return fromBlockPos(tile.getPos());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Position fromBlockPos(BlockPos pos){
|
|
||||||
//TODO Make this less object creaty (Typecasting doesn't work?)
|
|
||||||
return new Position(pos.getX(), pos.getY(), pos.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setBlockState(World world, IBlockState state, int flag){
|
|
||||||
return world.setBlockState(this, state, flag);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,9 +11,9 @@
|
||||||
package de.ellpeck.actuallyadditions.api.lens;
|
package de.ellpeck.actuallyadditions.api.lens;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the base class for a Reconstructor Lens Type (NOT THE ITEM!)
|
* This is the base class for a Reconstructor Lens Type (NOT THE ITEM!)
|
||||||
|
@ -32,7 +32,7 @@ public abstract class Lens{
|
||||||
* @param tile The tile the lens was invoked from
|
* @param tile The tile the lens was invoked from
|
||||||
* @return If the Reconstructor should stop continuing (return false if you want it to go through blocks)
|
* @return If the Reconstructor should stop continuing (return false if you want it to go through blocks)
|
||||||
*/
|
*/
|
||||||
public abstract boolean invoke(Position hitBlock, IAtomicReconstructor tile);
|
public abstract boolean invoke(BlockPos hitBlock, IAtomicReconstructor tile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the color in an array of 3 float values that are r, g, b
|
* Returns the color in an array of 3 float values that are r, g, b
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.api.tile;
|
package de.ellpeck.actuallyadditions.api.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
import net.minecraft.util.BlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extending this will cause a TileEntity to be able to be connected via a Phantom Connector
|
* Extending this will cause a TileEntity to be able to be connected via a Phantom Connector
|
||||||
|
@ -30,12 +30,12 @@ public interface IPhantomTile{
|
||||||
/**
|
/**
|
||||||
* @return The position this tile is bound to
|
* @return The position this tile is bound to
|
||||||
*/
|
*/
|
||||||
Position getBoundPosition();
|
BlockPos getBoundPosition();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the bound position
|
* Sets the bound position
|
||||||
*/
|
*/
|
||||||
void setBoundPosition(Position pos);
|
void setBoundPosition(BlockPos pos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The ID of the GUI it opens, -1 if none
|
* @return The ID of the GUI it opens, -1 if none
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.block.BlockPistonBase;
|
import net.minecraft.block.BlockPistonBase;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -55,7 +55,7 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||||
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
|
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
|
||||||
Position.fromBlockPos(pos).setMetadata(world, rotation, 2);
|
PosUtil.setMetadata(pos, world, rotation, 2);
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
||||||
if(this.tryToggleRedstone(world, Position.fromBlockPos(pos), player)){
|
if(this.tryToggleRedstone(world, pos, player)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
|
@ -100,7 +100,7 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.EntrySet;
|
import de.ellpeck.actuallyadditions.api.internal.EntrySet;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
|
@ -19,6 +18,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBookletStand;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBookletStand;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -72,19 +72,18 @@ public class BlockBookletStand extends BlockContainerBase implements IHudDisplay
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||||
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
||||||
Position thePos = Position.fromBlockPos(pos);
|
|
||||||
|
|
||||||
if(rotation == 0){
|
if(rotation == 0){
|
||||||
thePos.setMetadata(world, 2, 2);
|
PosUtil.setMetadata(pos, world, 2, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 1){
|
if(rotation == 1){
|
||||||
thePos.setMetadata(world, 1, 2);
|
PosUtil.setMetadata(pos, world, 1, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 2){
|
if(rotation == 2){
|
||||||
thePos.setMetadata(world, 0, 2);
|
PosUtil.setMetadata(pos, world, 0, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 3){
|
if(rotation == 3){
|
||||||
thePos.setMetadata(world, 3, 2);
|
PosUtil.setMetadata(pos, world, 3, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityBookletStand tile = (TileEntityBookletStand)world.getTileEntity(pos);
|
TileEntityBookletStand tile = (TileEntityBookletStand)world.getTileEntity(pos);
|
||||||
|
|
|
@ -10,11 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.BlockPistonBase;
|
import net.minecraft.block.BlockPistonBase;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -47,7 +48,7 @@ public class BlockBreaker extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
||||||
if(this.tryToggleRedstone(world, Position.fromBlockPos(pos), player)){
|
if(this.tryToggleRedstone(world, pos, player)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
|
@ -68,14 +69,14 @@ public class BlockBreaker extends BlockContainerBase{
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||||
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
|
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
|
||||||
Position.fromBlockPos(pos).setMetadata(world, rotation, 2);
|
PosUtil.setMetadata(pos, world, rotation, 2);
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
|
@ -59,7 +58,7 @@ public class BlockCanolaPress extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,13 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -50,7 +51,7 @@ public class BlockCoalGenerator extends BlockContainerBase{
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
|
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
|
||||||
int meta = Position.fromBlockPos(pos).getMetadata(world);
|
int meta = PosUtil.getMetadata(pos, world);
|
||||||
|
|
||||||
if(meta == 1){
|
if(meta == 1){
|
||||||
for(int i = 0; i < 5; i++){
|
for(int i = 0; i < 5; i++){
|
||||||
|
@ -78,7 +79,7 @@ public class BlockCoalGenerator extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
@ -70,7 +70,7 @@ public class BlockCoffeeMachine extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,19 +82,18 @@ public class BlockCoffeeMachine extends BlockContainerBase{
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||||
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
||||||
Position thePos = Position.fromBlockPos(pos);
|
|
||||||
|
|
||||||
if(rotation == 0){
|
if(rotation == 0){
|
||||||
thePos.setMetadata(world, 0, 2);
|
PosUtil.setMetadata(pos, world, 0, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 1){
|
if(rotation == 1){
|
||||||
thePos.setMetadata(world, 3, 2);
|
PosUtil.setMetadata(pos, world, 3, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 2){
|
if(rotation == 2){
|
||||||
thePos.setMetadata(world, 1, 2);
|
PosUtil.setMetadata(pos, world, 1, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 3){
|
if(rotation == 3){
|
||||||
thePos.setMetadata(world, 2, 2);
|
PosUtil.setMetadata(pos, world, 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
|
|
|
@ -10,11 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
|
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -63,7 +64,7 @@ public class BlockColoredLamp extends BlockBase{
|
||||||
//Turning On
|
//Turning On
|
||||||
if(player.isSneaking()){
|
if(player.isSneaking()){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
Position.fromBlockPos(pos).setBlock(world, this.isOn ? InitBlocks.blockColoredLamp : InitBlocks.blockColoredLampOn, Position.fromBlockPos(pos).getMetadata(world), 2);
|
PosUtil.setBlock(pos, world, this.isOn ? InitBlocks.blockColoredLamp : InitBlocks.blockColoredLampOn, PosUtil.getMetadata(pos, world), 2);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -75,9 +76,9 @@ public class BlockColoredLamp extends BlockBase{
|
||||||
String name = OreDictionary.getOreName(oreID);
|
String name = OreDictionary.getOreName(oreID);
|
||||||
TheColoredLampColors color = TheColoredLampColors.getColorFromDyeName(name);
|
TheColoredLampColors color = TheColoredLampColors.getColorFromDyeName(name);
|
||||||
if(color != null){
|
if(color != null){
|
||||||
if(Position.fromBlockPos(pos).getMetadata(world) != color.ordinal()){
|
if(PosUtil.getMetadata(pos, world) != color.ordinal()){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
Position.fromBlockPos(pos).setMetadata(world, color.ordinal(), 2);
|
PosUtil.setMetadata(pos, world, color.ordinal(), 2);
|
||||||
if(!player.capabilities.isCreativeMode){
|
if(!player.capabilities.isCreativeMode){
|
||||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemFertilizer;
|
import de.ellpeck.actuallyadditions.mod.items.ItemFertilizer;
|
||||||
|
@ -121,7 +120,7 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.BlockPistonBase;
|
import net.minecraft.block.BlockPistonBase;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -44,7 +45,7 @@ public class BlockDirectionalBreaker extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
||||||
if(this.tryToggleRedstone(world, Position.fromBlockPos(pos), player)){
|
if(this.tryToggleRedstone(world, pos, player)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
|
@ -65,14 +66,14 @@ public class BlockDirectionalBreaker extends BlockContainerBase{
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||||
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
|
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
|
||||||
Position.fromBlockPos(pos).setMetadata(world, rotation, 2);
|
PosUtil.setMetadata(pos, world, rotation, 2);
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.BlockPistonBase;
|
import net.minecraft.block.BlockPistonBase;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -44,7 +44,7 @@ public class BlockDropper extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
||||||
if(this.tryToggleRedstone(world, Position.fromBlockPos(pos), player)){
|
if(this.tryToggleRedstone(world, pos, player)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
|
@ -65,14 +65,14 @@ public class BlockDropper extends BlockContainerBase{
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||||
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
|
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
|
||||||
Position.fromBlockPos(pos).setMetadata(world, rotation, 2);
|
PosUtil.setMetadata(pos, world, rotation, 2);
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
|
@ -71,7 +70,7 @@ public class BlockEnergizer extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
|
@ -59,7 +58,7 @@ public class BlockFeeder extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
|
@ -42,7 +41,7 @@ public class BlockFermentingBarrel extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -40,7 +40,7 @@ public class BlockFireworkBox extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
||||||
return this.tryToggleRedstone(world, Position.fromBlockPos(pos), player);
|
return this.tryToggleRedstone(world, pos, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,7 +50,7 @@ public class BlockFireworkBox extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidCollector;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidCollector;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.BlockPistonBase;
|
import net.minecraft.block.BlockPistonBase;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -47,7 +48,7 @@ public class BlockFluidCollector extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
||||||
if(this.tryToggleRedstone(world, Position.fromBlockPos(pos), player)){
|
if(this.tryToggleRedstone(world, pos, player)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
|
@ -68,14 +69,14 @@ public class BlockFluidCollector extends BlockContainerBase{
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||||
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
|
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
|
||||||
Position.fromBlockPos(pos).setMetadata(world, rotation, 2);
|
PosUtil.setMetadata(pos, world, rotation, 2);
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceDouble;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceDouble;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
@ -53,7 +53,7 @@ public class BlockFurnaceDouble extends BlockContainerBase{
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
|
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
|
||||||
int meta = Position.fromBlockPos(pos).getMetadata(world);
|
int meta = PosUtil.getMetadata(pos, world);
|
||||||
|
|
||||||
if(meta > 3){
|
if(meta > 3){
|
||||||
float f = (float)pos.getX()+0.5F;
|
float f = (float)pos.getX()+0.5F;
|
||||||
|
@ -99,7 +99,7 @@ public class BlockFurnaceDouble extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLightValue(IBlockAccess world, BlockPos pos){
|
public int getLightValue(IBlockAccess world, BlockPos pos){
|
||||||
return Position.fromBlockPos(pos).getMetadata(world) > 3 ? 12 : 0;
|
return PosUtil.getMetadata(pos, world) > 3 ? 12 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -110,19 +110,18 @@ public class BlockFurnaceDouble extends BlockContainerBase{
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||||
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
||||||
Position thePos = Position.fromBlockPos(pos);
|
|
||||||
|
|
||||||
if(rotation == 0){
|
if(rotation == 0){
|
||||||
thePos.setMetadata(world, 0, 2);
|
PosUtil.setMetadata(pos, world, 0, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 1){
|
if(rotation == 1){
|
||||||
thePos.setMetadata(world, 3, 2);
|
PosUtil.setMetadata(pos, world, 3, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 2){
|
if(rotation == 2){
|
||||||
thePos.setMetadata(world, 1, 2);
|
PosUtil.setMetadata(pos, world, 1, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 3){
|
if(rotation == 3){
|
||||||
thePos.setMetadata(world, 2, 2);
|
PosUtil.setMetadata(pos, world, 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
|
@ -130,7 +129,7 @@ public class BlockFurnaceDouble extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
|
@ -121,7 +120,7 @@ public class BlockGiantChest extends BlockContainerBase{
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if(tile instanceof TileEntityGiantChest){
|
if(tile instanceof TileEntityGiantChest){
|
||||||
if(!ItemUtil.contains(((TileEntityGiantChest)tile).slots, new ItemStack(InitItems.itemCrateKeeper), false)){
|
if(!ItemUtil.contains(((TileEntityGiantChest)tile).slots, new ItemStack(InitItems.itemCrateKeeper), false)){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -54,8 +54,7 @@ public class BlockGrinder extends BlockContainerBase{
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
|
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
|
||||||
Position thePos = Position.fromBlockPos(pos);
|
int meta = PosUtil.getMetadata(pos, world);
|
||||||
int meta = thePos.getMetadata(world);
|
|
||||||
|
|
||||||
if(meta == 1){
|
if(meta == 1){
|
||||||
for(int i = 0; i < 5; i++){
|
for(int i = 0; i < 5; i++){
|
||||||
|
@ -81,7 +80,7 @@ public class BlockGrinder extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLightValue(IBlockAccess world, BlockPos pos){
|
public int getLightValue(IBlockAccess world, BlockPos pos){
|
||||||
return Position.fromBlockPos(pos).getMetadata(world) == 1 ? 12 : 0;
|
return PosUtil.getMetadata(pos, world) == 1 ? 12 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,7 +90,7 @@ public class BlockGrinder extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
||||||
|
@ -70,7 +70,7 @@ public class BlockInputter extends BlockContainerBase{
|
||||||
TileEntity aTile = world.getTileEntity(pos);
|
TileEntity aTile = world.getTileEntity(pos);
|
||||||
if(aTile instanceof TileEntityInventoryBase){
|
if(aTile instanceof TileEntityInventoryBase){
|
||||||
TileEntityInventoryBase tile = (TileEntityInventoryBase)aTile;
|
TileEntityInventoryBase tile = (TileEntityInventoryBase)aTile;
|
||||||
this.dropSlotFromInventory(0, tile, world, Position.fromBlockPos(pos));
|
this.dropSlotFromInventory(0, tile, world, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
|
|
|
@ -10,11 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemRepairer;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemRepairer;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -56,7 +57,7 @@ public class BlockItemRepairer extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLightValue(IBlockAccess world, BlockPos pos){
|
public int getLightValue(IBlockAccess world, BlockPos pos){
|
||||||
return Position.fromBlockPos(pos).getMetadata(world) == 1 ? 12 : 0;
|
return PosUtil.getMetadata(pos, world) == 1 ? 12 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,7 +67,7 @@ public class BlockItemRepairer extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,9 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockPistonBase;
|
import net.minecraft.block.BlockPistonBase;
|
||||||
|
@ -35,34 +36,34 @@ public class BlockLampPowerer extends BlockBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock){
|
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock){
|
||||||
this.updateLamp(world, Position.fromBlockPos(pos));
|
this.updateLamp(world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockAdded(World world, BlockPos pos, IBlockState state){
|
public void onBlockAdded(World world, BlockPos pos, IBlockState state){
|
||||||
this.updateLamp(world, Position.fromBlockPos(pos));
|
this.updateLamp(world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||||
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
|
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
|
||||||
Position.fromBlockPos(pos).setMetadata(world, rotation, 2);
|
PosUtil.setMetadata(pos, world, rotation, 2);
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLamp(World world, Position pos){
|
private void updateLamp(World world, BlockPos pos){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
Position coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionByPistonRotation(pos.getMetadata(world)), pos, 0);
|
BlockPos coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionByPistonRotation(PosUtil.getMetadata(pos, world)), pos, 0);
|
||||||
if(coords != null && coords.getBlock(world) instanceof BlockColoredLamp){
|
if(coords != null && PosUtil.getBlock(coords, world) instanceof BlockColoredLamp){
|
||||||
if(world.isBlockIndirectlyGettingPowered(pos) > 0){
|
if(world.isBlockIndirectlyGettingPowered(pos) > 0){
|
||||||
if(!((BlockColoredLamp)coords.getBlock(world)).isOn){
|
if(!((BlockColoredLamp)PosUtil.getBlock(coords, world)).isOn){
|
||||||
pos.setBlock(world, InitBlocks.blockColoredLampOn, coords.getMetadata(world), 2);
|
PosUtil.setBlock(coords, world, InitBlocks.blockColoredLampOn, PosUtil.getMetadata(coords, world), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(((BlockColoredLamp)coords.getBlock(world)).isOn){
|
if(((BlockColoredLamp)PosUtil.getBlock(coords, world)).isOn){
|
||||||
pos.setBlock(world, InitBlocks.blockColoredLamp, coords.getMetadata(world), 2);
|
PosUtil.setBlock(coords, world, InitBlocks.blockColoredLamp, PosUtil.getMetadata(coords, world), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -62,7 +62,7 @@ public class BlockLaserRelay extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos){
|
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos){
|
||||||
int meta = Position.fromBlockPos(pos).getMetadata(world);
|
int meta = PosUtil.getMetadata(pos, world);
|
||||||
|
|
||||||
float pixel = 1F/16F;
|
float pixel = 1F/16F;
|
||||||
if(meta == 0){
|
if(meta == 0){
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLeafGenerator;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLeafGenerator;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -43,7 +42,7 @@ public class BlockLeafGenerator extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
|
@ -71,7 +71,7 @@ public class BlockMiner extends BlockContainerBase implements IHudDisplay{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,13 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -50,7 +51,7 @@ public class BlockOilGenerator extends BlockContainerBase{
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
|
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
|
||||||
if(Position.fromBlockPos(pos).getMetadata(world) == 1){
|
if(PosUtil.getMetadata(pos, world) == 1){
|
||||||
for(int i = 0; i < 5; i++){
|
for(int i = 0; i < 5; i++){
|
||||||
world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D);
|
world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +77,7 @@ public class BlockOilGenerator extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
||||||
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.*;
|
import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -57,7 +57,7 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
if(this.type == Type.PLACER || this.type == Type.BREAKER){
|
if(this.type == Type.PLACER || this.type == Type.BREAKER){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
}
|
}
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ){
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ){
|
||||||
if(this.tryToggleRedstone(world, Position.fromBlockPos(pos), player)){
|
if(this.tryToggleRedstone(world, pos, player)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
|
@ -107,8 +107,8 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
|
||||||
minecraft.fontRendererObj.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);
|
minecraft.fontRendererObj.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()){
|
if(phantom.hasBoundPosition()){
|
||||||
int distance = (int)new Vec3(posHit.getBlockPos()).distanceTo(new Vec3(phantom.getBoundPosition()));
|
int distance = (int)new Vec3(posHit.getBlockPos()).distanceTo(new Vec3(phantom.getBoundPosition()));
|
||||||
Item item = phantom.getBoundPosition().getItemBlock(minecraft.theWorld);
|
Item item = PosUtil.getItemBlock(phantom.getBoundPosition(), minecraft.theWorld);
|
||||||
String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(phantom.getBoundPosition().getBlock(minecraft.theWorld), 1, phantom.getBoundPosition().getMetadata(minecraft.theWorld)));
|
String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(PosUtil.getBlock(phantom.getBoundPosition(), minecraft.theWorld), 1, PosUtil.getMetadata(phantom.getBoundPosition(), minecraft.theWorld)));
|
||||||
StringUtil.drawSplitString(minecraft.fontRendererObj, 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, true);
|
StringUtil.drawSplitString(minecraft.fontRendererObj, 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, true);
|
||||||
|
|
||||||
if(phantom.isBoundThingInRange()){
|
if(phantom.isBoundThingInRange()){
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
|
@ -64,7 +63,7 @@ public class BlockRangedCollector extends BlockContainerBase{
|
||||||
if(aTile instanceof TileEntityRangedCollector){
|
if(aTile instanceof TileEntityRangedCollector){
|
||||||
TileEntityRangedCollector tile = (TileEntityRangedCollector)aTile;
|
TileEntityRangedCollector tile = (TileEntityRangedCollector)aTile;
|
||||||
for(int i = 0; i < TileEntityRangedCollector.WHITELIST_START; i++){
|
for(int i = 0; i < TileEntityRangedCollector.WHITELIST_START; i++){
|
||||||
this.dropSlotFromInventory(i, tile, world, Position.fromBlockPos(pos));
|
this.dropSlotFromInventory(i, tile, world, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -69,7 +69,7 @@ public class BlockSlabs extends BlockBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos){
|
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos){
|
||||||
int meta = Position.fromBlockPos(pos).getMetadata(world);
|
int meta = PosUtil.getMetadata(pos, world);
|
||||||
float minY = meta == 1 ? 0.5F : 0.0F;
|
float minY = meta == 1 ? 0.5F : 0.0F;
|
||||||
float maxY = meta == 1 ? 1.0F : 0.5F;
|
float maxY = meta == 1 ? 1.0F : 0.5F;
|
||||||
this.setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F);
|
this.setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F);
|
||||||
|
@ -100,10 +100,9 @@ public class BlockSlabs extends BlockBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ){
|
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ){
|
||||||
Position thePos = Position.fromBlockPos(pos);
|
if(PosUtil.getBlock(pos, world) == this.block && ((side.ordinal() == 1 && PosUtil.getMetadata(pos, world) == 0) || (side.ordinal() == 0 && PosUtil.getMetadata(pos, world) == 1))){
|
||||||
if(thePos.getBlock(world) == this.block && ((side.ordinal() == 1 && thePos.getMetadata(world) == 0) || (side.ordinal() == 0 && thePos.getMetadata(world) == 1))){
|
if(PosUtil.setBlock(pos, world, ((BlockSlabs)this.block).fullBlock, ((BlockSlabs)this.block).meta, 3)){
|
||||||
if(thePos.setBlock(world, ((BlockSlabs)this.block).fullBlock, ((BlockSlabs)this.block).meta, 3)){
|
world.playSoundEffect(pos.getX()+0.5F, pos.getY()+0.5F, pos.getZ()+0.5F, this.block.stepSound.getBreakSound(), (this.block.stepSound.getVolume()+1.0F)/2.0F, this.block.stepSound.frequency*0.8F);
|
||||||
world.playSoundEffect(thePos.getX()+0.5F, thePos.getY()+0.5F, thePos.getZ()+0.5F, this.block.stepSound.getBreakSound(), (this.block.stepSound.getVolume()+1.0F)/2.0F, this.block.stepSound.frequency*0.8F);
|
|
||||||
stack.stackSize--;
|
stack.stackSize--;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,14 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
|
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -89,7 +90,7 @@ public class BlockSmileyCloud extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos){
|
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos){
|
||||||
int meta = Position.fromBlockPos(pos).getMetadata(world);
|
int meta = PosUtil.getMetadata(pos, world);
|
||||||
float f = 0.0625F;
|
float f = 0.0625F;
|
||||||
|
|
||||||
if(meta == 0){
|
if(meta == 0){
|
||||||
|
@ -113,7 +114,7 @@ public class BlockSmileyCloud extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,19 +126,18 @@ public class BlockSmileyCloud extends BlockContainerBase{
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||||
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
||||||
Position thePos = Position.fromBlockPos(pos);
|
|
||||||
|
|
||||||
if(rotation == 0){
|
if(rotation == 0){
|
||||||
thePos.setMetadata(world, 0, 2);
|
PosUtil.setMetadata(pos, world, 0, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 1){
|
if(rotation == 1){
|
||||||
thePos.setMetadata(world, 3, 2);
|
PosUtil.setMetadata(pos, world, 3, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 2){
|
if(rotation == 2){
|
||||||
thePos.setMetadata(world, 1, 2);
|
PosUtil.setMetadata(pos, world, 1, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 3){
|
if(rotation == 3){
|
||||||
thePos.setMetadata(world, 2, 2);
|
PosUtil.setMetadata(pos, world, 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot;
|
import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot;
|
||||||
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
|
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -64,7 +64,7 @@ public class BlockTreasureChest extends BlockBase{
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
world.playSoundAtEntity(player, "random.chestopen", 0.2F, Util.RANDOM.nextFloat()*0.1F+0.9F);
|
world.playSoundAtEntity(player, "random.chestopen", 0.2F, Util.RANDOM.nextFloat()*0.1F+0.9F);
|
||||||
this.dropItems(world, Position.fromBlockPos(pos));
|
this.dropItems(world, pos);
|
||||||
world.setBlockToAir(pos);
|
world.setBlockToAir(pos);
|
||||||
|
|
||||||
player.triggerAchievement(TheAchievements.OPEN_TREASURE_CHEST.ach);
|
player.triggerAchievement(TheAchievements.OPEN_TREASURE_CHEST.ach);
|
||||||
|
@ -80,23 +80,22 @@ public class BlockTreasureChest extends BlockBase{
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||||
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
||||||
Position thePos = Position.fromBlockPos(pos);
|
|
||||||
|
|
||||||
if(rotation == 0){
|
if(rotation == 0){
|
||||||
thePos.setMetadata(world, 0, 2);
|
PosUtil.setMetadata(pos, world, 0, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 1){
|
if(rotation == 1){
|
||||||
thePos.setMetadata(world, 3, 2);
|
PosUtil.setMetadata(pos, world, 3, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 2){
|
if(rotation == 2){
|
||||||
thePos.setMetadata(world, 1, 2);
|
PosUtil.setMetadata(pos, world, 1, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 3){
|
if(rotation == 3){
|
||||||
thePos.setMetadata(world, 2, 2);
|
PosUtil.setMetadata(pos, world, 2, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dropItems(World world, Position pos){
|
private void dropItems(World world, BlockPos pos){
|
||||||
for(int i = 0; i < MathHelper.getRandomIntegerInRange(Util.RANDOM, 3, 6); i++){
|
for(int i = 0; i < MathHelper.getRandomIntegerInRange(Util.RANDOM, 3, 6); i++){
|
||||||
TreasureChestLoot theReturn = WeightedRandom.getRandomItem(Util.RANDOM, ActuallyAdditionsAPI.treasureChestLoot);
|
TreasureChestLoot theReturn = WeightedRandom.getRandomItem(Util.RANDOM, ActuallyAdditionsAPI.treasureChestLoot);
|
||||||
ItemStack itemStack = theReturn.returnItem.copy();
|
ItemStack itemStack = theReturn.returnItem.copy();
|
||||||
|
|
|
@ -10,11 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBushBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBushBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheWildPlants;
|
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheWildPlants;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -44,9 +45,8 @@ public class BlockWildPlant extends BlockBushBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBlockStay(World world, BlockPos pos, IBlockState state){
|
public boolean canBlockStay(World world, BlockPos pos, IBlockState state){
|
||||||
Position thePos = Position.fromBlockPos(pos);
|
BlockPos offset = PosUtil.offset(pos, 0, -1, 0);
|
||||||
Position offset = thePos.getOffsetPosition(0, -1, 0);
|
return PosUtil.getMetadata(pos, world) == TheWildPlants.RICE.ordinal() ? PosUtil.getMaterial(offset, world) == Material.water : PosUtil.getBlock(offset, world).canSustainPlant(world, offset, EnumFacing.UP, this);
|
||||||
return thePos.getMetadata(world) == TheWildPlants.RICE.ordinal() ? offset.getMaterial(world) == Material.water : offset.getBlock(world).canSustainPlant(world, offset, EnumFacing.UP, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,8 +72,8 @@ public class BlockWildPlant extends BlockBushBase{
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public Item getItem(World world, BlockPos pos){
|
public Item getItem(World world, BlockPos pos){
|
||||||
int meta = Position.fromBlockPos(pos).getMetadata(world);
|
int metadata = PosUtil.getMetadata(pos, world);
|
||||||
return meta >= allWildPlants.length ? null : ((BlockPlant)allWildPlants[meta].wildVersionOf).seedItem;
|
return metadata >= allWildPlants.length ? null : ((BlockPlant)allWildPlants[metadata].wildVersionOf).seedItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
|
@ -86,7 +86,7 @@ public class BlockWildPlant extends BlockBushBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune){
|
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune){
|
||||||
int metadata = Position.fromBlockPos(pos).getMetadata(world);
|
int metadata = PosUtil.getMetadata(pos, world);
|
||||||
return metadata >= allWildPlants.length ? null : allWildPlants[metadata].wildVersionOf.getDrops(world, pos, allWildPlants[metadata].wildVersionOf.getStateFromMeta(7), fortune);
|
return metadata >= allWildPlants.length ? null : allWildPlants[metadata].wildVersionOf.getDrops(world, pos, allWildPlants[metadata].wildVersionOf.getStateFromMeta(7), fortune);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,13 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -65,19 +66,18 @@ public class BlockXPSolidifier extends BlockContainerBase{
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
|
||||||
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
||||||
Position thePos = Position.fromBlockPos(pos);
|
|
||||||
|
|
||||||
if(rotation == 0){
|
if(rotation == 0){
|
||||||
thePos.setMetadata(world, 0, 2);
|
PosUtil.setMetadata(pos, world, 0, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 1){
|
if(rotation == 1){
|
||||||
thePos.setMetadata(world, 3, 2);
|
PosUtil.setMetadata(pos, world, 3, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 2){
|
if(rotation == 2){
|
||||||
thePos.setMetadata(world, 1, 2);
|
PosUtil.setMetadata(pos, world, 1, 2);
|
||||||
}
|
}
|
||||||
if(rotation == 3){
|
if(rotation == 3){
|
||||||
thePos.setMetadata(world, 2, 2);
|
PosUtil.setMetadata(pos, world, 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
|
@ -85,7 +85,7 @@ public class BlockXPSolidifier extends BlockContainerBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
this.dropInventory(world, pos);
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if(tile instanceof TileEntityXPSolidifier){
|
if(tile instanceof TileEntityXPSolidifier){
|
||||||
TileEntityXPSolidifier solidifier = (TileEntityXPSolidifier)tile;
|
TileEntityXPSolidifier solidifier = (TileEntityXPSolidifier)tile;
|
||||||
|
|
|
@ -12,9 +12,9 @@ package de.ellpeck.actuallyadditions.mod.blocks.base;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
|
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
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.block.properties.PropertyInteger;
|
|
||||||
import net.minecraft.block.state.BlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
|
@ -59,20 +59,18 @@ public class BlockBase extends Block{
|
||||||
return EnumRarity.COMMON;
|
return EnumRarity.COMMON;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final PropertyInteger META = PropertyInteger.create("metadata", 0, 15);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState(){
|
protected BlockState createBlockState(){
|
||||||
return new BlockState(this, META);
|
return new BlockState(this, PosUtil.META);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState getStateFromMeta(int meta){
|
public IBlockState getStateFromMeta(int meta){
|
||||||
return getDefaultState().withProperty(META, meta);
|
return getDefaultState().withProperty(PosUtil.META, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetaFromState(IBlockState state){
|
public int getMetaFromState(IBlockState state){
|
||||||
return state.getValue(META);
|
return state.getValue(PosUtil.META);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ package de.ellpeck.actuallyadditions.mod.blocks.base;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
|
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.BlockBush;
|
import net.minecraft.block.BlockBush;
|
||||||
import net.minecraft.block.properties.PropertyInteger;
|
|
||||||
import net.minecraft.block.state.BlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
|
@ -58,20 +58,18 @@ public class BlockBushBase extends BlockBush{
|
||||||
return EnumRarity.COMMON;
|
return EnumRarity.COMMON;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final PropertyInteger META = PropertyInteger.create("metadata", 0, 15);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState(){
|
protected BlockState createBlockState(){
|
||||||
return new BlockState(this, META);
|
return new BlockState(this, PosUtil.META);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState getStateFromMeta(int meta){
|
public IBlockState getStateFromMeta(int meta){
|
||||||
return getDefaultState().withProperty(META, meta);
|
return getDefaultState().withProperty(PosUtil.META, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetaFromState(IBlockState state){
|
public int getMetaFromState(IBlockState state){
|
||||||
return state.getValue(META);
|
return state.getValue(PosUtil.META);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,16 +10,15 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
|
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.*;
|
import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.block.BlockRedstoneTorch;
|
import net.minecraft.block.BlockRedstoneTorch;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.properties.PropertyInteger;
|
|
||||||
import net.minecraft.block.state.BlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
@ -78,9 +77,9 @@ public abstract class BlockContainerBase extends BlockContainer{
|
||||||
return EnumRarity.COMMON;
|
return EnumRarity.COMMON;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dropInventory(World world, Position position){
|
public void dropInventory(World world, BlockPos position){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
TileEntity aTile = position.getTileEntity(world);
|
TileEntity aTile = world.getTileEntity(position);
|
||||||
if(aTile instanceof TileEntityInventoryBase){
|
if(aTile instanceof TileEntityInventoryBase){
|
||||||
TileEntityInventoryBase tile = (TileEntityInventoryBase)aTile;
|
TileEntityInventoryBase tile = (TileEntityInventoryBase)aTile;
|
||||||
if(tile.getSizeInventory() > 0){
|
if(tile.getSizeInventory() > 0){
|
||||||
|
@ -92,7 +91,7 @@ public abstract class BlockContainerBase extends BlockContainer{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dropSlotFromInventory(int i, TileEntityInventoryBase tile, World world, Position pos){
|
public void dropSlotFromInventory(int i, TileEntityInventoryBase tile, World world, BlockPos pos){
|
||||||
ItemStack stack = tile.getStackInSlot(i);
|
ItemStack stack = tile.getStackInSlot(i);
|
||||||
if(stack != null && stack.stackSize > 0){
|
if(stack != null && stack.stackSize > 0){
|
||||||
float dX = Util.RANDOM.nextFloat()*0.8F+0.1F;
|
float dX = Util.RANDOM.nextFloat()*0.8F+0.1F;
|
||||||
|
@ -113,10 +112,10 @@ public abstract class BlockContainerBase extends BlockContainer{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock){
|
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock){
|
||||||
this.updateRedstoneState(world, Position.fromBlockPos(pos));
|
this.updateRedstoneState(world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateRedstoneState(World world, Position pos){
|
public void updateRedstoneState(World world, BlockPos pos){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if(tile instanceof TileEntityBase){
|
if(tile instanceof TileEntityBase){
|
||||||
|
@ -239,13 +238,13 @@ public abstract class BlockContainerBase extends BlockContainer{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockAdded(World world, BlockPos pos, IBlockState state){
|
public void onBlockAdded(World world, BlockPos pos, IBlockState state){
|
||||||
this.updateRedstoneState(world, Position.fromBlockPos(pos));
|
this.updateRedstoneState(world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tryToggleRedstone(World world, Position pos, EntityPlayer player){
|
public boolean tryToggleRedstone(World world, BlockPos pos, EntityPlayer player){
|
||||||
ItemStack stack = player.getCurrentEquippedItem();
|
ItemStack stack = player.getCurrentEquippedItem();
|
||||||
if(stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){
|
if(stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){
|
||||||
TileEntity tile = pos.getTileEntity(world);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if(tile instanceof IRedstoneToggle){
|
if(tile instanceof IRedstoneToggle){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
((IRedstoneToggle)tile).toggle(!((IRedstoneToggle)tile).isPulseMode());
|
((IRedstoneToggle)tile).toggle(!((IRedstoneToggle)tile).isPulseMode());
|
||||||
|
@ -261,20 +260,18 @@ public abstract class BlockContainerBase extends BlockContainer{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final PropertyInteger META = PropertyInteger.create("metadata", 0, 15);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState(){
|
protected BlockState createBlockState(){
|
||||||
return new BlockState(this, META);
|
return new BlockState(this, PosUtil.META);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState getStateFromMeta(int meta){
|
public IBlockState getStateFromMeta(int meta){
|
||||||
return getDefaultState().withProperty(META, meta);
|
return getDefaultState().withProperty(PosUtil.META, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetaFromState(IBlockState state){
|
public int getMetaFromState(IBlockState state){
|
||||||
return state.getValue(META);
|
return state.getValue(PosUtil.META);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,10 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
|
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -60,12 +61,12 @@ public class BlockFluidFlowing extends BlockFluidClassic{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canDisplace(IBlockAccess world, BlockPos pos){
|
public boolean canDisplace(IBlockAccess world, BlockPos pos){
|
||||||
return !Position.fromBlockPos(pos).getMaterial(world).isLiquid() && super.canDisplace(world, pos);
|
return !PosUtil.getMaterial(pos, world).isLiquid() && super.canDisplace(world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean displaceIfPossible(World world, BlockPos pos){
|
public boolean displaceIfPossible(World world, BlockPos pos){
|
||||||
return !Position.fromBlockPos(pos).getMaterial(world).isLiquid() && super.displaceIfPossible(world, pos);
|
return !PosUtil.getMaterial(pos, world).isLiquid() && super.displaceIfPossible(world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnumRarity getRarity(ItemStack stack){
|
public EnumRarity getRarity(ItemStack stack){
|
||||||
|
|
|
@ -28,7 +28,6 @@ import java.util.List;
|
||||||
public class BlockWallAA extends BlockWall{
|
public class BlockWallAA extends BlockWall{
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private Block baseBlock;
|
|
||||||
private int meta;
|
private int meta;
|
||||||
|
|
||||||
public BlockWallAA(String name, Block base){
|
public BlockWallAA(String name, Block base){
|
||||||
|
@ -37,7 +36,6 @@ public class BlockWallAA extends BlockWall{
|
||||||
|
|
||||||
public BlockWallAA(String name, Block base, int meta){
|
public BlockWallAA(String name, Block base, int meta){
|
||||||
super(base);
|
super(base);
|
||||||
this.baseBlock = base;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.meta = meta;
|
this.meta = meta;
|
||||||
|
|
||||||
|
@ -80,6 +78,6 @@ public class BlockWallAA extends BlockWall{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int damageDropped(IBlockState state){
|
public int damageDropped(IBlockState state){
|
||||||
return this.getMetaFromState(state);
|
return meta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.render.model.ModelBaseAA;
|
import de.ellpeck.actuallyadditions.mod.blocks.render.model.ModelBaseAA;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public class RenderLaserRelay extends RenderTileEntity{
|
||||||
GL11.glTranslatef(0.0F, -2.0F, 0.0F);
|
GL11.glTranslatef(0.0F, -2.0F, 0.0F);
|
||||||
this.bindTexture(resLoc);
|
this.bindTexture(resLoc);
|
||||||
|
|
||||||
int meta = Position.fromTileEntity(tile).getMetadata(tile.getWorld());
|
int meta = PosUtil.getMetadata(tile.getPos(), tile.getWorld());
|
||||||
if(meta == 0){
|
if(meta == 0){
|
||||||
GL11.glRotatef(180F, 1F, 0F, 0F);
|
GL11.glRotatef(180F, 1F, 0F, 0F);
|
||||||
GL11.glTranslatef(0F, -2F, 0F);
|
GL11.glTranslatef(0F, -2F, 0F);
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -33,7 +34,7 @@ public class RenderReconstructorLens extends TileEntitySpecialRenderer{
|
||||||
GL11.glTranslatef((float)x+0.5F, (float)y-0.5F, (float)z+0.5F);
|
GL11.glTranslatef((float)x+0.5F, (float)y-0.5F, (float)z+0.5F);
|
||||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||||
|
|
||||||
int meta = Position.fromTileEntity(tile).getMetadata(getWorld());
|
int meta = PosUtil.getMetadata(tile.getPos(), tile.getWorld());
|
||||||
if(meta == 0){
|
if(meta == 0){
|
||||||
GL11.glTranslatef(0F, -0.5F, 0F);
|
GL11.glTranslatef(0F, -0.5F, 0F);
|
||||||
GL11.glTranslatef(-0.25F, 0F, -0.25F);
|
GL11.glTranslatef(-0.25F, 0F, -0.25F);
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.render.model.ModelBaseAA;
|
import de.ellpeck.actuallyadditions.mod.blocks.render.model.ModelBaseAA;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.cloud.ISmileyCloudEasterEgg;
|
import de.ellpeck.actuallyadditions.mod.misc.cloud.ISmileyCloudEasterEgg;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.cloud.SmileyCloudEasterEggs;
|
import de.ellpeck.actuallyadditions.mod.misc.cloud.SmileyCloudEasterEggs;
|
||||||
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
|
@ -66,7 +66,7 @@ public class RenderSmileyCloud extends RenderTileEntity{
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
{
|
{
|
||||||
if(theModel.doesRotate()){
|
if(theModel.doesRotate()){
|
||||||
int meta = Position.fromTileEntity(tile).getMetadata(tile.getWorld());
|
int meta = PosUtil.getMetadata(tile.getPos(), tile.getWorld());
|
||||||
if(meta == 0){
|
if(meta == 0){
|
||||||
GL11.glRotatef(180F, 0F, 1F, 0F);
|
GL11.glRotatef(180F, 0F, 1F, 0F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.render.model.ModelBaseAA;
|
import de.ellpeck.actuallyadditions.mod.blocks.render.model.ModelBaseAA;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
@ -37,7 +37,7 @@ public class RenderTileEntity extends TileEntitySpecialRenderer{
|
||||||
this.bindTexture(resLoc);
|
this.bindTexture(resLoc);
|
||||||
|
|
||||||
if(theModel.doesRotate()){
|
if(theModel.doesRotate()){
|
||||||
int meta = Position.fromTileEntity(tile).getMetadata(tile.getWorld());
|
int meta = PosUtil.getMetadata(tile.getPos(), tile.getWorld());
|
||||||
if(meta == 0){
|
if(meta == 0){
|
||||||
GL11.glRotatef(180F, 0F, 1F, 0F);
|
GL11.glRotatef(180F, 0F, 1F, 0F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,10 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.event;
|
package de.ellpeck.actuallyadditions.mod.event;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -29,7 +30,7 @@ public class BucketFillEvent{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillBucket(FillBucketEvent event, Item item, Block fluid){
|
private void fillBucket(FillBucketEvent event, Item item, Block fluid){
|
||||||
Block block = Position.fromBlockPos(event.target.getBlockPos()).getBlock(event.world);
|
Block block = PosUtil.getBlock(event.target.getBlockPos(), event.world);
|
||||||
if(block == fluid){
|
if(block == fluid){
|
||||||
event.world.setBlockToAir(event.target.getBlockPos());
|
event.world.setBlockToAir(event.target.getBlockPos());
|
||||||
event.result = new ItemStack(item);
|
event.result = new ItemStack(item);
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.event;
|
package de.ellpeck.actuallyadditions.mod.event;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
||||||
import de.ellpeck.actuallyadditions.api.tile.IEnergyDisplay;
|
import de.ellpeck.actuallyadditions.api.tile.IEnergyDisplay;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.IRedstoneToggle;
|
import de.ellpeck.actuallyadditions.mod.tile.IRedstoneToggle;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockRedstoneTorch;
|
import net.minecraft.block.BlockRedstoneTorch;
|
||||||
|
@ -52,7 +52,7 @@ public class HudEvent{
|
||||||
}
|
}
|
||||||
|
|
||||||
if(posHit != null){
|
if(posHit != null){
|
||||||
Block blockHit = Position.fromBlockPos(posHit.getBlockPos()).getBlock(minecraft.theWorld);
|
Block blockHit = PosUtil.getBlock(posHit.getBlockPos(), minecraft.theWorld);
|
||||||
TileEntity tileHit = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
|
TileEntity tileHit = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
|
||||||
|
|
||||||
if(blockHit instanceof IHudDisplay){
|
if(blockHit instanceof IHudDisplay){
|
||||||
|
|
|
@ -10,17 +10,19 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.event;
|
package de.ellpeck.actuallyadditions.mod.event;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheWildPlants;
|
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheWildPlants;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockBush;
|
import net.minecraft.block.BlockBush;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.world.biome.BiomeGenOcean;
|
import net.minecraft.world.biome.BiomeGenOcean;
|
||||||
import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
|
import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
@ -44,14 +46,14 @@ public class WorldDecorationEvent{
|
||||||
//Generate Treasure Chests
|
//Generate Treasure Chests
|
||||||
if(ConfigBoolValues.DO_TREASURE_CHEST_GEN.isEnabled()){
|
if(ConfigBoolValues.DO_TREASURE_CHEST_GEN.isEnabled()){
|
||||||
if(event.rand.nextInt(300) == 0){
|
if(event.rand.nextInt(300) == 0){
|
||||||
Position randomPos = new Position(event.pos.getX()+event.rand.nextInt(16)+8, 0, event.pos.getZ()+event.rand.nextInt(16)+8);
|
BlockPos randomPos = new BlockPos(event.pos.getX()+event.rand.nextInt(16)+8, 0, event.pos.getZ()+event.rand.nextInt(16)+8);
|
||||||
randomPos = Position.fromBlockPos(event.world.getTopSolidOrLiquidBlock(randomPos));
|
randomPos = event.world.getTopSolidOrLiquidBlock(randomPos);
|
||||||
|
|
||||||
if(event.world.getBiomeGenForCoords(randomPos) instanceof BiomeGenOcean){
|
if(event.world.getBiomeGenForCoords(randomPos) instanceof BiomeGenOcean){
|
||||||
if(randomPos.getY() >= 25 && randomPos.getY() <= 45){
|
if(randomPos.getY() >= 25 && randomPos.getY() <= 45){
|
||||||
if(randomPos.getBlock(event.world).getMaterial() == Material.water){
|
if(PosUtil.getBlock(randomPos, event.world).getMaterial() == Material.water){
|
||||||
if(randomPos.getOffsetPosition(0, -1, 0).getMaterial(event.world).isSolid()){
|
if(PosUtil.getMaterial(PosUtil.offset(randomPos, 0, -1, 0), event.world).isSolid()){
|
||||||
randomPos.setBlock(event.world, InitBlocks.blockTreasureChest, event.rand.nextInt(4), 2);
|
PosUtil.setBlock(randomPos, event.world, InitBlocks.blockTreasureChest, event.rand.nextInt(4), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,15 +67,15 @@ public class WorldDecorationEvent{
|
||||||
if(ConfigBoolValues.DO_RICE_GEN.isEnabled()){
|
if(ConfigBoolValues.DO_RICE_GEN.isEnabled()){
|
||||||
for(int i = 0; i < ConfigIntValues.RICE_AMOUNT.getValue(); i++){
|
for(int i = 0; i < ConfigIntValues.RICE_AMOUNT.getValue(); i++){
|
||||||
if(event.rand.nextInt(50) == 0){
|
if(event.rand.nextInt(50) == 0){
|
||||||
Position randomPos = new Position(event.pos.getX()+event.rand.nextInt(16)+8, 0, event.pos.getZ()+event.rand.nextInt(16)+8);
|
BlockPos randomPos = new BlockPos(event.pos.getX()+event.rand.nextInt(16)+8, 0, event.pos.getZ()+event.rand.nextInt(16)+8);
|
||||||
randomPos = Position.fromBlockPos(event.world.getTopSolidOrLiquidBlock(randomPos));
|
randomPos = event.world.getTopSolidOrLiquidBlock(randomPos);
|
||||||
|
|
||||||
if(randomPos.getMaterial(event.world) == Material.water){
|
if(PosUtil.getMaterial(randomPos, event.world) == Material.water){
|
||||||
ArrayList<Material> blocksAroundBottom = WorldUtil.getMaterialsAround(event.world, randomPos);
|
ArrayList<Material> blocksAroundBottom = WorldUtil.getMaterialsAround(event.world, randomPos);
|
||||||
ArrayList<Material> blocksAroundTop = WorldUtil.getMaterialsAround(event.world, randomPos.getOffsetPosition(0, 1, 0));
|
ArrayList<Material> blocksAroundTop = WorldUtil.getMaterialsAround(event.world, PosUtil.offset(randomPos, 0, 1, 0));
|
||||||
if(blocksAroundBottom.contains(Material.grass) || blocksAroundBottom.contains(Material.ground) || blocksAroundBottom.contains(Material.rock) || blocksAroundBottom.contains(Material.sand)){
|
if(blocksAroundBottom.contains(Material.grass) || blocksAroundBottom.contains(Material.ground) || blocksAroundBottom.contains(Material.rock) || blocksAroundBottom.contains(Material.sand)){
|
||||||
if(!blocksAroundTop.contains(Material.water) && randomPos.getMaterial(event.world) == Material.air){
|
if(!blocksAroundTop.contains(Material.water) && PosUtil.getMaterial(randomPos, event.world) == Material.air){
|
||||||
randomPos.getOffsetPosition(0, 1, 0).setBlock(event.world, InitBlocks.blockWildPlant, TheWildPlants.RICE.ordinal(), 2);
|
PosUtil.setBlock(PosUtil.offset(randomPos, 0, 1, 0), event.world, InitBlocks.blockWildPlant, TheWildPlants.RICE.ordinal(), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,13 +88,13 @@ public class WorldDecorationEvent{
|
||||||
if(doIt){
|
if(doIt){
|
||||||
for(int i = 0; i < amount; i++){
|
for(int i = 0; i < amount; i++){
|
||||||
if(event.rand.nextInt(400) == 0){
|
if(event.rand.nextInt(400) == 0){
|
||||||
Position randomPos = new Position(event.pos.getX()+event.rand.nextInt(16)+8, 0, event.pos.getZ()+event.rand.nextInt(16)+8);
|
BlockPos randomPos = new BlockPos(event.pos.getX()+event.rand.nextInt(16)+8, 0, event.pos.getZ()+event.rand.nextInt(16)+8);
|
||||||
randomPos = Position.fromBlockPos(event.world.getTopSolidOrLiquidBlock(randomPos));
|
randomPos = event.world.getTopSolidOrLiquidBlock(randomPos);
|
||||||
|
|
||||||
if(randomPos.getMaterial(event.world) == blockBelow){
|
if(PosUtil.getMaterial(randomPos, event.world) == blockBelow){
|
||||||
Position top = randomPos.getOffsetPosition(0, 1, 0);
|
BlockPos top = PosUtil.offset(randomPos, 0, 1, 0);
|
||||||
top.setBlock(event.world, plant, meta, 2);
|
PosUtil.setBlock(top, event.world, plant, meta, 2);
|
||||||
if(plant instanceof BlockBush && !((BlockBush)plant).canBlockStay(event.world, top, top.getBlockState(event.world))){
|
if(plant instanceof BlockBush && !((BlockBush)plant).canBlockStay(event.world, top, event.world.getBlockState(top))){
|
||||||
event.world.setBlockToAir(top);
|
event.world.setBlockToAir(top);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.gen;
|
package de.ellpeck.actuallyadditions.mod.gen;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
||||||
|
@ -20,6 +19,7 @@ import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.pattern.BlockHelper;
|
import net.minecraft.block.state.pattern.BlockHelper;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldType;
|
import net.minecraft.world.WorldType;
|
||||||
|
@ -79,7 +79,7 @@ public class OreGen implements IWorldGenerator{
|
||||||
int posX = blockXPos+random.nextInt(16);
|
int posX = blockXPos+random.nextInt(16);
|
||||||
int posY = minY+random.nextInt(yDiff);
|
int posY = minY+random.nextInt(yDiff);
|
||||||
int posZ = blockZPos+random.nextInt(16);
|
int posZ = blockZPos+random.nextInt(16);
|
||||||
new WorldGenMinable(block.getStateFromMeta(meta), maxVeinSize, BlockHelper.forBlock(blockIn)).generate(world, random, new Position(posX, posY, posZ));
|
new WorldGenMinable(block.getStateFromMeta(meta), maxVeinSize, BlockHelper.forBlock(blockIn)).generate(world, random, new BlockPos(posX, posY, posZ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.inventory;
|
package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBookletStand;
|
import de.ellpeck.actuallyadditions.mod.booklet.GuiBookletStand;
|
||||||
|
@ -18,6 +17,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.gui.*;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||||
|
@ -33,7 +33,7 @@ public class GuiHandler implements IGuiHandler{
|
||||||
public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){
|
public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){
|
||||||
TileEntityBase tile = null;
|
TileEntityBase tile = null;
|
||||||
if(GuiTypes.values()[id].checkTileEntity){
|
if(GuiTypes.values()[id].checkTileEntity){
|
||||||
tile = (TileEntityBase)world.getTileEntity(new Position(x, y, z));
|
tile = (TileEntityBase)world.getTileEntity(new BlockPos(x, y, z));
|
||||||
}
|
}
|
||||||
switch(GuiTypes.values()[id]){
|
switch(GuiTypes.values()[id]){
|
||||||
case FEEDER:
|
case FEEDER:
|
||||||
|
@ -97,7 +97,7 @@ public class GuiHandler implements IGuiHandler{
|
||||||
public Object getClientGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){
|
public Object getClientGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){
|
||||||
TileEntityBase tile = null;
|
TileEntityBase tile = null;
|
||||||
if(GuiTypes.values()[id].checkTileEntity){
|
if(GuiTypes.values()[id].checkTileEntity){
|
||||||
tile = (TileEntityBase)world.getTileEntity(new Position(x, y, z));
|
tile = (TileEntityBase)world.getTileEntity(new BlockPos(x, y, z));
|
||||||
}
|
}
|
||||||
switch(GuiTypes.values()[id]){
|
switch(GuiTypes.values()[id]){
|
||||||
case FEEDER:
|
case FEEDER:
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.EntrySet;
|
import de.ellpeck.actuallyadditions.api.internal.EntrySet;
|
||||||
|
@ -23,6 +22,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -65,8 +65,8 @@ public class ItemBooklet extends ItemBase implements IHudDisplay{
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing face, float hitX, float hitY, float hitZ){
|
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing face, float hitX, float hitY, float hitZ){
|
||||||
if(player.isSneaking()){
|
if(player.isSneaking()){
|
||||||
Block block = Position.fromBlockPos(pos).getBlock(world);
|
Block block = PosUtil.getBlock(pos, world);
|
||||||
ItemStack blockStack = new ItemStack(block, 1, Position.fromBlockPos(pos).getMetadata(world));
|
ItemStack blockStack = new ItemStack(block, 1, PosUtil.getMetadata(pos, world));
|
||||||
if(blockStack != null){
|
if(blockStack != null){
|
||||||
BookletPage page = BookletUtils.getFirstPageForStack(blockStack);
|
BookletPage page = BookletUtils.getFirstPageForStack(blockStack);
|
||||||
if(page != null){
|
if(page != null){
|
||||||
|
@ -95,9 +95,9 @@ public class ItemBooklet extends ItemBase implements IHudDisplay{
|
||||||
@Override
|
@Override
|
||||||
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){
|
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){
|
||||||
if(posHit != null){
|
if(posHit != null){
|
||||||
Block block = Position.fromBlockPos(posHit.getBlockPos()).getBlock(minecraft.theWorld);
|
Block block = PosUtil.getBlock(posHit.getBlockPos(), minecraft.theWorld);
|
||||||
if(block != null && !block.isAir(minecraft.theWorld, posHit.getBlockPos())){
|
if(block != null && !block.isAir(minecraft.theWorld, posHit.getBlockPos())){
|
||||||
ItemStack blockStack = new ItemStack(block, 1, Position.fromBlockPos(posHit.getBlockPos()).getMetadata(minecraft.theWorld));
|
ItemStack blockStack = new ItemStack(block, 1, PosUtil.getMetadata(posHit.getBlockPos(), minecraft.theWorld));
|
||||||
if(blockStack != null){
|
if(blockStack != null){
|
||||||
int height = resolution.getScaledHeight()/5*3;
|
int height = resolution.getScaledHeight()/5*3;
|
||||||
if(player.isSneaking()){
|
if(player.isSneaking()){
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockChest;
|
import net.minecraft.block.BlockChest;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -35,7 +35,7 @@ public class ItemChestToCrateUpgrade extends ItemBase{
|
||||||
public boolean onItemUse(ItemStack heldStack, EntityPlayer player, World world, BlockPos pos, EnumFacing facing, float par8, float par9, float par10){
|
public boolean onItemUse(ItemStack heldStack, EntityPlayer player, World world, BlockPos pos, EnumFacing facing, float par8, float par9, float par10){
|
||||||
if(player.isSneaking()){
|
if(player.isSneaking()){
|
||||||
TileEntity tileHit = world.getTileEntity(pos);
|
TileEntity tileHit = world.getTileEntity(pos);
|
||||||
Block block = Position.fromBlockPos(pos).getBlock(world);
|
Block block = PosUtil.getBlock(pos, world);
|
||||||
if(block instanceof BlockChest && tileHit instanceof TileEntityChest){
|
if(block instanceof BlockChest && tileHit instanceof TileEntityChest){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
TileEntityChest chest = (TileEntityChest)tileHit;
|
TileEntityChest chest = (TileEntityChest)tileHit;
|
||||||
|
@ -51,8 +51,8 @@ public class ItemChestToCrateUpgrade extends ItemBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set New Block
|
//Set New Block
|
||||||
world.playAuxSFX(2001, pos, Block.getIdFromBlock(block)+(Position.fromBlockPos(pos).getMetadata(world) << 12));
|
world.playAuxSFX(2001, pos, Block.getIdFromBlock(block)+(PosUtil.getMetadata(pos, world) << 12));
|
||||||
Position.fromBlockPos(pos).setBlock(world, InitBlocks.blockGiantChest, 0, 2);
|
PosUtil.setBlock(pos, world, InitBlocks.blockGiantChest, 0, 2);
|
||||||
|
|
||||||
//Copy Items into new Chest
|
//Copy Items into new Chest
|
||||||
TileEntity newTileHit = world.getTileEntity(pos);
|
TileEntity newTileHit = world.getTileEntity(pos);
|
||||||
|
|
|
@ -12,13 +12,13 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyContainerItem;
|
import cofh.api.energy.IEnergyContainerItem;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -436,12 +436,12 @@ public class ItemDrill extends ItemEnergy{
|
||||||
}
|
}
|
||||||
|
|
||||||
//Not defined later because main Block is getting broken below
|
//Not defined later because main Block is getting broken below
|
||||||
float mainHardness = Position.fromBlockPos(aPos).getBlock(world).getBlockHardness(world, aPos);
|
float mainHardness = PosUtil.getBlock(aPos, world).getBlockHardness(world, aPos);
|
||||||
|
|
||||||
//Break Middle Block first
|
//Break Middle Block first
|
||||||
int use = this.getEnergyUsePerBlock(stack);
|
int use = this.getEnergyUsePerBlock(stack);
|
||||||
if(this.getEnergyStored(stack) >= use){
|
if(this.getEnergyStored(stack) >= use){
|
||||||
if(!this.tryHarvestBlock(world, Position.fromBlockPos(aPos), false, stack, player, use)){
|
if(!this.tryHarvestBlock(world, aPos, false, stack, player, use)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,8 +457,8 @@ public class ItemDrill extends ItemEnergy{
|
||||||
if(!(aPos.getX() == xPos && aPos.getY() == yPos && aPos.getZ() == zPos)){
|
if(!(aPos.getX() == xPos && aPos.getY() == yPos && aPos.getZ() == zPos)){
|
||||||
if(this.getEnergyStored(stack) >= use){
|
if(this.getEnergyStored(stack) >= use){
|
||||||
//Only break Blocks around that are (about) as hard or softer
|
//Only break Blocks around that are (about) as hard or softer
|
||||||
Position thePos = new Position(xPos, yPos, zPos);
|
BlockPos thePos = new BlockPos(xPos, yPos, zPos);
|
||||||
if(thePos.getBlock(world).getBlockHardness(world, thePos) <= mainHardness+5.0F){
|
if(PosUtil.getBlock(thePos, world).getBlockHardness(world, thePos) <= mainHardness+5.0F){
|
||||||
this.tryHarvestBlock(world, thePos, true, stack, player, use);
|
this.tryHarvestBlock(world, thePos, true, stack, player, use);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -484,12 +484,11 @@ public class ItemDrill extends ItemEnergy{
|
||||||
* @param player The Player breaking the Blocks
|
* @param player The Player breaking the Blocks
|
||||||
* @param use The Energy that should be extracted per Block
|
* @param use The Energy that should be extracted per Block
|
||||||
*/
|
*/
|
||||||
private boolean tryHarvestBlock(World world, Position pos, boolean isExtra, ItemStack stack, EntityPlayer player, int use){
|
private boolean tryHarvestBlock(World world, BlockPos pos, boolean isExtra, ItemStack stack, EntityPlayer player, int use){
|
||||||
Block block = pos.getBlock(world);
|
Block block = PosUtil.getBlock(pos, world);
|
||||||
float hardness = block.getBlockHardness(world, pos);
|
float hardness = block.getBlockHardness(world, pos);
|
||||||
int meta = pos.getMetadata(world);
|
boolean canHarvest = (ForgeHooks.canHarvestBlock(block, player, world, pos) || this.canHarvestBlock(block, stack)) && (!isExtra || this.getDigSpeed(stack, world.getBlockState(pos)) > 1.0F);
|
||||||
boolean canHarvest = (ForgeHooks.canHarvestBlock(block, player, world, pos) || this.canHarvestBlock(block, stack)) && (!isExtra || this.getDigSpeed(stack, pos.getBlockState(world)) > 1.0F);
|
if(hardness >= 0.0F && (!isExtra || (canHarvest && !block.hasTileEntity(world.getBlockState(pos))))){
|
||||||
if(hardness >= 0.0F && (!isExtra || (canHarvest && !block.hasTileEntity(pos.getBlockState(world))))){
|
|
||||||
this.extractEnergy(stack, use, false);
|
this.extractEnergy(stack, use, false);
|
||||||
//Break the Block
|
//Break the Block
|
||||||
return WorldUtil.playerHarvestBlock(world, pos, player);
|
return WorldUtil.playerHarvestBlock(world, pos, player);
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockGrass;
|
import net.minecraft.block.BlockGrass;
|
||||||
|
@ -21,6 +21,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.IPlantable;
|
import net.minecraftforge.common.IPlantable;
|
||||||
|
@ -44,7 +45,7 @@ public class ItemGrowthRing extends ItemEnergy{
|
||||||
|
|
||||||
int energyUse = 300;
|
int energyUse = 300;
|
||||||
if(equipped != null && equipped == stack && this.getEnergyStored(stack) >= energyUse){
|
if(equipped != null && equipped == stack && this.getEnergyStored(stack) >= energyUse){
|
||||||
ArrayList<Position> blocks = new ArrayList<Position>();
|
ArrayList<BlockPos> blocks = new ArrayList<BlockPos>();
|
||||||
|
|
||||||
if(stack.getTagCompound() == null){
|
if(stack.getTagCompound() == null){
|
||||||
stack.setTagCompound(new NBTTagCompound());
|
stack.setTagCompound(new NBTTagCompound());
|
||||||
|
@ -60,9 +61,10 @@ public class ItemGrowthRing extends ItemEnergy{
|
||||||
int theX = MathHelper.floor_double(player.posX+x);
|
int theX = MathHelper.floor_double(player.posX+x);
|
||||||
int theY = MathHelper.floor_double(player.posY+y);
|
int theY = MathHelper.floor_double(player.posY+y);
|
||||||
int theZ = MathHelper.floor_double(player.posZ+z);
|
int theZ = MathHelper.floor_double(player.posZ+z);
|
||||||
Block theBlock = new Position(theX, theY, theZ).getBlock(world);
|
BlockPos posInQuestion = new BlockPos(theX, theY, theZ);
|
||||||
|
Block theBlock = PosUtil.getBlock(posInQuestion, world);
|
||||||
if((theBlock instanceof IGrowable || theBlock instanceof IPlantable) && !(theBlock instanceof BlockGrass)){
|
if((theBlock instanceof IGrowable || theBlock instanceof IPlantable) && !(theBlock instanceof BlockGrass)){
|
||||||
blocks.add(new Position(theX, theY, theZ));
|
blocks.add(posInQuestion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,13 +74,13 @@ public class ItemGrowthRing extends ItemEnergy{
|
||||||
if(!blocks.isEmpty()){
|
if(!blocks.isEmpty()){
|
||||||
for(int i = 0; i < 45; i++){
|
for(int i = 0; i < 45; i++){
|
||||||
if(this.getEnergyStored(stack) >= energyUse){
|
if(this.getEnergyStored(stack) >= energyUse){
|
||||||
Position pos = blocks.get(Util.RANDOM.nextInt(blocks.size()));
|
BlockPos pos = blocks.get(Util.RANDOM.nextInt(blocks.size()));
|
||||||
|
|
||||||
int metaBefore = pos.getMetadata(world);
|
int metaBefore = PosUtil.getMetadata(pos, world);
|
||||||
pos.getBlock(world).updateTick(world, pos, pos.getBlockState(world), Util.RANDOM);
|
PosUtil.getBlock(pos, world).updateTick(world, pos, world.getBlockState(pos), Util.RANDOM);
|
||||||
|
|
||||||
//Show Particles if Metadata changed
|
//Show Particles if Metadata changed
|
||||||
if(pos.getMetadata(world) != metaBefore){
|
if(PosUtil.getMetadata(pos, world) != metaBefore){
|
||||||
world.playAuxSFX(2005, pos, 0);
|
world.playAuxSFX(2005, pos, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler;
|
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
||||||
|
@ -48,13 +47,12 @@ public class ItemLaserWrench extends ItemBase{
|
||||||
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".laser.stored.desc")));
|
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".laser.stored.desc")));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Position savedPos = ItemPhantomConnector.getStoredPosition(stack);
|
BlockPos savedPos = ItemPhantomConnector.getStoredPosition(stack);
|
||||||
Position otherPos = Position.fromBlockPos(pos);
|
if(ItemPhantomConnector.getStoredWorld(stack) == world && world.getTileEntity(savedPos) instanceof TileEntityLaserRelay && LaserRelayConnectionHandler.getInstance().addConnection(savedPos, pos)){
|
||||||
if(ItemPhantomConnector.getStoredWorld(stack) == world && savedPos.getTileEntity(world) instanceof TileEntityLaserRelay && LaserRelayConnectionHandler.getInstance().addConnection(savedPos, otherPos)){
|
|
||||||
ItemPhantomConnector.clearStorage(stack);
|
ItemPhantomConnector.clearStorage(stack);
|
||||||
|
|
||||||
((TileEntityLaserRelay)savedPos.getTileEntity(world)).sendUpdate();
|
((TileEntityLaserRelay)world.getTileEntity(savedPos)).sendUpdate();
|
||||||
((TileEntityLaserRelay)otherPos.getTileEntity(world)).sendUpdate();
|
((TileEntityLaserRelay)world.getTileEntity(pos)).sendUpdate();
|
||||||
|
|
||||||
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".laser.connected.desc")));
|
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".laser.connected.desc")));
|
||||||
}
|
}
|
||||||
|
@ -84,7 +82,7 @@ public class ItemLaserWrench extends ItemBase{
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@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){
|
||||||
Position coords = ItemPhantomConnector.getStoredPosition(stack);
|
BlockPos coords = ItemPhantomConnector.getStoredPosition(stack);
|
||||||
if(coords != null){
|
if(coords != null){
|
||||||
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".boundTo.desc")+":");
|
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".boundTo.desc")+":");
|
||||||
list.add("X: "+coords.getX());
|
list.add("X: "+coords.getX());
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockBush;
|
import net.minecraft.block.BlockBush;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
@ -20,6 +20,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.EnumAction;
|
import net.minecraft.item.EnumAction;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ public class ItemLeafBlower extends ItemBase{
|
||||||
* @param z The Z Position of the Player
|
* @param z The Z Position of the Player
|
||||||
*/
|
*/
|
||||||
public void breakStuff(World world, int x, int y, int z){
|
public void breakStuff(World world, int x, int y, int z){
|
||||||
ArrayList<Position> breakPositions = new ArrayList<Position>();
|
ArrayList<BlockPos> breakPositions = new ArrayList<BlockPos>();
|
||||||
|
|
||||||
int rangeSides = 5;
|
int rangeSides = 5;
|
||||||
int rangeUp = 1;
|
int rangeUp = 1;
|
||||||
|
@ -89,8 +90,8 @@ public class ItemLeafBlower extends ItemBase{
|
||||||
for(int reachZ = -rangeSides; reachZ < rangeSides+1; reachZ++){
|
for(int reachZ = -rangeSides; reachZ < rangeSides+1; reachZ++){
|
||||||
for(int reachY = (this.isAdvanced ? -rangeSides : -rangeUp); reachY < (this.isAdvanced ? rangeSides : rangeUp)+1; reachY++){
|
for(int reachY = (this.isAdvanced ? -rangeSides : -rangeUp); reachY < (this.isAdvanced ? rangeSides : rangeUp)+1; reachY++){
|
||||||
//The current Block to break
|
//The current Block to break
|
||||||
Position pos = new Position(x+reachX, y+reachY, z+reachZ);
|
BlockPos pos = new BlockPos(x+reachX, y+reachY, z+reachZ);
|
||||||
Block block = pos.getBlock(world);
|
Block block = PosUtil.getBlock(pos, world);
|
||||||
if(block != null && (block instanceof BlockBush || (this.isAdvanced && block.isLeaves(world, pos)))){
|
if(block != null && (block instanceof BlockBush || (this.isAdvanced && block.isLeaves(world, pos)))){
|
||||||
breakPositions.add(pos);
|
breakPositions.add(pos);
|
||||||
}
|
}
|
||||||
|
@ -101,13 +102,13 @@ public class ItemLeafBlower extends ItemBase{
|
||||||
if(!breakPositions.isEmpty()){
|
if(!breakPositions.isEmpty()){
|
||||||
Collections.shuffle(breakPositions);
|
Collections.shuffle(breakPositions);
|
||||||
|
|
||||||
Position theCoord = breakPositions.get(0);
|
BlockPos theCoord = breakPositions.get(0);
|
||||||
Block theBlock = theCoord.getBlock(world);
|
Block theBlock = PosUtil.getBlock(theCoord, world);
|
||||||
|
|
||||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
int meta = theCoord.getMetadata(world);
|
int meta = PosUtil.getMetadata(theCoord, world);
|
||||||
//Gets all of the Drops the Block should have
|
//Gets all of the Drops the Block should have
|
||||||
drops.addAll(theBlock.getDrops(world, theCoord, theCoord.getBlockState(world), 0));
|
drops.addAll(theBlock.getDrops(world, theCoord, world.getBlockState(theCoord), 0));
|
||||||
|
|
||||||
//Deletes the Block
|
//Deletes the Block
|
||||||
world.setBlockToAir(theCoord);
|
world.setBlockToAir(theCoord);
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||||
|
@ -80,14 +79,14 @@ public class ItemPhantomConnector extends ItemBase{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Position getStoredPosition(ItemStack stack){
|
public static BlockPos 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");
|
||||||
if(!(x == 0 && y == 0 && z == 0)){
|
if(!(x == 0 && y == 0 && z == 0)){
|
||||||
return new Position(x, y, z);
|
return new BlockPos(x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -135,7 +134,7 @@ public class ItemPhantomConnector extends ItemBase{
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@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){
|
||||||
Position coords = getStoredPosition(stack);
|
BlockPos coords = getStoredPosition(stack);
|
||||||
if(coords != null){
|
if(coords != null){
|
||||||
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".boundTo.desc")+":");
|
list.add(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".boundTo.desc")+":");
|
||||||
list.add("X: "+coords.getX());
|
list.add("X: "+coords.getX());
|
||||||
|
|
|
@ -10,14 +10,16 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@ -49,8 +51,8 @@ public class ItemWaterRemovalRing extends ItemEnergy{
|
||||||
int theZ = MathHelper.floor_double(player.posZ+z);
|
int theZ = MathHelper.floor_double(player.posZ+z);
|
||||||
if(this.getEnergyStored(stack) >= energyUse){
|
if(this.getEnergyStored(stack) >= energyUse){
|
||||||
//Remove Water
|
//Remove Water
|
||||||
Position pos = new Position(theX, theY, theZ);
|
BlockPos pos = new BlockPos(theX, theY, theZ);
|
||||||
Block block = pos.getBlock(world);
|
Block block = PosUtil.getBlock(pos, world);
|
||||||
if(block == Blocks.water || block == Blocks.flowing_water){
|
if(block == Blocks.water || block == Blocks.flowing_water){
|
||||||
world.setBlockToAir(pos);
|
world.setBlockToAir(pos);
|
||||||
|
|
||||||
|
|
|
@ -10,16 +10,18 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items.lens;
|
package de.ellpeck.actuallyadditions.mod.items.lens;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -54,15 +56,15 @@ public class LensColor extends Lens{
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public boolean invoke(Position hitBlock, IAtomicReconstructor tile){
|
public boolean invoke(BlockPos hitBlock, IAtomicReconstructor tile){
|
||||||
if(hitBlock != null){
|
if(hitBlock != null){
|
||||||
if(Util.arrayContains(CONVERTABLE_BLOCKS, hitBlock.getBlock(tile.getWorldObject())) >= 0 && tile.getEnergy() >= ENERGY_USE){
|
if(Util.arrayContains(CONVERTABLE_BLOCKS, PosUtil.getBlock(hitBlock, tile.getWorldObject())) >= 0 && tile.getEnergy() >= ENERGY_USE){
|
||||||
int meta = hitBlock.getMetadata(tile.getWorldObject());
|
int meta = PosUtil.getMetadata(hitBlock, tile.getWorldObject());
|
||||||
if(meta >= 15){
|
if(meta >= 15){
|
||||||
hitBlock.setMetadata(tile.getWorldObject(), 0, 2);
|
PosUtil.setMetadata(hitBlock, tile.getWorldObject(), 0, 2);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
hitBlock.setMetadata(tile.getWorldObject(), meta+1, 2);
|
PosUtil.setMetadata(hitBlock, tile.getWorldObject(), meta+1, 2);
|
||||||
}
|
}
|
||||||
tile.extractEnergy(ENERGY_USE);
|
tile.extractEnergy(ENERGY_USE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,13 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items.lens;
|
package de.ellpeck.actuallyadditions.mod.items.lens;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.DamageSources;
|
import de.ellpeck.actuallyadditions.mod.misc.DamageSources;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ public class LensDeath extends Lens{
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public boolean invoke(Position hitBlock, IAtomicReconstructor tile){
|
public boolean invoke(BlockPos hitBlock, IAtomicReconstructor tile){
|
||||||
int use = 150; //Per Block (because it doesn't only activate when something is hit like the other lenses!)
|
int use = 150; //Per Block (because it doesn't only activate when something is hit like the other lenses!)
|
||||||
if(tile.getEnergy() >= use){
|
if(tile.getEnergy() >= use){
|
||||||
tile.extractEnergy(use);
|
tile.extractEnergy(use);
|
||||||
|
@ -34,7 +35,7 @@ public class LensDeath extends Lens{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hitBlock != null && !hitBlock.getBlock(tile.getWorldObject()).isAir(tile.getWorldObject(), hitBlock);
|
return hitBlock != null && !PosUtil.getBlock(hitBlock, tile.getWorldObject()).isAir(tile.getWorldObject(), hitBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,15 +10,16 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items.lens;
|
package de.ellpeck.actuallyadditions.mod.items.lens;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
|
||||||
public class LensDetonation extends Lens{
|
public class LensDetonation extends Lens{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean invoke(Position hitBlock, IAtomicReconstructor tile){
|
public boolean invoke(BlockPos hitBlock, IAtomicReconstructor tile){
|
||||||
if(hitBlock != null && !hitBlock.getBlock(tile.getWorldObject()).isAir(tile.getWorldObject(), hitBlock)){
|
if(hitBlock != null && !PosUtil.getBlock(hitBlock, tile.getWorldObject()).isAir(tile.getWorldObject(), hitBlock)){
|
||||||
int use = 250000;
|
int use = 250000;
|
||||||
if(tile.getEnergy() >= use){
|
if(tile.getEnergy() >= use){
|
||||||
tile.getWorldObject().newExplosion(null, hitBlock.getX()+0.5, hitBlock.getY()+0.5, hitBlock.getZ()+0.5, 10F, true, true);
|
tile.getWorldObject().newExplosion(null, hitBlock.getX()+0.5, hitBlock.getY()+0.5, hitBlock.getZ()+0.5, 10F, true, true);
|
||||||
|
|
|
@ -10,15 +10,17 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items.lens;
|
package de.ellpeck.actuallyadditions.mod.items.lens;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.LensNoneRecipe;
|
import de.ellpeck.actuallyadditions.api.recipe.LensNoneRecipe;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -27,24 +29,24 @@ public class LensNone extends Lens{
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public boolean invoke(Position hitBlock, IAtomicReconstructor tile){
|
public boolean invoke(BlockPos hitBlock, IAtomicReconstructor tile){
|
||||||
if(hitBlock != null && !hitBlock.getBlock(tile.getWorldObject()).isAir(tile.getWorldObject(), hitBlock)){
|
if(hitBlock != null && !PosUtil.getBlock(hitBlock, tile.getWorldObject()).isAir(tile.getWorldObject(), hitBlock)){
|
||||||
int range = 2;
|
int range = 2;
|
||||||
|
|
||||||
//Converting the Blocks
|
//Converting the Blocks
|
||||||
for(int reachX = -range; reachX < range+1; reachX++){
|
for(int reachX = -range; reachX < range+1; reachX++){
|
||||||
for(int reachZ = -range; reachZ < range+1; reachZ++){
|
for(int reachZ = -range; reachZ < range+1; reachZ++){
|
||||||
for(int reachY = -range; reachY < range+1; reachY++){
|
for(int reachY = -range; reachY < range+1; reachY++){
|
||||||
Position pos = new Position(hitBlock.getX()+reachX, hitBlock.getY()+reachY, hitBlock.getZ()+reachZ);
|
BlockPos pos = new BlockPos(hitBlock.getX()+reachX, hitBlock.getY()+reachY, hitBlock.getZ()+reachZ);
|
||||||
List<LensNoneRecipe> recipes = LensNoneRecipeHandler.getRecipesFor(new ItemStack(pos.getBlock(tile.getWorldObject()), 1, pos.getMetadata(tile.getWorldObject())));
|
List<LensNoneRecipe> recipes = LensNoneRecipeHandler.getRecipesFor(new ItemStack(PosUtil.getBlock(pos, tile.getWorldObject()), 1, PosUtil.getMetadata(pos, tile.getWorldObject())));
|
||||||
for(LensNoneRecipe recipe : recipes){
|
for(LensNoneRecipe recipe : recipes){
|
||||||
if(recipe != null && tile.getEnergy() >= recipe.energyUse){
|
if(recipe != null && tile.getEnergy() >= recipe.energyUse){
|
||||||
List<ItemStack> outputs = recipe.getOutputs();
|
List<ItemStack> outputs = recipe.getOutputs();
|
||||||
if(outputs != null && !outputs.isEmpty()){
|
if(outputs != null && !outputs.isEmpty()){
|
||||||
ItemStack output = outputs.get(0);
|
ItemStack output = outputs.get(0);
|
||||||
if(output.getItem() instanceof ItemBlock){
|
if(output.getItem() instanceof ItemBlock){
|
||||||
tile.getWorldObject().playAuxSFX(2001, pos, Block.getIdFromBlock(pos.getBlock(tile.getWorldObject()))+(pos.getMetadata(tile.getWorldObject()) << 12));
|
tile.getWorldObject().playAuxSFX(2001, pos, Block.getIdFromBlock(PosUtil.getBlock(pos, tile.getWorldObject()))+(PosUtil.getMetadata(pos, tile.getWorldObject()) << 12));
|
||||||
pos.setBlock(tile.getWorldObject(), Block.getBlockFromItem(output.getItem()), output.getItemDamage(), 2);
|
PosUtil.setBlock(pos, tile.getWorldObject(), Block.getBlockFromItem(output.getItem()), output.getItemDamage(), 2);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
EntityItem item = new EntityItem(tile.getWorldObject(), pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, output.copy());
|
EntityItem item = new EntityItem(tile.getWorldObject(), pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, output.copy());
|
||||||
|
|
|
@ -10,13 +10,15 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.misc;
|
package de.ellpeck.actuallyadditions.mod.misc;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.BlockDispenser;
|
import net.minecraft.block.BlockDispenser;
|
||||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||||
import net.minecraft.dispenser.IBlockSource;
|
import net.minecraft.dispenser.IBlockSource;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemBucket;
|
import net.minecraft.item.ItemBucket;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
public class DispenserHandlerEmptyBucket extends BehaviorDefaultDispenseItem{
|
public class DispenserHandlerEmptyBucket extends BehaviorDefaultDispenseItem{
|
||||||
|
@ -27,9 +29,9 @@ public class DispenserHandlerEmptyBucket extends BehaviorDefaultDispenseItem{
|
||||||
int x = source.getBlockTileEntity().getPos().getX()+facing.getFrontOffsetX();
|
int x = source.getBlockTileEntity().getPos().getX()+facing.getFrontOffsetX();
|
||||||
int y = source.getBlockTileEntity().getPos().getY()+facing.getFrontOffsetY();
|
int y = source.getBlockTileEntity().getPos().getY()+facing.getFrontOffsetY();
|
||||||
int z = source.getBlockTileEntity().getPos().getZ()+facing.getFrontOffsetZ();
|
int z = source.getBlockTileEntity().getPos().getZ()+facing.getFrontOffsetZ();
|
||||||
Position pos = new Position(x, y, z);
|
BlockPos pos = new BlockPos(x, y, z);
|
||||||
|
|
||||||
if(source.getWorld().isAirBlock(pos) && !pos.getMaterial(source.getWorld()).isSolid() && ((ItemBucket)bucket.getItem()).tryPlaceContainedLiquid(source.getWorld(), pos)){
|
if(source.getWorld().isAirBlock(pos) && !PosUtil.getMaterial(pos, source.getWorld()).isSolid() && ((ItemBucket)bucket.getItem()).tryPlaceContainedLiquid(source.getWorld(), pos)){
|
||||||
return new ItemStack(Items.bucket);
|
return new ItemStack(Items.bucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,13 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.misc;
|
package de.ellpeck.actuallyadditions.mod.misc;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import net.minecraft.block.BlockDispenser;
|
import net.minecraft.block.BlockDispenser;
|
||||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||||
import net.minecraft.dispenser.IBlockSource;
|
import net.minecraft.dispenser.IBlockSource;
|
||||||
import net.minecraft.item.ItemDye;
|
import net.minecraft.item.ItemDye;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
public class DispenserHandlerFertilize extends BehaviorDefaultDispenseItem{
|
public class DispenserHandlerFertilize extends BehaviorDefaultDispenseItem{
|
||||||
|
@ -26,7 +27,7 @@ public class DispenserHandlerFertilize extends BehaviorDefaultDispenseItem{
|
||||||
int x = source.getBlockTileEntity().getPos().getX()+facing.getFrontOffsetX();
|
int x = source.getBlockTileEntity().getPos().getX()+facing.getFrontOffsetX();
|
||||||
int y = source.getBlockTileEntity().getPos().getY()+facing.getFrontOffsetY();
|
int y = source.getBlockTileEntity().getPos().getY()+facing.getFrontOffsetY();
|
||||||
int z = source.getBlockTileEntity().getPos().getZ()+facing.getFrontOffsetZ();
|
int z = source.getBlockTileEntity().getPos().getZ()+facing.getFrontOffsetZ();
|
||||||
Position pos = new Position(x, y, z);
|
BlockPos pos = new BlockPos(x, y, z);
|
||||||
|
|
||||||
if(ItemDye.applyBonemeal(stack, source.getWorld(), pos, null)){
|
if(ItemDye.applyBonemeal(stack, source.getWorld(), pos, null)){
|
||||||
source.getWorld().playAuxSFX(2005, pos, 0);
|
source.getWorld().playAuxSFX(2005, pos, 0);
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.misc;
|
package de.ellpeck.actuallyadditions.mod.misc;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockDispenser;
|
import net.minecraft.block.BlockDispenser;
|
||||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||||
|
@ -19,6 +20,7 @@ import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntityDispenser;
|
import net.minecraft.tileentity.TileEntityDispenser;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
import net.minecraftforge.fluids.IFluidBlock;
|
||||||
|
@ -53,17 +55,17 @@ public class DispenserHandlerFillBucket extends BehaviorDefaultDispenseItem{
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack tryFillBucket(IBlockSource source, int x, int y, int z, ItemStack bucket){
|
private ItemStack tryFillBucket(IBlockSource source, int x, int y, int z, ItemStack bucket){
|
||||||
Position pos = new Position(x, y, z);
|
BlockPos pos = new BlockPos(x, y, z);
|
||||||
Block block = pos.getBlock(source.getWorld());
|
Block block = PosUtil.getBlock(pos, source.getWorld());
|
||||||
|
|
||||||
if(block == Blocks.water || block == Blocks.flowing_water){
|
if(block == Blocks.water || block == Blocks.flowing_water){
|
||||||
if(pos.getMetadata(source.getWorld()) == 0){
|
if(PosUtil.getMetadata(pos, source.getWorld()) == 0){
|
||||||
source.getWorld().setBlockToAir(pos);
|
source.getWorld().setBlockToAir(pos);
|
||||||
return new ItemStack(Items.water_bucket);
|
return new ItemStack(Items.water_bucket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(block == Blocks.lava || block == Blocks.flowing_lava){
|
else if(block == Blocks.lava || block == Blocks.flowing_lava){
|
||||||
if(pos.getMetadata(source.getWorld()) == 0){
|
if(PosUtil.getMetadata(pos, source.getWorld()) == 0){
|
||||||
source.getWorld().setBlockToAir(pos);
|
source.getWorld().setBlockToAir(pos);
|
||||||
return new ItemStack(Items.lava_bucket);
|
return new ItemStack(Items.lava_bucket);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,15 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.misc;
|
package de.ellpeck.actuallyadditions.mod.misc;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import io.netty.util.internal.ConcurrentSet;
|
import io.netty.util.internal.ConcurrentSet;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ public class LaserRelayConnectionHandler{
|
||||||
/**
|
/**
|
||||||
* Gets all Connections for a Relay
|
* Gets all Connections for a Relay
|
||||||
*/
|
*/
|
||||||
public ConcurrentSet<ConnectionPair> getConnectionsFor(Position relay){
|
public ConcurrentSet<ConnectionPair> getConnectionsFor(BlockPos relay){
|
||||||
ConcurrentSet<ConnectionPair> allPairs = new ConcurrentSet<ConnectionPair>();
|
ConcurrentSet<ConnectionPair> allPairs = new ConcurrentSet<ConnectionPair>();
|
||||||
for(Network aNetwork : this.networks){
|
for(Network aNetwork : this.networks){
|
||||||
for(ConnectionPair pair : aNetwork.connections){
|
for(ConnectionPair pair : aNetwork.connections){
|
||||||
|
@ -76,7 +77,7 @@ public class LaserRelayConnectionHandler{
|
||||||
/**
|
/**
|
||||||
* Removes a Relay from its Network
|
* Removes a Relay from its Network
|
||||||
*/
|
*/
|
||||||
public void removeRelayFromNetwork(Position relay){
|
public void removeRelayFromNetwork(BlockPos relay){
|
||||||
Network network = this.getNetworkFor(relay);
|
Network network = this.getNetworkFor(relay);
|
||||||
if(network != null){
|
if(network != null){
|
||||||
//Setup new network (so that splitting a network will cause it to break into two)
|
//Setup new network (so that splitting a network will cause it to break into two)
|
||||||
|
@ -94,7 +95,7 @@ public class LaserRelayConnectionHandler{
|
||||||
/**
|
/**
|
||||||
* Gets a Network for a Relay
|
* Gets a Network for a Relay
|
||||||
*/
|
*/
|
||||||
public Network getNetworkFor(Position relay){
|
public Network getNetworkFor(BlockPos relay){
|
||||||
for(Network aNetwork : this.networks){
|
for(Network aNetwork : this.networks){
|
||||||
for(ConnectionPair pair : aNetwork.connections){
|
for(ConnectionPair pair : aNetwork.connections){
|
||||||
if(pair.contains(relay)){
|
if(pair.contains(relay)){
|
||||||
|
@ -109,9 +110,9 @@ public class LaserRelayConnectionHandler{
|
||||||
* Adds a new connection between two relays
|
* Adds a new connection between two relays
|
||||||
* (Puts it into the correct network!)
|
* (Puts it into the correct network!)
|
||||||
*/
|
*/
|
||||||
public boolean addConnection(Position firstRelay, Position secondRelay){
|
public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay){
|
||||||
int distance = (int)firstRelay.toVec().distanceTo(secondRelay.toVec());
|
int distance = (int)PosUtil.toVec(firstRelay).distanceTo(PosUtil.toVec(secondRelay));
|
||||||
if(distance > TileEntityLaserRelay.MAX_DISTANCE || firstRelay.isEqual(secondRelay)){
|
if(distance > TileEntityLaserRelay.MAX_DISTANCE || PosUtil.areSamePos(firstRelay, secondRelay)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,21 +162,21 @@ public class LaserRelayConnectionHandler{
|
||||||
//System.out.println("Merged Two Networks!");
|
//System.out.println("Merged Two Networks!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int transferEnergyToReceiverInNeed(World world, Position energyGottenFrom, Network network, int maxTransfer, boolean simulate){
|
public int transferEnergyToReceiverInNeed(World world, BlockPos energyGottenFrom, Network network, int maxTransfer, boolean simulate){
|
||||||
int transmitted = 0;
|
int transmitted = 0;
|
||||||
//Go through all of the connections in the network
|
//Go through all of the connections in the network
|
||||||
for(ConnectionPair pair : network.connections){
|
for(ConnectionPair pair : network.connections){
|
||||||
Position[] relays = new Position[]{pair.firstRelay, pair.secondRelay};
|
BlockPos[] relays = new BlockPos[]{pair.firstRelay, pair.secondRelay};
|
||||||
//Go through both relays in the connection
|
//Go through both relays in the connection
|
||||||
for(Position relay : relays){
|
for(BlockPos relay : relays){
|
||||||
if(relay != null){
|
if(relay != null){
|
||||||
//Get every side of the relay
|
//Get every side of the relay
|
||||||
for(int i = 0; i <= 5; i++){
|
for(int i = 0; i <= 5; i++){
|
||||||
EnumFacing side = WorldUtil.getDirectionBySidesInOrder(i);
|
EnumFacing side = WorldUtil.getDirectionBySidesInOrder(i);
|
||||||
//Get the Position at the side
|
//Get the Position at the side
|
||||||
Position pos = WorldUtil.getCoordsFromSide(side, relay, 0);
|
BlockPos pos = WorldUtil.getCoordsFromSide(side, relay, 0);
|
||||||
if(!pos.isEqual(energyGottenFrom)){
|
if(!PosUtil.areSamePos(pos, energyGottenFrom)){
|
||||||
TileEntity tile = pos.getTileEntity(world);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if(tile instanceof IEnergyReceiver && !(tile instanceof TileEntityLaserRelay)){
|
if(tile instanceof IEnergyReceiver && !(tile instanceof TileEntityLaserRelay)){
|
||||||
IEnergyReceiver receiver = (IEnergyReceiver)tile;
|
IEnergyReceiver receiver = (IEnergyReceiver)tile;
|
||||||
if(receiver.canConnectEnergy(side.getOpposite())){
|
if(receiver.canConnectEnergy(side.getOpposite())){
|
||||||
|
@ -203,30 +204,30 @@ public class LaserRelayConnectionHandler{
|
||||||
|
|
||||||
public static class ConnectionPair{
|
public static class ConnectionPair{
|
||||||
|
|
||||||
public Position firstRelay;
|
public BlockPos firstRelay;
|
||||||
public Position secondRelay;
|
public BlockPos secondRelay;
|
||||||
|
|
||||||
public ConnectionPair(Position firstRelay, Position secondRelay){
|
public ConnectionPair(BlockPos firstRelay, BlockPos secondRelay){
|
||||||
this.firstRelay = firstRelay;
|
this.firstRelay = firstRelay;
|
||||||
this.secondRelay = secondRelay;
|
this.secondRelay = secondRelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConnectionPair readFromNBT(NBTTagCompound compound){
|
public static ConnectionPair readFromNBT(NBTTagCompound compound){
|
||||||
if(compound != null){
|
if(compound != null){
|
||||||
Position[] pos = new Position[2];
|
BlockPos[] pos = new BlockPos[2];
|
||||||
for(int i = 0; i < pos.length; i++){
|
for(int i = 0; i < pos.length; i++){
|
||||||
int anX = compound.getInteger("x"+i);
|
int anX = compound.getInteger("x"+i);
|
||||||
int aY = compound.getInteger("y"+i);
|
int aY = compound.getInteger("y"+i);
|
||||||
int aZ = compound.getInteger("z"+i);
|
int aZ = compound.getInteger("z"+i);
|
||||||
pos[i] = new Position(anX, aY, aZ);
|
pos[i] = new BlockPos(anX, aY, aZ);
|
||||||
}
|
}
|
||||||
return new ConnectionPair(pos[0], pos[1]);
|
return new ConnectionPair(pos[0], pos[1]);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Position relay){
|
public boolean contains(BlockPos relay){
|
||||||
return (this.firstRelay != null && this.firstRelay.isEqual(relay)) || (this.secondRelay != null && this.secondRelay.isEqual(relay));
|
return (this.firstRelay != null && PosUtil.areSamePos(firstRelay, relay)) || (this.secondRelay != null && PosUtil.areSamePos(secondRelay, relay));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -237,7 +238,7 @@ public class LaserRelayConnectionHandler{
|
||||||
public NBTTagCompound writeToNBT(){
|
public NBTTagCompound writeToNBT(){
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
for(int i = 0; i < 2; i++){
|
for(int i = 0; i < 2; i++){
|
||||||
Position relay = i == 0 ? this.firstRelay : this.secondRelay;
|
BlockPos relay = i == 0 ? this.firstRelay : this.secondRelay;
|
||||||
compound.setInteger("x"+i, relay.getX());
|
compound.setInteger("x"+i, relay.getX());
|
||||||
compound.setInteger("y"+i, relay.getY());
|
compound.setInteger("y"+i, relay.getY());
|
||||||
compound.setInteger("z"+i, relay.getZ());
|
compound.setInteger("z"+i, relay.getZ());
|
||||||
|
|
|
@ -11,12 +11,12 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.network;
|
package de.ellpeck.actuallyadditions.mod.network;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.internal.EntrySet;
|
import de.ellpeck.actuallyadditions.api.internal.EntrySet;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBookletStand;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBookletStand;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
|
@ -89,7 +89,7 @@ public class PacketBookletStandButton implements IMessage{
|
||||||
@Override
|
@Override
|
||||||
public IMessage onMessage(PacketBookletStandButton message, MessageContext ctx){
|
public IMessage onMessage(PacketBookletStandButton message, MessageContext ctx){
|
||||||
World world = DimensionManager.getWorld(message.worldID);
|
World world = DimensionManager.getWorld(message.worldID);
|
||||||
TileEntity tile = world.getTileEntity(new Position(message.tileX, message.tileY, message.tileZ));
|
TileEntity tile = world.getTileEntity(new BlockPos(message.tileX, message.tileY, message.tileZ));
|
||||||
EntityPlayer player = (EntityPlayer)world.getEntityByID(message.playerID);
|
EntityPlayer player = (EntityPlayer)world.getEntityByID(message.playerID);
|
||||||
|
|
||||||
if(tile instanceof TileEntityBookletStand){
|
if(tile instanceof TileEntityBookletStand){
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.network.gui;
|
package de.ellpeck.actuallyadditions.mod.network.gui;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
|
@ -68,7 +69,7 @@ public class PacketGuiButton implements IMessage{
|
||||||
@Override
|
@Override
|
||||||
public IMessage onMessage(PacketGuiButton message, MessageContext ctx){
|
public IMessage onMessage(PacketGuiButton message, MessageContext ctx){
|
||||||
World world = DimensionManager.getWorld(message.worldID);
|
World world = DimensionManager.getWorld(message.worldID);
|
||||||
TileEntity tile = world.getTileEntity(new Position(message.tileX, message.tileY, message.tileZ));
|
TileEntity tile = world.getTileEntity(new BlockPos(message.tileX, message.tileY, message.tileZ));
|
||||||
|
|
||||||
if(tile instanceof IButtonReactor){
|
if(tile instanceof IButtonReactor){
|
||||||
IButtonReactor reactor = (IButtonReactor)tile;
|
IButtonReactor reactor = (IButtonReactor)tile;
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.network.gui;
|
package de.ellpeck.actuallyadditions.mod.network.gui;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
|
@ -72,7 +73,7 @@ public class PacketGuiNumber implements IMessage{
|
||||||
@Override
|
@Override
|
||||||
public IMessage onMessage(PacketGuiNumber message, MessageContext ctx){
|
public IMessage onMessage(PacketGuiNumber message, MessageContext ctx){
|
||||||
World world = DimensionManager.getWorld(message.worldID);
|
World world = DimensionManager.getWorld(message.worldID);
|
||||||
TileEntity tile = world.getTileEntity(new Position(message.tileX, message.tileY, message.tileZ));
|
TileEntity tile = world.getTileEntity(new BlockPos(message.tileX, message.tileY, message.tileZ));
|
||||||
|
|
||||||
if(tile instanceof INumberReactor){
|
if(tile instanceof INumberReactor){
|
||||||
INumberReactor reactor = (INumberReactor)tile;
|
INumberReactor reactor = (INumberReactor)tile;
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.network.gui;
|
package de.ellpeck.actuallyadditions.mod.network.gui;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
|
@ -83,7 +84,7 @@ public class PacketGuiString implements IMessage{
|
||||||
@Override
|
@Override
|
||||||
public IMessage onMessage(PacketGuiString message, MessageContext ctx){
|
public IMessage onMessage(PacketGuiString message, MessageContext ctx){
|
||||||
World world = DimensionManager.getWorld(message.worldID);
|
World world = DimensionManager.getWorld(message.worldID);
|
||||||
TileEntity tile = world.getTileEntity(new Position(message.tileX, message.tileY, message.tileZ));
|
TileEntity tile = world.getTileEntity(new BlockPos(message.tileX, message.tileY, message.tileZ));
|
||||||
|
|
||||||
if(tile instanceof IStringReactor){
|
if(tile instanceof IStringReactor){
|
||||||
IStringReactor reactor = (IStringReactor)tile;
|
IStringReactor reactor = (IStringReactor)tile;
|
||||||
|
|
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
|
@ -21,9 +20,11 @@ import de.ellpeck.actuallyadditions.mod.items.lens.Lenses;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||||
|
@ -68,8 +69,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
|
|
||||||
private void doWork(){
|
private void doWork(){
|
||||||
if(this.storage.getEnergyStored() >= ENERGY_USE){
|
if(this.storage.getEnergyStored() >= ENERGY_USE){
|
||||||
Position thisPos = Position.fromTileEntity(this);
|
EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(PosUtil.getMetadata(this.pos, worldObj));
|
||||||
EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(thisPos.getMetadata(worldObj));
|
|
||||||
//Extract energy for shooting the laser itself too!
|
//Extract energy for shooting the laser itself too!
|
||||||
this.storage.extractEnergy(ENERGY_USE, false);
|
this.storage.extractEnergy(ENERGY_USE, false);
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
Lens currentLens = this.getCurrentLens();
|
Lens currentLens = this.getCurrentLens();
|
||||||
int distance = currentLens.getDistance();
|
int distance = currentLens.getDistance();
|
||||||
for(int i = 0; i < distance; i++){
|
for(int i = 0; i < distance; i++){
|
||||||
Position hitBlock = WorldUtil.getCoordsFromSide(sideToManipulate, thisPos, i);
|
BlockPos hitBlock = WorldUtil.getCoordsFromSide(sideToManipulate, this.pos, i);
|
||||||
|
|
||||||
if(currentLens.invoke(hitBlock, this)){
|
if(currentLens.invoke(hitBlock, this)){
|
||||||
this.shootLaser(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens);
|
this.shootLaser(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens);
|
||||||
|
|
|
@ -10,12 +10,14 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockAir;
|
import net.minecraft.block.BlockAir;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -67,26 +69,26 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doWork(){
|
private void doWork(){
|
||||||
EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(Position.fromTileEntity(this).getMetadata(worldObj));
|
EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(PosUtil.getMetadata(this.pos, worldObj));
|
||||||
|
|
||||||
Position coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, Position.fromTileEntity(this), 0);
|
BlockPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, this.pos, 0);
|
||||||
if(coordsBlock != null){
|
if(coordsBlock != null){
|
||||||
Block blockToBreak = coordsBlock.getBlock(worldObj);
|
Block blockToBreak = PosUtil.getBlock(coordsBlock, worldObj);
|
||||||
if(!this.isPlacer && blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, coordsBlock) > -1.0F){
|
if(!this.isPlacer && blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, coordsBlock) > -1.0F){
|
||||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
int meta = coordsBlock.getMetadata(worldObj);
|
int meta = PosUtil.getMetadata(coordsBlock, worldObj);
|
||||||
drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock, coordsBlock.getBlockState(worldObj), 0));
|
drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock, worldObj.getBlockState(coordsBlock), 0));
|
||||||
|
|
||||||
if(WorldUtil.addToInventory(this, drops, false, true)){
|
if(WorldUtil.addToInventory(this, drops, false, true)){
|
||||||
worldObj.playAuxSFX(2001, coordsBlock, Block.getIdFromBlock(blockToBreak)+(meta << 12));
|
worldObj.playAuxSFX(2001, coordsBlock, Block.getIdFromBlock(blockToBreak)+(meta << 12));
|
||||||
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, Position.fromTileEntity(this));
|
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, this.pos);
|
||||||
WorldUtil.addToInventory(this, drops, true, true);
|
WorldUtil.addToInventory(this, drops, true, true);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(this.isPlacer && coordsBlock.getBlock(worldObj).isReplaceable(worldObj, coordsBlock)){
|
else if(this.isPlacer && PosUtil.getBlock(coordsBlock, worldObj).isReplaceable(worldObj, coordsBlock)){
|
||||||
int theSlot = WorldUtil.findFirstFilledSlot(this.slots);
|
int theSlot = WorldUtil.findFirstFilledSlot(this.slots);
|
||||||
this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, Position.fromTileEntity(this), this.slots[theSlot]));
|
this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, this.pos, this.slots[theSlot]));
|
||||||
if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0){
|
if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0){
|
||||||
this.slots[theSlot] = null;
|
this.slots[theSlot] = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||||
|
@ -85,12 +84,12 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
|
||||||
WorldUtil.fillBucket(tank, slots, 1, 2);
|
WorldUtil.fillBucket(tank, slots, 1, 2);
|
||||||
|
|
||||||
if(this.tank.getFluidAmount() > 0){
|
if(this.tank.getFluidAmount() > 0){
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.DOWN, this.tank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.DOWN, this.tank);
|
||||||
if(!this.isRedstonePowered){
|
if(!this.isRedstonePowered){
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.NORTH, this.tank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.NORTH, this.tank);
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.EAST, this.tank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.EAST, this.tank);
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.SOUTH, this.tank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.SOUTH, this.tank);
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.WEST, this.tank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.WEST, this.tank);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyProvider;
|
import cofh.api.energy.IEnergyProvider;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -69,20 +69,19 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.storage.getEnergyStored() > 0){
|
if(this.storage.getEnergyStored() > 0){
|
||||||
WorldUtil.pushEnergyToAllSides(worldObj, Position.fromTileEntity(this), this.storage);
|
WorldUtil.pushEnergyToAllSides(worldObj, this.pos, this.storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flag != this.currentBurnTime > 0){
|
if(flag != this.currentBurnTime > 0){
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
Position thisPos = Position.fromTileEntity(this);
|
int meta = PosUtil.getMetadata(this.getPos(), worldObj);
|
||||||
int meta = thisPos.getMetadata(worldObj);
|
|
||||||
if(meta == 1){
|
if(meta == 1){
|
||||||
if(!(this.currentBurnTime <= 0 && this.slots[0] != null && TileEntityFurnace.getItemBurnTime(this.slots[0]) > 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored())){
|
if(!(this.currentBurnTime <= 0 && this.slots[0] != null && TileEntityFurnace.getItemBurnTime(this.slots[0]) > 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored())){
|
||||||
thisPos.setMetadata(worldObj, 0, 2);
|
PosUtil.setMetadata(this.pos, worldObj, 0, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
thisPos.setMetadata(worldObj, 1, 2);
|
PosUtil.setMetadata(this.pos, worldObj, 1, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,13 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockAir;
|
import net.minecraft.block.BlockAir;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
@ -63,21 +64,20 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doWork(){
|
private void doWork(){
|
||||||
Position pos = Position.fromTileEntity(this);
|
EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(PosUtil.getMetadata(this.pos, worldObj));
|
||||||
EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(pos.getMetadata(worldObj));
|
|
||||||
|
|
||||||
for(int i = 0; i < RANGE; i++){
|
for(int i = 0; i < RANGE; i++){
|
||||||
Position coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, pos, i);
|
BlockPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, pos, i);
|
||||||
if(coordsBlock != null){
|
if(coordsBlock != null){
|
||||||
Block blockToBreak = coordsBlock.getBlock(worldObj);
|
Block blockToBreak = PosUtil.getBlock(coordsBlock, worldObj);
|
||||||
if(blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, pos) > -1.0F){
|
if(blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, pos) > -1.0F){
|
||||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
int meta = coordsBlock.getMetadata(worldObj);
|
int meta = PosUtil.getMetadata(coordsBlock, worldObj);
|
||||||
drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock, coordsBlock.getBlockState(worldObj), 0));
|
drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock, worldObj.getBlockState(coordsBlock), 0));
|
||||||
|
|
||||||
if(WorldUtil.addToInventory(this, drops, false, true)){
|
if(WorldUtil.addToInventory(this, drops, false, true)){
|
||||||
worldObj.playAuxSFX(2001, this.getPos(), Block.getIdFromBlock(blockToBreak)+(meta << 12));
|
worldObj.playAuxSFX(2001, this.getPos(), Block.getIdFromBlock(blockToBreak)+(meta << 12));
|
||||||
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, Position.fromTileEntity(this), i);
|
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, this.getPos(), i);
|
||||||
WorldUtil.addToInventory(this, drops, true, true);
|
WorldUtil.addToInventory(this, drops, true, true);
|
||||||
this.storage.extractEnergy(ENERGY_USE, false);
|
this.storage.extractEnergy(ENERGY_USE, false);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -60,7 +60,7 @@ public class TileEntityDropper extends TileEntityInventoryBase implements IRedst
|
||||||
if(this.removeFromInventory(false) != null){
|
if(this.removeFromInventory(false) != null){
|
||||||
ItemStack stack = this.removeFromInventory(true);
|
ItemStack stack = this.removeFromInventory(true);
|
||||||
stack.stackSize = 1;
|
stack.stackSize = 1;
|
||||||
WorldUtil.dropItemAtSide(WorldUtil.getDirectionByPistonRotation(Position.fromTileEntity(this).getMetadata(worldObj)), worldObj, Position.fromTileEntity(this), stack);
|
WorldUtil.dropItemAtSide(WorldUtil.getDirectionByPistonRotation(PosUtil.getMetadata(this.pos, worldObj)), worldObj, this.pos, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyContainerItem;
|
import cofh.api.energy.IEnergyContainerItem;
|
||||||
import cofh.api.energy.IEnergyProvider;
|
import cofh.api.energy.IEnergyProvider;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -50,7 +49,7 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.storage.getEnergyStored() > 0){
|
if(this.storage.getEnergyStored() > 0){
|
||||||
WorldUtil.pushEnergyToAllSides(worldObj, Position.fromTileEntity(this), this.storage);
|
WorldUtil.pushEnergyToAllSides(worldObj, this.pos, this.storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lastEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
|
if(lastEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
|
@ -59,12 +58,12 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
|
||||||
WorldUtil.fillBucket(oilTank, slots, 2, 3);
|
WorldUtil.fillBucket(oilTank, slots, 2, 3);
|
||||||
|
|
||||||
if(this.oilTank.getFluidAmount() > 0){
|
if(this.oilTank.getFluidAmount() > 0){
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.DOWN, this.oilTank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.DOWN, this.oilTank);
|
||||||
if(!this.isRedstonePowered){
|
if(!this.isRedstonePowered){
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.NORTH, this.oilTank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.NORTH, this.oilTank);
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.EAST, this.oilTank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.EAST, this.oilTank);
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.SOUTH, this.oilTank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.SOUTH, this.oilTank);
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.WEST, this.oilTank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.WEST, this.oilTank);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -33,13 +34,12 @@ public class TileEntityFishingNet extends TileEntityBase{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if(!worldObj.isRemote){
|
if(!worldObj.isRemote){
|
||||||
if(!this.isRedstonePowered){
|
if(!this.isRedstonePowered){
|
||||||
Position pos = Position.fromTileEntity(this);
|
if(PosUtil.getMaterial(PosUtil.offset(this.pos, 0, -1, 0), this.worldObj) == Material.water){
|
||||||
if(pos.getOffsetPosition(0, -1, 0).getMaterial(worldObj) == Material.water){
|
|
||||||
if(this.timeUntilNextDrop > 0){
|
if(this.timeUntilNextDrop > 0){
|
||||||
this.timeUntilNextDrop--;
|
this.timeUntilNextDrop--;
|
||||||
if(timeUntilNextDrop <= 0){
|
if(timeUntilNextDrop <= 0){
|
||||||
ItemStack fishable = FishingHooks.getRandomFishable(Util.RANDOM, Util.RANDOM.nextFloat());
|
ItemStack fishable = FishingHooks.getRandomFishable(Util.RANDOM, Util.RANDOM.nextFloat());
|
||||||
TileEntity tile = pos.getOffsetPosition(0, 1, 0).getTileEntity(worldObj);
|
TileEntity tile = worldObj.getTileEntity(PosUtil.offset(pos, 0, 1, 0));
|
||||||
if(tile != null && tile instanceof IInventory){
|
if(tile != null && tile instanceof IInventory){
|
||||||
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
|
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
|
||||||
list.add(fishable);
|
list.add(fishable);
|
||||||
|
|
|
@ -10,12 +10,14 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.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.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.fluids.*;
|
import net.minecraftforge.fluids.*;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
@ -54,39 +56,37 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doWork(){
|
private void doWork(){
|
||||||
Position thisPos = Position.fromTileEntity(this);
|
EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(PosUtil.getMetadata(this.pos, worldObj));
|
||||||
|
BlockPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, this.pos, 0);
|
||||||
EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(thisPos.getMetadata(worldObj));
|
|
||||||
Position coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, Position.fromTileEntity(this), 0);
|
|
||||||
|
|
||||||
if(coordsBlock != null){
|
if(coordsBlock != null){
|
||||||
Block blockToBreak = coordsBlock.getBlock(worldObj);
|
Block blockToBreak = PosUtil.getBlock(coordsBlock, worldObj);
|
||||||
if(!this.isPlacer && blockToBreak != null && coordsBlock.getMetadata(worldObj) == 0 && FluidContainerRegistry.BUCKET_VOLUME <= this.tank.getCapacity()-this.tank.getFluidAmount()){
|
if(!this.isPlacer && blockToBreak != null && PosUtil.getMetadata(coordsBlock, worldObj) == 0 && FluidContainerRegistry.BUCKET_VOLUME <= this.tank.getCapacity()-this.tank.getFluidAmount()){
|
||||||
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);
|
||||||
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, thisPos);
|
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, this.pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(blockToBreak == Blocks.lava || blockToBreak == Blocks.flowing_lava){
|
else if(blockToBreak == Blocks.lava || blockToBreak == Blocks.flowing_lava){
|
||||||
if(this.tank.fill(new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME), false) >= FluidContainerRegistry.BUCKET_VOLUME){
|
if(this.tank.fill(new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME), false) >= FluidContainerRegistry.BUCKET_VOLUME){
|
||||||
this.tank.fill(new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME), true);
|
this.tank.fill(new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME), true);
|
||||||
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, thisPos);
|
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, this.pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(blockToBreak == Blocks.water || blockToBreak == Blocks.flowing_water){
|
else if(blockToBreak == Blocks.water || blockToBreak == Blocks.flowing_water){
|
||||||
if(this.tank.fill(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), false) >= FluidContainerRegistry.BUCKET_VOLUME){
|
if(this.tank.fill(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), false) >= FluidContainerRegistry.BUCKET_VOLUME){
|
||||||
this.tank.fill(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), true);
|
this.tank.fill(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), true);
|
||||||
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, thisPos);
|
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, this.pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(this.isPlacer && coordsBlock.getBlock(worldObj).isReplaceable(worldObj, coordsBlock)){
|
else if(this.isPlacer && PosUtil.getBlock(coordsBlock, worldObj).isReplaceable(worldObj, coordsBlock)){
|
||||||
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 = coordsBlock.getBlock(worldObj);
|
Block block = PosUtil.getBlock(coordsBlock, worldObj);
|
||||||
if(!(block instanceof IFluidBlock) && block != Blocks.lava && block != Blocks.water && block != Blocks.flowing_lava && block != Blocks.flowing_water){
|
if(!(block instanceof IFluidBlock) && block != Blocks.lava && block != Blocks.water && block != Blocks.flowing_lava && block != Blocks.flowing_water){
|
||||||
WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, thisPos, new ItemStack(this.tank.getFluid().getFluid().getBlock()));
|
WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, this.pos, new ItemStack(this.tank.getFluid().getFluid().getBlock()));
|
||||||
this.tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
|
this.tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,12 +159,12 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.isPlacer && this.tank.getFluidAmount() > 0){
|
if(!this.isPlacer && this.tank.getFluidAmount() > 0){
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.DOWN, this.tank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.DOWN, this.tank);
|
||||||
if(!this.isRedstonePowered){
|
if(!this.isRedstonePowered){
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.NORTH, this.tank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.NORTH, this.tank);
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.EAST, this.tank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.EAST, this.tank);
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.SOUTH, this.tank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.SOUTH, this.tank);
|
||||||
WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.WEST, this.tank);
|
WorldUtil.pushFluid(worldObj, this.pos, EnumFacing.WEST, this.tank);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -81,15 +81,14 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
|
||||||
|
|
||||||
if(flag != (this.firstSmeltTime > 0 || this.secondSmeltTime > 0)){
|
if(flag != (this.firstSmeltTime > 0 || this.secondSmeltTime > 0)){
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
Position thisPos = Position.fromTileEntity(this);
|
int meta = PosUtil.getMetadata(this.pos, worldObj);
|
||||||
int meta = thisPos.getMetadata(worldObj);
|
|
||||||
if(meta > 3){
|
if(meta > 3){
|
||||||
if(!this.canSmeltOn(SLOT_INPUT_1, SLOT_OUTPUT_1) && !this.canSmeltOn(SLOT_INPUT_2, SLOT_OUTPUT_2)){
|
if(!this.canSmeltOn(SLOT_INPUT_1, SLOT_OUTPUT_1) && !this.canSmeltOn(SLOT_INPUT_2, SLOT_OUTPUT_2)){
|
||||||
thisPos.setMetadata(worldObj, meta-4, 2);
|
PosUtil.setMetadata(this.pos, worldObj, meta-4, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
thisPos.setMetadata(worldObj, meta+4, 2);
|
PosUtil.setMetadata(this.pos, worldObj, meta+4, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,11 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyProvider;
|
import cofh.api.energy.IEnergyProvider;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.tile.IEnergyDisplay;
|
import de.ellpeck.actuallyadditions.api.tile.IEnergyDisplay;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
@ -58,7 +59,7 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyPro
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.storage.getEnergyStored() > 0){
|
if(this.storage.getEnergyStored() > 0){
|
||||||
WorldUtil.pushEnergyToAllSides(worldObj, Position.fromTileEntity(this), this.storage);
|
WorldUtil.pushEnergyToAllSides(worldObj, this.pos, this.storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
|
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
|
||||||
|
@ -80,10 +81,9 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyPro
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBlockAbove(){
|
public boolean hasBlockAbove(){
|
||||||
Position pos = Position.fromTileEntity(this);
|
|
||||||
for(int y = 1; y <= worldObj.getHeight(); y++){
|
for(int y = 1; y <= worldObj.getHeight(); y++){
|
||||||
Position offset = pos.getOffsetPosition(0, y, 0);
|
BlockPos offset = PosUtil.offset(this.pos, 0, y, 0);
|
||||||
if(!offset.getBlock(worldObj).isAir(worldObj, offset)){
|
if(!PosUtil.getBlock(offset, worldObj).isAir(worldObj, offset)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,14 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
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.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraftforge.common.IPlantable;
|
import net.minecraftforge.common.IPlantable;
|
||||||
|
|
||||||
public class TileEntityGreenhouseGlass extends TileEntityBase{
|
public class TileEntityGreenhouseGlass extends TileEntityBase{
|
||||||
|
@ -30,12 +32,12 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{
|
||||||
if(this.timeUntilNextFert > 0){
|
if(this.timeUntilNextFert > 0){
|
||||||
this.timeUntilNextFert--;
|
this.timeUntilNextFert--;
|
||||||
if(timeUntilNextFert <= 0){
|
if(timeUntilNextFert <= 0){
|
||||||
Position blockToFert = this.blockToFertilize();
|
BlockPos blockToFert = this.blockToFertilize();
|
||||||
if(blockToFert != null){
|
if(blockToFert != null){
|
||||||
int metaBefore = blockToFert.getMetadata(worldObj);
|
int metaBefore = PosUtil.getMetadata(blockToFert, worldObj);
|
||||||
blockToFert.getBlock(worldObj).updateTick(worldObj, blockToFert, blockToFert.getBlockState(worldObj), Util.RANDOM);
|
PosUtil.getBlock(blockToFert, worldObj).updateTick(worldObj, blockToFert, worldObj.getBlockState(blockToFert), Util.RANDOM);
|
||||||
|
|
||||||
if(blockToFert.getMetadata(worldObj) != metaBefore){
|
if(PosUtil.getMetadata(blockToFert, worldObj) != metaBefore){
|
||||||
worldObj.playAuxSFX(2005, blockToFert, 0);
|
worldObj.playAuxSFX(2005, blockToFert, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,10 +51,10 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Position blockToFertilize(){
|
public BlockPos blockToFertilize(){
|
||||||
for(int i = -1; i > 0; i--){
|
for(int i = -1; i > 0; i--){
|
||||||
Position offset = Position.fromBlockPos(pos).getOffsetPosition(0, i, 0);
|
BlockPos offset = PosUtil.offset(this.pos, 0, i, 0);
|
||||||
Block block = offset.getBlock(worldObj);
|
Block block = PosUtil.getBlock(pos, worldObj);
|
||||||
if(block != null && !(worldObj.isAirBlock(offset))){
|
if(block != null && !(worldObj.isAirBlock(offset))){
|
||||||
if((block instanceof IGrowable || block instanceof IPlantable) && !(block instanceof BlockGrass)){
|
if((block instanceof IGrowable || block instanceof IPlantable) && !(block instanceof BlockGrass)){
|
||||||
return offset;
|
return offset;
|
||||||
|
|
|
@ -13,9 +13,9 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -125,15 +125,14 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
|
||||||
|
|
||||||
if(flag != (this.firstCrushTime > 0 || this.secondCrushTime > 0)){
|
if(flag != (this.firstCrushTime > 0 || this.secondCrushTime > 0)){
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
Position thisPos = Position.fromTileEntity(this);
|
int meta = PosUtil.getMetadata(this.pos, worldObj);
|
||||||
int meta = thisPos.getMetadata(worldObj);
|
|
||||||
if(meta == 1){
|
if(meta == 1){
|
||||||
if(!this.canCrushOn(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2) && (!this.isDouble || !this.canCrushOn(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2))){
|
if(!this.canCrushOn(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2) && (!this.isDouble || !this.canCrushOn(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2))){
|
||||||
thisPos.setMetadata(worldObj, 0, 2);
|
PosUtil.setMetadata(this.pos, worldObj, 0, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
thisPos.setMetadata(worldObj, 1, 2);
|
PosUtil.setMetadata(this.pos, worldObj, 1, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,14 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyProvider;
|
import cofh.api.energy.IEnergyProvider;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.tile.IEnergyDisplay;
|
import de.ellpeck.actuallyadditions.api.tile.IEnergyDisplay;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.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.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
@ -39,10 +40,10 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
|
||||||
ArrayList<Integer> blocksAround = new ArrayList<Integer>();
|
ArrayList<Integer> blocksAround = new ArrayList<Integer>();
|
||||||
if(ENERGY_PRODUCE <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){
|
if(ENERGY_PRODUCE <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){
|
||||||
for(int i = 1; i <= 5; i++){
|
for(int i = 1; i <= 5; i++){
|
||||||
Position coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionBySidesInOrder(i), Position.fromTileEntity(this), 0);
|
BlockPos coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionBySidesInOrder(i), this.pos, 0);
|
||||||
if(coords != null){
|
if(coords != null){
|
||||||
Block block = coords.getBlock(worldObj);
|
Block block = PosUtil.getBlock(coords, worldObj);
|
||||||
if(block != null && block.getMaterial() == Material.lava && coords.getMetadata(worldObj) == 0){
|
if(block != null && block.getMaterial() == Material.lava && PosUtil.getMetadata(coords, worldObj) == 0){
|
||||||
blocksAround.add(i);
|
blocksAround.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,13 +55,13 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
|
||||||
|
|
||||||
if(Util.RANDOM.nextInt(10000) == 0){
|
if(Util.RANDOM.nextInt(10000) == 0){
|
||||||
int randomSide = blocksAround.get(Util.RANDOM.nextInt(blocksAround.size()));
|
int randomSide = blocksAround.get(Util.RANDOM.nextInt(blocksAround.size()));
|
||||||
WorldUtil.breakBlockAtSide(WorldUtil.getDirectionBySidesInOrder(randomSide), worldObj, Position.fromTileEntity(this));
|
WorldUtil.breakBlockAtSide(WorldUtil.getDirectionBySidesInOrder(randomSide), worldObj, this.pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.storage.getEnergyStored() > 0){
|
if(this.storage.getEnergyStored() > 0){
|
||||||
WorldUtil.pushEnergy(worldObj, Position.fromTileEntity(this), EnumFacing.UP, this.storage);
|
WorldUtil.pushEnergy(worldObj, this.pos, EnumFacing.UP, this.storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
|
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
|
@ -303,8 +303,8 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
||||||
public void initVars(){
|
public void initVars(){
|
||||||
|
|
||||||
//Gets the Place to put and Pull
|
//Gets the Place to put and Pull
|
||||||
this.placeToPull = WorldUtil.getTileEntityFromSide(WorldUtil.getDirectionBySidesInOrder(this.sideToPull), this.worldObj, Position.fromTileEntity(this));
|
this.placeToPull = WorldUtil.getTileEntityFromSide(WorldUtil.getDirectionBySidesInOrder(this.sideToPull), this.worldObj, this.pos);
|
||||||
this.placeToPut = WorldUtil.getTileEntityFromSide(WorldUtil.getDirectionBySidesInOrder(this.sideToPut), this.worldObj, Position.fromTileEntity(this));
|
this.placeToPut = WorldUtil.getTileEntityFromSide(WorldUtil.getDirectionBySidesInOrder(this.sideToPut), this.worldObj, this.pos);
|
||||||
|
|
||||||
//Resets the Variables
|
//Resets the Variables
|
||||||
if(this.placeToPull instanceof IInventory){
|
if(this.placeToPull instanceof IInventory){
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler;
|
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import io.netty.util.internal.ConcurrentSet;
|
import io.netty.util.internal.ConcurrentSet;
|
||||||
|
@ -24,6 +24,7 @@ import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
@ -44,11 +45,11 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void renderParticles(){
|
public void renderParticles(){
|
||||||
if(Util.RANDOM.nextInt(ConfigBoolValues.LESS_LASER_RELAY_PARTICLES.isEnabled() ? 15 : 8) == 0){
|
if(Util.RANDOM.nextInt(ConfigBoolValues.LESS_LASER_RELAY_PARTICLES.isEnabled() ? 15 : 8) == 0){
|
||||||
Position thisPos = Position.fromTileEntity(this);
|
BlockPos thisPos = this.pos;
|
||||||
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(thisPos);
|
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(thisPos);
|
||||||
if(network != null){
|
if(network != null){
|
||||||
for(LaserRelayConnectionHandler.ConnectionPair aPair : network.connections){
|
for(LaserRelayConnectionHandler.ConnectionPair aPair : network.connections){
|
||||||
if(aPair.contains(thisPos) && thisPos.isEqual(aPair.firstRelay)){
|
if(aPair.contains(thisPos) && PosUtil.areSamePos(thisPos, aPair.firstRelay)){
|
||||||
PacketParticle.renderParticlesFromAToB(aPair.firstRelay.getX(), aPair.firstRelay.getY(), aPair.firstRelay.getZ(), aPair.secondRelay.getX(), aPair.secondRelay.getY(), aPair.secondRelay.getZ(), ConfigBoolValues.LESS_LASER_RELAY_PARTICLES.isEnabled() ? 1 : Util.RANDOM.nextInt(3)+1, 0.8F, COLOR, 1F);
|
PacketParticle.renderParticlesFromAToB(aPair.firstRelay.getX(), aPair.firstRelay.getY(), aPair.firstRelay.getZ(), aPair.secondRelay.getX(), aPair.secondRelay.getY(), aPair.secondRelay.getZ(), ConfigBoolValues.LESS_LASER_RELAY_PARTICLES.isEnabled() ? 1 : Util.RANDOM.nextInt(3)+1, 0.8F, COLOR, 1F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +61,7 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
||||||
public Packet getDescriptionPacket(){
|
public Packet getDescriptionPacket(){
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
|
|
||||||
Position thisPos = Position.fromTileEntity(this);
|
BlockPos thisPos = this.pos;
|
||||||
ConcurrentSet<LaserRelayConnectionHandler.ConnectionPair> connections = LaserRelayConnectionHandler.getInstance().getConnectionsFor(thisPos);
|
ConcurrentSet<LaserRelayConnectionHandler.ConnectionPair> connections = LaserRelayConnectionHandler.getInstance().getConnectionsFor(thisPos);
|
||||||
|
|
||||||
if(connections != null){
|
if(connections != null){
|
||||||
|
@ -76,7 +77,7 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){
|
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){
|
||||||
Position thisPos = Position.fromTileEntity(this);
|
BlockPos thisPos = this.pos;
|
||||||
if(pkt != null && pkt.getNbtCompound() != null){
|
if(pkt != null && pkt.getNbtCompound() != null){
|
||||||
LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(thisPos);
|
LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(thisPos);
|
||||||
|
|
||||||
|
@ -94,12 +95,12 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
||||||
@Override
|
@Override
|
||||||
public void invalidate(){
|
public void invalidate(){
|
||||||
super.invalidate();
|
super.invalidate();
|
||||||
LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(Position.fromTileEntity(this));
|
LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(this.pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
|
||||||
return this.transmitEnergy(WorldUtil.getCoordsFromSide(from, Position.fromTileEntity(this), 0), maxReceive, simulate);
|
return this.transmitEnergy(WorldUtil.getCoordsFromSide(from, this.pos, 0), maxReceive, simulate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,10 +113,10 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int transmitEnergy(Position blockFrom, int maxTransmit, boolean simulate){
|
public int transmitEnergy(BlockPos blockFrom, int maxTransmit, boolean simulate){
|
||||||
int transmitted = 0;
|
int transmitted = 0;
|
||||||
if(maxTransmit > 0){
|
if(maxTransmit > 0){
|
||||||
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(Position.fromTileEntity(this));
|
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(this.pos);
|
||||||
if(network != null){
|
if(network != null){
|
||||||
transmitted = LaserRelayConnectionHandler.getInstance().transferEnergyToReceiverInNeed(worldObj, 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,14 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.tile.IEnergyDisplay;
|
import de.ellpeck.actuallyadditions.api.tile.IEnergyDisplay;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
@ -42,7 +43,7 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
|
||||||
this.currentWorkTime++;
|
this.currentWorkTime++;
|
||||||
if(this.currentWorkTime >= 200){
|
if(this.currentWorkTime >= 200){
|
||||||
this.currentWorkTime = 0;
|
this.currentWorkTime = 0;
|
||||||
Position.fromTileEntity(this).getOffsetPosition(0, 1, 0).setBlock(worldObj, Blocks.lava, 0, 2);
|
PosUtil.setBlock(PosUtil.offset(this.pos, 0, 1, 0), worldObj, Blocks.lava, 0, 2);
|
||||||
this.storage.extractEnergy(ENERGY_USE, false);
|
this.storage.extractEnergy(ENERGY_USE, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,20 +72,20 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
public int isMultiblock(){
|
public int isMultiblock(){
|
||||||
Position thisPos = Position.fromTileEntity(this);
|
BlockPos thisPos = this.pos;
|
||||||
Position[] positions = new Position[]{
|
BlockPos[] positions = new BlockPos[]{
|
||||||
thisPos.getOffsetPosition(1, 1, 0),
|
PosUtil.offset(thisPos, 1, 1, 0),
|
||||||
thisPos.getOffsetPosition(-1, 1, 0),
|
PosUtil.offset(thisPos, -1, 1, 0),
|
||||||
thisPos.getOffsetPosition(0, 1, 1),
|
PosUtil.offset(thisPos, 0, 1, 1),
|
||||||
thisPos.getOffsetPosition(0, 1, -1)
|
PosUtil.offset(thisPos, 0, 1, -1)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(WorldUtil.hasBlocksInPlacesGiven(positions, InitBlocks.blockMisc, TheMiscBlocks.LAVA_FACTORY_CASE.ordinal(), worldObj)){
|
if(WorldUtil.hasBlocksInPlacesGiven(positions, InitBlocks.blockMisc, TheMiscBlocks.LAVA_FACTORY_CASE.ordinal(), worldObj)){
|
||||||
Position pos = thisPos.getOffsetPosition(0, 1, 0);
|
BlockPos pos = PosUtil.offset(thisPos, 0, 1, 0);
|
||||||
if(pos.getBlock(worldObj) == Blocks.lava || pos.getBlock(worldObj) == Blocks.flowing_lava){
|
if(PosUtil.getBlock(pos, worldObj) == Blocks.lava || PosUtil.getBlock(pos, worldObj) == Blocks.flowing_lava){
|
||||||
return HAS_LAVA;
|
return HAS_LAVA;
|
||||||
}
|
}
|
||||||
if(pos.getBlock(worldObj) == null || worldObj.isAirBlock(pos)){
|
if(PosUtil.getBlock(pos, worldObj) == null || worldObj.isAirBlock(pos)){
|
||||||
return HAS_AIR;
|
return HAS_AIR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,14 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyProvider;
|
import cofh.api.energy.IEnergyProvider;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.tile.IEnergyDisplay;
|
import de.ellpeck.actuallyadditions.api.tile.IEnergyDisplay;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
@ -46,13 +47,13 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
|
||||||
this.nextUseCounter = 0;
|
this.nextUseCounter = 0;
|
||||||
|
|
||||||
if(ENERGY_PRODUCED <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){
|
if(ENERGY_PRODUCED <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){
|
||||||
ArrayList<Position> breakPositions = new ArrayList<Position>();
|
ArrayList<BlockPos> breakPositions = new ArrayList<BlockPos>();
|
||||||
|
|
||||||
for(int reachX = -RANGE; reachX < RANGE+1; reachX++){
|
for(int reachX = -RANGE; reachX < RANGE+1; reachX++){
|
||||||
for(int reachZ = -RANGE; reachZ < RANGE+1; reachZ++){
|
for(int reachZ = -RANGE; reachZ < RANGE+1; reachZ++){
|
||||||
for(int reachY = -RANGE; reachY < RANGE+1; reachY++){
|
for(int reachY = -RANGE; reachY < RANGE+1; reachY++){
|
||||||
Position pos = new Position(this.pos.getX()+reachX, this.pos.getY()+reachY, this.pos.getZ()+reachZ);
|
BlockPos pos = PosUtil.offset(this.pos, reachX, reachY, reachZ);
|
||||||
Block block = pos.getBlock(worldObj);
|
Block block = PosUtil.getBlock(pos, worldObj);
|
||||||
if(block != null && block.isLeaves(this.worldObj, pos)){
|
if(block != null && block.isLeaves(this.worldObj, pos)){
|
||||||
breakPositions.add(pos);
|
breakPositions.add(pos);
|
||||||
}
|
}
|
||||||
|
@ -62,10 +63,10 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
|
||||||
|
|
||||||
if(!breakPositions.isEmpty()){
|
if(!breakPositions.isEmpty()){
|
||||||
Collections.shuffle(breakPositions);
|
Collections.shuffle(breakPositions);
|
||||||
Position theCoord = breakPositions.get(0);
|
BlockPos theCoord = breakPositions.get(0);
|
||||||
|
|
||||||
Block theBlock = theCoord.getBlock(worldObj);
|
Block theBlock = PosUtil.getBlock(theCoord, worldObj);
|
||||||
int meta = theCoord.getMetadata(worldObj);
|
int meta = PosUtil.getMetadata(theCoord, worldObj);
|
||||||
this.worldObj.playAuxSFX(2001, theCoord, Block.getIdFromBlock(theBlock)+(meta << 12));
|
this.worldObj.playAuxSFX(2001, theCoord, Block.getIdFromBlock(theBlock)+(meta << 12));
|
||||||
|
|
||||||
this.worldObj.setBlockToAir(this.getPos());
|
this.worldObj.setBlockToAir(this.getPos());
|
||||||
|
@ -82,7 +83,7 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.storage.getEnergyStored() > 0){
|
if(this.storage.getEnergyStored() > 0){
|
||||||
WorldUtil.pushEnergyToAllSides(worldObj, Position.fromTileEntity(this), this.storage);
|
WorldUtil.pushEnergyToAllSides(worldObj, this.pos, this.storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
|
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
|
||||||
|
|
|
@ -12,18 +12,19 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.tile.IEnergyDisplay;
|
import de.ellpeck.actuallyadditions.api.tile.IEnergyDisplay;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockLiquid;
|
import net.minecraft.block.BlockLiquid;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
import net.minecraftforge.fluids.IFluidBlock;
|
||||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||||
|
@ -58,7 +59,7 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyR
|
||||||
if(!this.isRedstonePowered && this.ticksElapsed%5 == 0){
|
if(!this.isRedstonePowered && this.ticksElapsed%5 == 0){
|
||||||
|
|
||||||
if(this.layerAt > 0){
|
if(this.layerAt > 0){
|
||||||
if(this.mine(TileEntityPhantomface.upgradeRange(DEFAULT_RANGE, worldObj, Position.fromTileEntity(this)))){
|
if(this.mine(TileEntityPhantomface.upgradeRange(DEFAULT_RANGE, worldObj, this.pos))){
|
||||||
this.layerAt--;
|
this.layerAt--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,14 +77,14 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyR
|
||||||
for(int aZ = -range; aZ <= range; aZ++){
|
for(int aZ = -range; aZ <= range; aZ++){
|
||||||
int actualUse = ENERGY_USE_PER_BLOCK*(this.onlyMineOres ? 3 : 1);
|
int actualUse = ENERGY_USE_PER_BLOCK*(this.onlyMineOres ? 3 : 1);
|
||||||
if(this.storage.getEnergyStored() >= actualUse){
|
if(this.storage.getEnergyStored() >= actualUse){
|
||||||
Position pos = new Position(this.pos.getX()+anX, this.layerAt, this.pos.getZ()+aZ);
|
BlockPos pos = new BlockPos(this.pos.getX()+anX, this.layerAt, this.pos.getZ()+aZ);
|
||||||
|
|
||||||
Block block = pos.getBlock(worldObj);
|
Block block = PosUtil.getBlock(pos, worldObj);
|
||||||
int meta = pos.getMetadata(worldObj);
|
int meta = PosUtil.getMetadata(pos, worldObj);
|
||||||
if(block != null && !block.isAir(this.worldObj, pos)){
|
if(block != null && !block.isAir(this.worldObj, pos)){
|
||||||
if(block.getHarvestLevel(pos.getBlockState(worldObj)) <= 3F && block.getBlockHardness(this.worldObj, pos) >= 0F && !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock) && this.isMinable(block, meta)){
|
if(block.getHarvestLevel(worldObj.getBlockState(pos)) <= 3F && block.getBlockHardness(this.worldObj, pos) >= 0F && !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock) && this.isMinable(block, meta)){
|
||||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
drops.addAll(block.getDrops(worldObj, pos, pos.getBlockState(worldObj), 0));
|
drops.addAll(block.getDrops(worldObj, pos, worldObj.getBlockState(pos), 0));
|
||||||
|
|
||||||
if(WorldUtil.addToInventory(this, drops, false, true)){
|
if(WorldUtil.addToInventory(this, drops, false, true)){
|
||||||
worldObj.playAuxSFX(2001, pos, Block.getIdFromBlock(block)+(meta << 12));
|
worldObj.playAuxSFX(2001, pos, Block.getIdFromBlock(block)+(meta << 12));
|
||||||
|
|
|
@ -12,8 +12,8 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyProvider;
|
import cofh.api.energy.IEnergyProvider;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -75,20 +75,19 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
|
||||||
WorldUtil.emptyBucket(tank, slots, 0, 1, InitBlocks.fluidOil);
|
WorldUtil.emptyBucket(tank, slots, 0, 1, InitBlocks.fluidOil);
|
||||||
|
|
||||||
if(this.storage.getEnergyStored() > 0){
|
if(this.storage.getEnergyStored() > 0){
|
||||||
WorldUtil.pushEnergyToAllSides(worldObj, Position.fromTileEntity(this), this.storage);
|
WorldUtil.pushEnergyToAllSides(worldObj, this.pos, this.storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flag != this.currentBurnTime > 0){
|
if(flag != this.currentBurnTime > 0){
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
Position thisPos = Position.fromTileEntity(this);
|
int meta = PosUtil.getMetadata(pos, worldObj);
|
||||||
int meta = thisPos.getMetadata(worldObj);
|
|
||||||
if(meta == 1){
|
if(meta == 1){
|
||||||
if(!(ENERGY_PRODUCED*BURN_TIME <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored() && this.currentBurnTime <= 0 && this.tank.getFluidAmount() >= fuelUsed)){
|
if(!(ENERGY_PRODUCED*BURN_TIME <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored() && this.currentBurnTime <= 0 && this.tank.getFluidAmount() >= fuelUsed)){
|
||||||
thisPos.setMetadata(worldObj, 0, 2);
|
PosUtil.setMetadata(this.pos, worldObj, 0, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
thisPos.setMetadata(worldObj, 1, 2);
|
PosUtil.setMetadata(this.pos, worldObj, 1, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
import cofh.api.energy.IEnergyHandler;
|
import cofh.api.energy.IEnergyHandler;
|
||||||
import cofh.api.energy.IEnergyProvider;
|
import cofh.api.energy.IEnergyProvider;
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -104,7 +103,7 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pushEnergy(EnumFacing side){
|
private void pushEnergy(EnumFacing side){
|
||||||
TileEntity tile = WorldUtil.getTileEntityFromSide(side, worldObj, Position.fromTileEntity(this));
|
TileEntity tile = WorldUtil.getTileEntityFromSide(side, worldObj, this.getPos());
|
||||||
if(tile != null && tile instanceof IEnergyReceiver && this.getProvider().getEnergyStored(side.getOpposite()) > 0){
|
if(tile != null && tile instanceof IEnergyReceiver && this.getProvider().getEnergyStored(side.getOpposite()) > 0){
|
||||||
if(((IEnergyReceiver)tile).canConnectEnergy(side.getOpposite()) && this.canConnectEnergy(side)){
|
if(((IEnergyReceiver)tile).canConnectEnergy(side.getOpposite()) && this.canConnectEnergy(side)){
|
||||||
int receive = this.extractEnergy(side, Math.min(((IEnergyReceiver)tile).getMaxEnergyStored(side.getOpposite())-((IEnergyReceiver)tile).getEnergyStored(side.getOpposite()), this.getEnergyStored(side)), true);
|
int receive = this.extractEnergy(side, Math.min(((IEnergyReceiver)tile).getMaxEnergyStored(side.getOpposite())-((IEnergyReceiver)tile).getEnergyStored(side.getOpposite()), this.getEnergyStored(side)), true);
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -45,7 +44,7 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
||||||
|
|
||||||
public IFluidHandler getHandler(){
|
public IFluidHandler getHandler(){
|
||||||
if(this.boundPosition != null){
|
if(this.boundPosition != null){
|
||||||
TileEntity tile = boundPosition.getTileEntity(worldObj);
|
TileEntity tile = worldObj.getTileEntity(boundPosition);
|
||||||
if(tile instanceof IFluidHandler){
|
if(tile instanceof IFluidHandler){
|
||||||
return (IFluidHandler)tile;
|
return (IFluidHandler)tile;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +53,7 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pushFluid(EnumFacing side){
|
private void pushFluid(EnumFacing side){
|
||||||
TileEntity tile = WorldUtil.getTileEntityFromSide(side, worldObj, Position.fromTileEntity(this));
|
TileEntity tile = WorldUtil.getTileEntityFromSide(side, worldObj, this.pos);
|
||||||
if(tile != null && tile instanceof IFluidHandler && this.getTankInfo(side) != null && this.getTankInfo(side).length > 0 && ((IFluidHandler)tile).getTankInfo(side.getOpposite()) != null && ((IFluidHandler)tile).getTankInfo(side.getOpposite()).length > 0){
|
if(tile != null && tile instanceof IFluidHandler && this.getTankInfo(side) != null && this.getTankInfo(side).length > 0 && ((IFluidHandler)tile).getTankInfo(side.getOpposite()) != null && ((IFluidHandler)tile).getTankInfo(side.getOpposite()).length > 0){
|
||||||
for(FluidTankInfo myInfo : this.getTankInfo(side)){
|
for(FluidTankInfo myInfo : this.getTankInfo(side)){
|
||||||
for(FluidTankInfo hisInfo : ((IFluidHandler)tile).getTankInfo(side.getOpposite())){
|
for(FluidTankInfo hisInfo : ((IFluidHandler)tile).getTankInfo(side.getOpposite())){
|
||||||
|
@ -74,7 +73,7 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBoundThingInRange(){
|
public boolean isBoundThingInRange(){
|
||||||
return super.isBoundThingInRange() && boundPosition.getTileEntity(worldObj) instanceof IFluidHandler;
|
return super.isBoundThingInRange() && worldObj.getTileEntity(boundPosition) instanceof IFluidHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,15 +10,16 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.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.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.EnumParticleTypes;
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
|
@ -30,7 +31,7 @@ import java.util.ArrayList;
|
||||||
public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements IPhantomTile, IRedstoneToggle{
|
public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements IPhantomTile, IRedstoneToggle{
|
||||||
|
|
||||||
public static final int RANGE = 3;
|
public static final int RANGE = 3;
|
||||||
public Position boundPosition;
|
public BlockPos boundPosition;
|
||||||
public int currentTime;
|
public int currentTime;
|
||||||
public int range;
|
public int range;
|
||||||
public boolean isBreaker;
|
public boolean isBreaker;
|
||||||
|
@ -50,7 +51,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
||||||
public void updateEntity(){
|
public void updateEntity(){
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if(!worldObj.isRemote){
|
if(!worldObj.isRemote){
|
||||||
this.range = TileEntityPhantomface.upgradeRange(RANGE, worldObj, Position.fromTileEntity(this));
|
this.range = TileEntityPhantomface.upgradeRange(RANGE, worldObj, this.pos);
|
||||||
|
|
||||||
if(!this.hasBoundPosition()){
|
if(!this.hasBoundPosition()){
|
||||||
this.boundPosition = null;
|
this.boundPosition = null;
|
||||||
|
@ -97,11 +98,11 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
||||||
|
|
||||||
private void doWork(){
|
private void doWork(){
|
||||||
if(this.isBreaker){
|
if(this.isBreaker){
|
||||||
Block blockToBreak = boundPosition.getBlock(worldObj);
|
Block blockToBreak = PosUtil.getBlock(boundPosition, worldObj);
|
||||||
if(blockToBreak != null && blockToBreak.getBlockHardness(worldObj, boundPosition) > -1.0F){
|
if(blockToBreak != null && blockToBreak.getBlockHardness(worldObj, boundPosition) > -1.0F){
|
||||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
int meta = boundPosition.getMetadata(worldObj);
|
int meta = PosUtil.getMetadata(boundPosition, worldObj);
|
||||||
drops.addAll(blockToBreak.getDrops(worldObj, boundPosition, boundPosition.getBlockState(worldObj), 0));
|
drops.addAll(blockToBreak.getDrops(worldObj, boundPosition, worldObj.getBlockState(boundPosition), 0));
|
||||||
|
|
||||||
if(WorldUtil.addToInventory(this, drops, false, true)){
|
if(WorldUtil.addToInventory(this, drops, false, true)){
|
||||||
worldObj.playAuxSFX(2001, this.boundPosition, Block.getIdFromBlock(blockToBreak)+(meta << 12));
|
worldObj.playAuxSFX(2001, this.boundPosition, Block.getIdFromBlock(blockToBreak)+(meta << 12));
|
||||||
|
@ -112,7 +113,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(boundPosition.getBlock(worldObj).isReplaceable(worldObj, boundPosition)){
|
if(PosUtil.getBlock(boundPosition, worldObj).isReplaceable(worldObj, boundPosition)){
|
||||||
int theSlot = WorldUtil.findFirstFilledSlot(this.slots);
|
int theSlot = WorldUtil.findFirstFilledSlot(this.slots);
|
||||||
this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(EnumFacing.UP, worldObj, boundPosition, this.slots[theSlot]));
|
this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(EnumFacing.UP, worldObj, boundPosition, this.slots[theSlot]));
|
||||||
if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0){
|
if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0){
|
||||||
|
@ -143,17 +144,17 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBoundThingInRange(){
|
public boolean isBoundThingInRange(){
|
||||||
return this.hasBoundPosition() && this.boundPosition.toVec().distanceTo(new Vec3(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ())) <= this.range;
|
return this.hasBoundPosition() && PosUtil.toVec(this.boundPosition).distanceTo(new Vec3(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ())) <= this.range;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Position getBoundPosition(){
|
public BlockPos getBoundPosition(){
|
||||||
return this.boundPosition;
|
return this.boundPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBoundPosition(Position pos){
|
public void setBoundPosition(BlockPos pos){
|
||||||
this.boundPosition = pos == null ? null : pos.copy();
|
this.boundPosition = pos == null ? null : PosUtil.copyPos(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -185,7 +186,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
||||||
int z = compound.getInteger("ZCoordOfTileStored");
|
int z = compound.getInteger("ZCoordOfTileStored");
|
||||||
this.range = compound.getInteger("Range");
|
this.range = compound.getInteger("Range");
|
||||||
if(!(x == 0 && y == 0 && z == 0)){
|
if(!(x == 0 && y == 0 && z == 0)){
|
||||||
this.boundPosition = new Position(x, y, z);
|
this.boundPosition = new BlockPos(x, y, z);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,15 +10,16 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
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.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.EnumParticleTypes;
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -29,11 +30,11 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
||||||
|
|
||||||
public static final int RANGE = 16;
|
public static final int RANGE = 16;
|
||||||
public static final float[] COLORS = new float[]{93F/255F, 43F/255F, 181F/255F};
|
public static final float[] COLORS = new float[]{93F/255F, 43F/255F, 181F/255F};
|
||||||
public Position boundPosition;
|
public BlockPos boundPosition;
|
||||||
public BlockPhantom.Type type;
|
public BlockPhantom.Type type;
|
||||||
public int range;
|
public int range;
|
||||||
private int rangeBefore;
|
private int rangeBefore;
|
||||||
private Position boundPosBefore;
|
private BlockPos boundPosBefore;
|
||||||
private Block boundBlockBefore;
|
private Block boundBlockBefore;
|
||||||
|
|
||||||
public TileEntityPhantomface(String name){
|
public TileEntityPhantomface(String name){
|
||||||
|
@ -44,23 +45,23 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
||||||
public void updateEntity(){
|
public void updateEntity(){
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if(!worldObj.isRemote){
|
if(!worldObj.isRemote){
|
||||||
this.range = upgradeRange(RANGE, worldObj, Position.fromBlockPos(this.getPos()));
|
this.range = upgradeRange(RANGE, worldObj, this.getPos());
|
||||||
|
|
||||||
if(!this.hasBoundPosition()){
|
if(!this.hasBoundPosition()){
|
||||||
this.boundPosition = null;
|
this.boundPosition = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.boundPosition != this.boundPosBefore || (this.boundPosition != null && this.boundPosition.getBlock(worldObj) != this.boundBlockBefore) || this.rangeBefore != this.range){
|
if(this.boundPosition != this.boundPosBefore || (this.boundPosition != null && PosUtil.getBlock(this.boundPosition, worldObj) != this.boundBlockBefore) || this.rangeBefore != this.range){
|
||||||
this.rangeBefore = this.range;
|
this.rangeBefore = this.range;
|
||||||
this.boundPosBefore = this.boundPosition;
|
this.boundPosBefore = this.boundPosition;
|
||||||
this.boundBlockBefore = this.boundPosition == null ? null : this.boundPosition.getBlock(worldObj);
|
this.boundBlockBefore = this.boundPosition == null ? null : PosUtil.getBlock(this.boundPosition, this.worldObj);
|
||||||
|
|
||||||
this.worldObj.markBlockForUpdate(new Position(this.getPos().getX()+1, this.getPos().getY(), this.getPos().getZ()));
|
this.worldObj.markBlockForUpdate(PosUtil.offset(this.pos, 1, 0, 0));
|
||||||
this.worldObj.markBlockForUpdate(new Position(this.getPos().getX()-1, this.getPos().getY(), this.getPos().getZ()));
|
this.worldObj.markBlockForUpdate(PosUtil.offset(this.pos, -1, 0, 0));
|
||||||
this.worldObj.markBlockForUpdate(new Position(this.getPos().getX(), this.getPos().getY()+1, this.getPos().getZ()));
|
this.worldObj.markBlockForUpdate(PosUtil.offset(this.pos, 0, 1, 0));
|
||||||
this.worldObj.markBlockForUpdate(new Position(this.getPos().getX(), this.getPos().getY()-1, this.getPos().getZ()));
|
this.worldObj.markBlockForUpdate(PosUtil.offset(this.pos, 0, -1, 0));
|
||||||
this.worldObj.markBlockForUpdate(new Position(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ()+1));
|
this.worldObj.markBlockForUpdate(PosUtil.offset(this.pos, 0, 0, 1));
|
||||||
this.worldObj.markBlockForUpdate(new Position(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ()-1));
|
this.worldObj.markBlockForUpdate(PosUtil.offset(this.pos, 0, 0, -1));
|
||||||
this.sendUpdate();
|
this.sendUpdate();
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
@ -89,18 +90,17 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
||||||
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");
|
||||||
int world = compound.getInteger("WorldOfTileStored");
|
|
||||||
this.range = compound.getInteger("Range");
|
this.range = compound.getInteger("Range");
|
||||||
if(!(x == 0 && y == 0 && z == 0)){
|
if(!(x == 0 && y == 0 && z == 0)){
|
||||||
this.boundPosition = new Position(x, y, z);
|
this.boundPosition = new BlockPos(x, y, z);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int upgradeRange(int defaultRange, World world, Position pos){
|
public static int upgradeRange(int defaultRange, World world, BlockPos pos){
|
||||||
int newRange = defaultRange;
|
int newRange = defaultRange;
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
Block block = pos.getOffsetPosition(0, 1+i, 0).getBlock(world);
|
Block block = PosUtil.getBlock(PosUtil.offset(pos, 0, 1+i, 0), world);
|
||||||
if(block == InitBlocks.blockPhantomBooster){
|
if(block == InitBlocks.blockPhantomBooster){
|
||||||
newRange = newRange*2;
|
newRange = newRange*2;
|
||||||
}
|
}
|
||||||
|
@ -144,17 +144,17 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBoundThingInRange(){
|
public boolean isBoundThingInRange(){
|
||||||
return this.hasBoundPosition() && this.boundPosition.toVec().distanceTo(Position.fromBlockPos(this.getPos()).toVec()) <= this.range;
|
return this.hasBoundPosition() && PosUtil.toVec(this.boundPosition).distanceTo(PosUtil.toVec(this.getPos())) <= this.range;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Position getBoundPosition(){
|
public BlockPos getBoundPosition(){
|
||||||
return this.boundPosition;
|
return this.boundPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBoundPosition(Position pos){
|
public void setBoundPosition(BlockPos pos){
|
||||||
this.boundPosition = pos == null ? null : pos.copy();
|
this.boundPosition = pos == null ? null : PosUtil.copyPos(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* This file ("PosUtil.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://ellpeck.de/actaddlicense/
|
||||||
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
|
*
|
||||||
|
* © 2016 Ellpeck
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.ellpeck.actuallyadditions.mod.util;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class PosUtil{
|
||||||
|
|
||||||
|
public static final PropertyInteger META = PropertyInteger.create("meta", 0, 15);
|
||||||
|
|
||||||
|
public static Block getBlock(BlockPos pos, IBlockAccess world){
|
||||||
|
return world.getBlockState(pos).getBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Material getMaterial(BlockPos pos, IBlockAccess world){
|
||||||
|
return getBlock(pos, world).getMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMetadata(BlockPos pos, IBlockAccess world){
|
||||||
|
return getBlock(pos, world).getMetaFromState(world.getBlockState(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockPos offset(BlockPos pos, int x, int y, int z){
|
||||||
|
return new BlockPos(pos.getX()+x, pos.getY()+y, pos.getZ()+z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean setBlock(BlockPos pos, World world, Block block, int meta, int flag){
|
||||||
|
return world.setBlockState(pos, block.getStateFromMeta(meta), flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vec3 toVec(BlockPos pos){
|
||||||
|
return new Vec3(pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockPos copyPos(BlockPos pos){
|
||||||
|
return new BlockPos(pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemBlock getItemBlock(BlockPos pos, IBlockAccess world){
|
||||||
|
Item item = Item.getItemFromBlock(getBlock(pos, world));
|
||||||
|
if(item instanceof ItemBlock){
|
||||||
|
return (ItemBlock)item;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMetadata(BlockPos pos, World world, int meta, int flag){
|
||||||
|
world.setBlockState(pos, getBlock(pos, world).getStateFromMeta(meta), flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean areSamePos(BlockPos first, BlockPos second){
|
||||||
|
return first.getX() == second.getX() && first.getY() == second.getY() && first.getZ() == second.getZ();
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.util;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import de.ellpeck.actuallyadditions.api.Position;
|
|
||||||
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.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -29,10 +28,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.play.client.C07PacketPlayerDigging;
|
import net.minecraft.network.play.client.C07PacketPlayerDigging;
|
||||||
import net.minecraft.network.play.server.S23PacketBlockChange;
|
import net.minecraft.network.play.server.S23PacketBlockChange;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
|
||||||
import net.minecraft.util.Vec3;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
|
@ -43,22 +39,22 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
public class WorldUtil{
|
public class WorldUtil{
|
||||||
|
|
||||||
public static void breakBlockAtSide(EnumFacing side, World world, Position pos){
|
public static void breakBlockAtSide(EnumFacing side, World world, BlockPos pos){
|
||||||
breakBlockAtSide(side, world, pos, 0);
|
breakBlockAtSide(side, world, pos, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void breakBlockAtSide(EnumFacing side, World world, Position pos, int offset){
|
public static void breakBlockAtSide(EnumFacing side, World world, BlockPos pos, int offset){
|
||||||
Position c = getCoordsFromSide(side, pos, offset);
|
BlockPos c = getCoordsFromSide(side, pos, offset);
|
||||||
if(c != null){
|
if(c != null){
|
||||||
world.setBlockToAir(pos);
|
world.setBlockToAir(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Position getCoordsFromSide(EnumFacing side, Position pos, int offset){
|
public static BlockPos getCoordsFromSide(EnumFacing side, BlockPos pos, int offset){
|
||||||
return new Position(pos.getX()+side.getFrontOffsetX()*(offset+1), pos.getY()+side.getFrontOffsetY()*(offset+1), pos.getZ()+side.getFrontOffsetZ()*(offset+1));
|
return new BlockPos(pos.getX()+side.getFrontOffsetX()*(offset+1), pos.getY()+side.getFrontOffsetY()*(offset+1), pos.getZ()+side.getFrontOffsetZ()*(offset+1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pushEnergyToAllSides(World world, Position pos, EnergyStorage storage){
|
public static void pushEnergyToAllSides(World world, BlockPos pos, EnergyStorage storage){
|
||||||
WorldUtil.pushEnergy(world, pos, EnumFacing.UP, storage);
|
WorldUtil.pushEnergy(world, pos, EnumFacing.UP, storage);
|
||||||
WorldUtil.pushEnergy(world, pos, EnumFacing.DOWN, storage);
|
WorldUtil.pushEnergy(world, pos, EnumFacing.DOWN, storage);
|
||||||
WorldUtil.pushEnergy(world, pos, EnumFacing.NORTH, storage);
|
WorldUtil.pushEnergy(world, pos, EnumFacing.NORTH, storage);
|
||||||
|
@ -67,7 +63,7 @@ public class WorldUtil{
|
||||||
WorldUtil.pushEnergy(world, pos, EnumFacing.WEST, storage);
|
WorldUtil.pushEnergy(world, pos, EnumFacing.WEST, storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pushEnergy(World world, Position pos, EnumFacing side, EnergyStorage storage){
|
public static void pushEnergy(World world, BlockPos pos, EnumFacing side, EnergyStorage storage){
|
||||||
TileEntity tile = getTileEntityFromSide(side, world, pos);
|
TileEntity tile = getTileEntityFromSide(side, world, pos);
|
||||||
if(tile != null && tile instanceof IEnergyReceiver && storage.getEnergyStored() > 0){
|
if(tile != null && tile instanceof IEnergyReceiver && storage.getEnergyStored() > 0){
|
||||||
if(((IEnergyReceiver)tile).canConnectEnergy(side.getOpposite())){
|
if(((IEnergyReceiver)tile).canConnectEnergy(side.getOpposite())){
|
||||||
|
@ -77,8 +73,8 @@ public class WorldUtil{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TileEntity getTileEntityFromSide(EnumFacing side, World world, Position pos){
|
public static TileEntity getTileEntityFromSide(EnumFacing side, World world, BlockPos pos){
|
||||||
Position c = getCoordsFromSide(side, pos, 0);
|
BlockPos c = getCoordsFromSide(side, pos, 0);
|
||||||
if(c != null){
|
if(c != null){
|
||||||
return world.getTileEntity(pos);
|
return world.getTileEntity(pos);
|
||||||
}
|
}
|
||||||
|
@ -94,16 +90,16 @@ public class WorldUtil{
|
||||||
* @param world The World
|
* @param world The World
|
||||||
* @return Is every block present?
|
* @return Is every block present?
|
||||||
*/
|
*/
|
||||||
public static boolean hasBlocksInPlacesGiven(Position[] positions, Block block, int meta, World world){
|
public static boolean hasBlocksInPlacesGiven(BlockPos[] positions, Block block, int meta, World world){
|
||||||
for(Position pos : positions){
|
for(BlockPos pos : positions){
|
||||||
if(!(pos.getBlock(world) == block && pos.getMetadata(world) == meta)){
|
if(!(PosUtil.getBlock(pos, world) == block && PosUtil.getMetadata(pos, world) == meta)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pushFluid(World world, Position pos, EnumFacing side, FluidTank tank){
|
public static void pushFluid(World world, BlockPos pos, EnumFacing side, FluidTank tank){
|
||||||
TileEntity tile = getTileEntityFromSide(side, world, pos);
|
TileEntity tile = getTileEntityFromSide(side, world, pos);
|
||||||
if(tile != null && tank.getFluid() != null && tile instanceof IFluidHandler){
|
if(tile != null && tank.getFluid() != null && tile instanceof IFluidHandler){
|
||||||
if(((IFluidHandler)tile).canFill(side.getOpposite(), tank.getFluid().getFluid())){
|
if(((IFluidHandler)tile).canFill(side.getOpposite(), tank.getFluid().getFluid())){
|
||||||
|
@ -113,16 +109,16 @@ public class WorldUtil{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack placeBlockAtSide(EnumFacing side, World world, Position pos, ItemStack stack){
|
public static ItemStack placeBlockAtSide(EnumFacing side, World world, BlockPos pos, ItemStack stack){
|
||||||
if(world instanceof WorldServer && stack != null && stack.getItem() != null){
|
if(world instanceof WorldServer && stack != null && stack.getItem() != null){
|
||||||
Position offsetPos = pos.getOffsetPosition(side);
|
BlockPos offsetPos = pos.offset(side);
|
||||||
|
|
||||||
//Fluids
|
//Fluids
|
||||||
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
|
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
|
||||||
if(fluid != null && fluid.getFluid().getBlock() != null && fluid.getFluid().getBlock().canPlaceBlockAt(world, offsetPos)){
|
if(fluid != null && fluid.getFluid().getBlock() != null && fluid.getFluid().getBlock().canPlaceBlockAt(world, offsetPos)){
|
||||||
Block block = offsetPos.getBlock(world);
|
Block block = PosUtil.getBlock(offsetPos, world);
|
||||||
if(!(block instanceof IFluidBlock) && block != Blocks.lava && block != Blocks.water && block != Blocks.flowing_lava && block != Blocks.flowing_water){
|
if(!(block instanceof IFluidBlock) && block != Blocks.lava && block != Blocks.water && block != Blocks.flowing_lava && block != Blocks.flowing_water){
|
||||||
if(offsetPos.setBlock(world, fluid.getFluid().getBlock(), 0, 2)){
|
if(PosUtil.setBlock(pos, world, fluid.getFluid().getBlock(), 0, 2)){
|
||||||
return stack.getItem().getContainerItem(stack);
|
return stack.getItem().getContainerItem(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,14 +126,14 @@ public class WorldUtil{
|
||||||
|
|
||||||
//Redstone
|
//Redstone
|
||||||
else if(stack.getItem() == Items.redstone){
|
else if(stack.getItem() == Items.redstone){
|
||||||
offsetPos.setBlock(world, Blocks.redstone_wire, 0, 2);
|
PosUtil.setBlock(pos, world, Blocks.redstone_wire, 0, 2);
|
||||||
stack.stackSize--;
|
stack.stackSize--;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Plants
|
//Plants
|
||||||
else if(stack.getItem() instanceof IPlantable){
|
else if(stack.getItem() instanceof IPlantable){
|
||||||
if(((IPlantable)stack.getItem()).getPlant(world, offsetPos).getBlock().canPlaceBlockAt(world, offsetPos)){
|
if(((IPlantable)stack.getItem()).getPlant(world, offsetPos).getBlock().canPlaceBlockAt(world, offsetPos)){
|
||||||
if(offsetPos.setBlockState(world, ((IPlantable)stack.getItem()).getPlant(world, offsetPos), 2)){
|
if(world.setBlockState(offsetPos, ((IPlantable)stack.getItem()).getPlant(world, offsetPos), 2)){
|
||||||
stack.stackSize--;
|
stack.stackSize--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,8 +152,8 @@ public class WorldUtil{
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dropItemAtSide(EnumFacing side, World world, Position pos, ItemStack stack){
|
public static void dropItemAtSide(EnumFacing side, World world, BlockPos pos, ItemStack stack){
|
||||||
Position coords = getCoordsFromSide(side, pos, 0);
|
BlockPos coords = getCoordsFromSide(side, pos, 0);
|
||||||
if(coords != null){
|
if(coords != null){
|
||||||
EntityItem item = new EntityItem(world, coords.getX()+0.5, coords.getY()+0.5, coords.getZ()+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;
|
||||||
|
@ -235,28 +231,15 @@ public class WorldUtil{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EnumFacing getDirectionByPistonRotation(int meta){
|
public static EnumFacing getDirectionByPistonRotation(int meta){
|
||||||
switch(meta){
|
return EnumFacing.values()[meta];
|
||||||
case 0:
|
|
||||||
return EnumFacing.UP;
|
|
||||||
case 1:
|
|
||||||
return EnumFacing.DOWN;
|
|
||||||
case 2:
|
|
||||||
return EnumFacing.NORTH;
|
|
||||||
case 3:
|
|
||||||
return EnumFacing.EAST;
|
|
||||||
case 4:
|
|
||||||
return EnumFacing.SOUTH;
|
|
||||||
default:
|
|
||||||
return EnumFacing.WEST;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Material> getMaterialsAround(World world, Position pos){
|
public static ArrayList<Material> getMaterialsAround(World world, BlockPos pos){
|
||||||
ArrayList<Material> blocks = new ArrayList<Material>();
|
ArrayList<Material> blocks = new ArrayList<Material>();
|
||||||
blocks.add(pos.getOffsetPosition(EnumFacing.NORTH).getMaterial(world));
|
blocks.add(PosUtil.getMaterial(pos.offset(EnumFacing.NORTH), world));
|
||||||
blocks.add(pos.getOffsetPosition(EnumFacing.EAST).getMaterial(world));
|
blocks.add(PosUtil.getMaterial(pos.offset(EnumFacing.EAST), world));
|
||||||
blocks.add(pos.getOffsetPosition(EnumFacing.SOUTH).getMaterial(world));
|
blocks.add(PosUtil.getMaterial(pos.offset(EnumFacing.SOUTH), world));
|
||||||
blocks.add(pos.getOffsetPosition(EnumFacing.WEST).getMaterial(world));
|
blocks.add(PosUtil.getMaterial(pos.offset(EnumFacing.WEST), world));
|
||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,10 +345,11 @@ public class WorldUtil{
|
||||||
* @param player The Player
|
* @param player The Player
|
||||||
* @return If the Block could be harvested normally (so that it drops an item)
|
* @return If the Block could be harvested normally (so that it drops an item)
|
||||||
*/
|
*/
|
||||||
public static boolean playerHarvestBlock(World world, Position pos, EntityPlayer player){
|
public static boolean playerHarvestBlock(World world, BlockPos pos, EntityPlayer player){
|
||||||
Block block = pos.getBlock(world);
|
Block block = PosUtil.getBlock(pos, world);
|
||||||
IBlockState state = pos.getBlockState(world);
|
IBlockState state = world.getBlockState(pos);
|
||||||
int meta = pos.getMetadata(world);
|
int meta = PosUtil.getMetadata(pos, world);
|
||||||
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
//If the Block can be harvested or not
|
//If the Block can be harvested or not
|
||||||
boolean canHarvest = block.canHarvestBlock(world, pos, player);
|
boolean canHarvest = block.canHarvestBlock(world, pos, player);
|
||||||
|
|
||||||
|
@ -396,7 +380,7 @@ public class WorldUtil{
|
||||||
if(!world.isRemote && !player.capabilities.isCreativeMode){
|
if(!world.isRemote && !player.capabilities.isCreativeMode){
|
||||||
//Actually drops the Block's Items etc.
|
//Actually drops the Block's Items etc.
|
||||||
if(canHarvest){
|
if(canHarvest){
|
||||||
block.harvestBlock(world, player, pos, state, pos.getTileEntity(world));
|
block.harvestBlock(world, player, pos, state, tile);
|
||||||
}
|
}
|
||||||
//Only drop XP when no Silk Touch is applied
|
//Only drop XP when no Silk Touch is applied
|
||||||
if(!EnchantmentHelper.getSilkTouchModifier(player)){
|
if(!EnchantmentHelper.getSilkTouchModifier(player)){
|
||||||
|
|
Loading…
Reference in a new issue