Most of the 1.8 Port.

This commit is contained in:
AlgorithmX2
2015-06-15 19:44:59 -05:00
parent 17465e68e8
commit 38afde724b
824 changed files with 12120 additions and 9158 deletions
@@ -21,12 +21,9 @@ package appeng.items.tools.powered;
import java.util.EnumSet;
import com.google.common.base.Optional;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.sync.packets.PacketLightning;
@@ -34,6 +31,8 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.server.ServerHelper;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolChargedStaff extends AEBasePoweredItem
{
@@ -54,9 +53,9 @@ public class ToolChargedStaff extends AEBasePoweredItem
{
for( int x = 0; x < 2; x++ )
{
float dx = (float) ( Platform.getRandomFloat() * target.width + target.boundingBox.minX );
float dy = (float) ( Platform.getRandomFloat() * target.height + target.boundingBox.minY );
float dz = (float) ( Platform.getRandomFloat() * target.width + target.boundingBox.minZ );
float dx = (float) ( Platform.getRandomFloat() * target.width + target.getBoundingBox().minX );
float dy = (float) ( Platform.getRandomFloat() * target.height + target.getBoundingBox().minY );
float dz = (float) ( Platform.getRandomFloat() * target.width + target.getBoundingBox().minZ );
ServerHelper.proxy.sendToAllNearExcept( null, dx, dy, dz, 32.0, target.worldObj, new PacketLightning( dx, dy, dz ) );
}
}
@@ -28,22 +28,25 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.block.BlockDispenser;
import net.minecraft.block.BlockStainedGlass;
import net.minecraft.block.BlockStainedGlassPane;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemSnowball;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
@@ -78,6 +81,8 @@ import appeng.util.ItemSorters;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import com.google.common.base.Optional;
public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCell, IItemGroup, IBlockTool, IMouseWheelItem
{
@@ -116,9 +121,17 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
}
@Override
public boolean onItemUse( ItemStack is, EntityPlayer p, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
public boolean onItemUse(
ItemStack is,
EntityPlayer p,
World w,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
Block blk = w.getBlock( x, y, z );
Block blk = w.getBlockState( pos ).getBlock();
double powerPerUse = 100;
ItemStack paintBall = this.getColor( is );
@@ -138,21 +151,20 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
paintBall = null;
}
if( !Platform.hasPermissions( new DimensionalCoord( w, x, y, z ), p ) )
if( !Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) )
{
return false;
}
if( paintBall != null && paintBall.getItem() instanceof ItemSnowball )
{
ForgeDirection orientation = ForgeDirection.getOrientation( side );
TileEntity te = w.getTileEntity( x, y, z );
TileEntity te = w.getTileEntity( pos );
// clean cables.
if( te instanceof IColorableTile )
{
if( this.getAECurrentPower( is ) > powerPerUse && ( (IColorableTile) te ).getColor() != AEColor.Transparent )
{
if( ( (IColorableTile) te ).recolourBlock( orientation, AEColor.Transparent, p ) )
if( ( (IColorableTile) te ).recolourBlock( side, AEColor.Transparent, p ) )
{
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
this.extractAEPower( is, powerPerUse );
@@ -162,13 +174,13 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
}
// clean paint balls..
Block testBlk = w.getBlock( x + orientation.offsetX, y + orientation.offsetY, z + orientation.offsetZ );
TileEntity painted = w.getTileEntity( x + orientation.offsetX, y + orientation.offsetY, z + orientation.offsetZ );
Block testBlk = w.getBlockState( pos.offset( side ) ).getBlock();
TileEntity painted = w.getTileEntity( pos.offset( side ) );
if( this.getAECurrentPower( is ) > powerPerUse && testBlk instanceof BlockPaint && painted instanceof TilePaint )
{
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
this.extractAEPower( is, powerPerUse );
( (TilePaint) painted ).cleanSide( orientation.getOpposite() );
( (TilePaint) painted ).cleanSide( side.getOpposite() );
return true;
}
}
@@ -178,7 +190,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
if( color != null && this.getAECurrentPower( is ) > powerPerUse )
{
if( color != AEColor.Transparent && this.recolourBlock( blk, ForgeDirection.getOrientation( side ), w, x, y, z, ForgeDirection.getOrientation( side ), color, p ) )
if( color != AEColor.Transparent && this.recolourBlock( blk, side, w, pos, side, color, p ) )
{
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
this.extractAEPower( is, powerPerUse );
@@ -352,69 +364,67 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
}
}
private boolean recolourBlock( Block blk, ForgeDirection side, World w, int x, int y, int z, ForgeDirection orientation, AEColor newColor, EntityPlayer p )
private boolean recolourBlock( Block blk, EnumFacing side, World w, BlockPos pos, EnumFacing orientation, AEColor newColor, EntityPlayer p )
{
if( blk == Blocks.carpet )
IBlockState state = w.getBlockState( pos );
if( blk instanceof BlockColored )
{
int meta = w.getBlockMetadata( x, y, z );
if( newColor.ordinal() == meta )
EnumDyeColor color = ( EnumDyeColor ) state.getValue( BlockColored.COLOR );
if( newColor.dye == color )
{
return false;
}
return w.setBlock( x, y, z, Blocks.carpet, newColor.ordinal(), 3 );
return w.setBlockState( pos, state.withProperty( BlockColored.COLOR, newColor.dye ) );
}
if( blk == Blocks.glass )
{
return w.setBlock( x, y, z, Blocks.stained_glass, newColor.ordinal(), 3 );
return w.setBlockState( pos, Blocks.stained_glass.getDefaultState().withProperty( BlockStainedGlass.COLOR, newColor.dye) );
}
if( blk == Blocks.stained_glass )
{
int meta = w.getBlockMetadata( x, y, z );
if( newColor.ordinal() == meta )
EnumDyeColor color = ( EnumDyeColor ) state.getValue( BlockStainedGlass.COLOR );
if( newColor.dye == color )
{
return false;
}
return w.setBlock( x, y, z, Blocks.stained_glass, newColor.ordinal(), 3 );
return w.setBlockState( pos, state.withProperty( BlockStainedGlass.COLOR, newColor.dye ) );
}
if( blk == Blocks.glass_pane )
{
return w.setBlock( x, y, z, Blocks.stained_glass_pane, newColor.ordinal(), 3 );
return w.setBlockState( pos, Blocks.stained_glass_pane.getDefaultState().withProperty( BlockStainedGlassPane.COLOR, newColor.dye) );
}
if( blk == Blocks.stained_glass_pane )
{
int meta = w.getBlockMetadata( x, y, z );
if( newColor.ordinal() == meta )
EnumDyeColor color = ( EnumDyeColor ) state.getValue( BlockStainedGlassPane.COLOR );
if( newColor.dye == color )
{
return false;
}
return w.setBlock( x, y, z, Blocks.stained_glass_pane, newColor.ordinal(), 3 );
return w.setBlockState( pos, state.withProperty( BlockStainedGlassPane.COLOR, newColor.dye ) );
}
if( blk == Blocks.hardened_clay )
{
return w.setBlock( x, y, z, Blocks.stained_hardened_clay, newColor.ordinal(), 3 );
}
if( blk == Blocks.stained_hardened_clay )
{
int meta = w.getBlockMetadata( x, y, z );
if( newColor.ordinal() == meta )
{
return false;
}
return w.setBlock( x, y, z, Blocks.stained_hardened_clay, newColor.ordinal(), 3 );
return w.setBlockState( pos, Blocks.stained_hardened_clay.getDefaultState().withProperty( BlockColored.COLOR, newColor.dye ) );
}
if( blk instanceof BlockCableBus )
{
return ( (BlockCableBus) blk ).recolourBlock( w, x, y, z, side, newColor.ordinal(), p );
return ( (BlockCableBus) blk ).recolorBlock( w, pos, side, newColor.dye, p );
}
return blk.recolourBlock( w, x, y, z, side, newColor.ordinal() );
return blk.recolorBlock( w, pos, side, newColor.dye );
}
public void cycleColors( ItemStack is, ItemStack paintBall, int i )
@@ -25,12 +25,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDispenser;
import net.minecraft.block.BlockTNT;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@@ -38,12 +37,11 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.util.DimensionalCoord;
import appeng.block.misc.BlockTinyTNT;
import appeng.core.AEConfig;
@@ -54,6 +52,8 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.util.InWorldToolOperationResult;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockTool
{
@@ -69,21 +69,21 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
this.heatUp = new HashMap<InWorldToolOperationIngredient, InWorldToolOperationResult>();
this.coolDown = new HashMap<InWorldToolOperationIngredient, InWorldToolOperationResult>();
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stone, 0 ), new InWorldToolOperationResult( new ItemStack( Blocks.cobblestone ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stonebrick, 0 ), new InWorldToolOperationResult( new ItemStack( Blocks.stonebrick, 1, 2 ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.lava, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.obsidian ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.flowing_lava, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.obsidian ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.grass, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.dirt ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stone.getDefaultState() ), new InWorldToolOperationResult( new ItemStack( Blocks.cobblestone ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stonebrick.getDefaultState() ), new InWorldToolOperationResult( new ItemStack( Blocks.stonebrick, 1, 2 ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.lava, true ), new InWorldToolOperationResult( new ItemStack( Blocks.obsidian ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.flowing_lava, true ), new InWorldToolOperationResult( new ItemStack( Blocks.obsidian ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.grass, true ), new InWorldToolOperationResult( new ItemStack( Blocks.dirt ) ) );
List<ItemStack> snowBalls = new ArrayList<ItemStack>();
snowBalls.add( new ItemStack( Items.snowball ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.flowing_water, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( null, snowBalls ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.water, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.ice ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.flowing_water, true ), new InWorldToolOperationResult( null, snowBalls ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.water, true ), new InWorldToolOperationResult( new ItemStack( Blocks.ice ) ) );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.ice, 0 ), new InWorldToolOperationResult( new ItemStack( Blocks.water ) ) );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.flowing_water, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult() );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.water, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult() );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.snow, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.flowing_water ) ) );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.ice.getDefaultState() ), new InWorldToolOperationResult( new ItemStack( Blocks.water ) ) );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.flowing_water, true ), new InWorldToolOperationResult() );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.water, true ), new InWorldToolOperationResult() );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.snow, true ), new InWorldToolOperationResult( new ItemStack( Blocks.flowing_water ) ) );
}
@Override
@@ -95,19 +95,27 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
private static class InWorldToolOperationIngredient
{
private final Block blockID;
private final int metadata;
private final IBlockState state;
private boolean blockOnly;
public InWorldToolOperationIngredient( Block blockID, int metadata )
public InWorldToolOperationIngredient( IBlockState state )
{
this.blockID = blockID;
this.metadata = metadata;
this.state = state;
blockOnly = false;
}
public InWorldToolOperationIngredient(
Block blk,
boolean b )
{
state = blk.getDefaultState();
blockOnly = b;
}
@Override
public int hashCode()
{
return this.blockID.hashCode() ^ this.metadata;
return state.getBlock().hashCode();
}
@Override
@@ -122,77 +130,79 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
return false;
}
InWorldToolOperationIngredient other = (InWorldToolOperationIngredient) obj;
return this.blockID == other.blockID && this.metadata == other.metadata;
return state == other.state && ( blockOnly && state.getBlock() == other.state.getBlock() );
}
}
private void heat( Block blockID, int metadata, World w, int x, int y, int z )
private void heat( IBlockState state, World w, BlockPos pos )
{
InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( blockID, metadata ) );
InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( state ) );
if( r == null )
{
r = this.heatUp.get( new InWorldToolOperationIngredient( blockID, OreDictionary.WILDCARD_VALUE ) );
r = this.heatUp.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
}
if( r.BlockItem != null )
{
w.setBlock( x, y, z, Block.getBlockFromItem( r.BlockItem.getItem() ), r.BlockItem.getItemDamage(), 3 );
Block blk = Block.getBlockFromItem( r.BlockItem.getItem() );
w.setBlockState( pos, blk.getStateFromMeta( r.BlockItem.getItemDamage() ), 3 );
}
else
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
w.setBlockToAir( pos );
}
if( r.Drops != null )
{
Platform.spawnDrops( w, x, y, z, r.Drops );
Platform.spawnDrops( w, pos, r.Drops );
}
}
private boolean canHeat( Block blockID, int metadata )
private boolean canHeat( IBlockState state )
{
InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( blockID, metadata ) );
InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( state ) );
if( r == null )
{
r = this.heatUp.get( new InWorldToolOperationIngredient( blockID, OreDictionary.WILDCARD_VALUE ) );
r = this.heatUp.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
}
return r != null;
}
private void cool( Block blockID, int metadata, World w, int x, int y, int z )
private void cool( IBlockState state, World w, BlockPos pos )
{
InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( blockID, metadata ) );
InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( state ) );
if( r == null )
{
r = this.coolDown.get( new InWorldToolOperationIngredient( blockID, OreDictionary.WILDCARD_VALUE ) );
r = this.coolDown.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
}
if( r.BlockItem != null )
{
w.setBlock( x, y, z, Block.getBlockFromItem( r.BlockItem.getItem() ), r.BlockItem.getItemDamage(), 3 );
Block blk = Block.getBlockFromItem( r.BlockItem.getItem() );
w.setBlockState( pos, blk.getStateFromMeta( r.BlockItem.getItemDamage() ), 3 );
}
else
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
w.setBlockToAir( pos );
}
if( r.Drops != null )
{
Platform.spawnDrops( w, x, y, z, r.Drops );
Platform.spawnDrops( w, pos, r.Drops );
}
}
private boolean canCool( Block blockID, int metadata )
private boolean canCool( IBlockState state )
{
InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( blockID, metadata ) );
InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( state ) );
if( r == null )
{
r = this.coolDown.get( new InWorldToolOperationIngredient( blockID, OreDictionary.WILDCARD_VALUE ) );
r = this.coolDown.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
}
return r != null;
@@ -223,15 +233,11 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
{
if( target.typeOfHit == MovingObjectType.BLOCK )
{
int x = target.blockX;
int y = target.blockY;
int z = target.blockZ;
if( w.getBlock( x, y, z ).getMaterial() == Material.lava || w.getBlock( x, y, z ).getMaterial() == Material.water )
if( w.getBlockState( target.getBlockPos() ).getBlock().getMaterial() == Material.lava || w.getBlockState( target.getBlockPos() ).getBlock().getMaterial() == Material.water )
{
if( Platform.hasPermissions( new DimensionalCoord( w, x, y, z ), p ) )
if( Platform.hasPermissions( new DimensionalCoord( w, target.getBlockPos() ), p ) )
{
this.onItemUse( item, p, w, x, y, z, 0, 0.0F, 0.0F, 0.0F );
this.onItemUse( item, p, w, target.getBlockPos(), EnumFacing.UP, 0.0F, 0.0F, 0.0F );
}
}
}
@@ -239,26 +245,34 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
return item;
}
@Override
public boolean onItemUse( ItemStack item, EntityPlayer p, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
public boolean onItemUse(
ItemStack item,
EntityPlayer p,
World w,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( this.getAECurrentPower( item ) > 1600 )
{
if( !p.canPlayerEdit( x, y, z, side, item ) )
if( !p.canPlayerEdit( pos, side, item ) )
{
return false;
}
Block blockID = w.getBlock( x, y, z );
int metadata = w.getBlockMetadata( x, y, z );
IBlockState state = w.getBlockState( pos );
Block blockID = state.getBlock();
if( p.isSneaking() )
{
if( this.canCool( blockID, metadata ) )
if( this.canCool( state ) )
{
this.extractAEPower( item, 1600 );
this.cool( blockID, metadata, w, x, y, z );
this.cool( state, w, pos );
return true;
}
}
@@ -266,39 +280,39 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
{
if( blockID instanceof BlockTNT )
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
( (BlockTNT) blockID ).func_150114_a( w, x, y, z, 1, p );
w.setBlockToAir( pos );
( (BlockTNT) blockID ).explode( w, pos, state, p );
return true;
}
if( blockID instanceof BlockTinyTNT )
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
( (BlockTinyTNT) blockID ).startFuse( w, x, y, z, p );
w.setBlockToAir( pos );
( (BlockTinyTNT) blockID ).startFuse( w, pos, p );
return true;
}
if( this.canHeat( blockID, metadata ) )
if( this.canHeat( state ) )
{
this.extractAEPower( item, 1600 );
this.heat( blockID, metadata, w, x, y, z );
this.heat( state, w, pos );
return true;
}
ItemStack[] stack = Platform.getBlockDrops( w, x, y, z );
ItemStack[] stack = Platform.getBlockDrops( w, pos );
List<ItemStack> out = new ArrayList<ItemStack>();
boolean hasFurnaceable = false;
boolean canFurnaceable = true;
for( ItemStack i : stack )
{
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult( i );
ItemStack result = FurnaceRecipes.instance().getSmeltingResult( i );
if( result != null )
{
if( result.getItem() instanceof ItemBlock )
{
if( Block.getBlockFromItem( result.getItem() ) == blockID && result.getItem().getDamage( result ) == metadata )
if( Block.getBlockFromItem( result.getItem() ) == blockID && result.getItem().getDamage( result ) == blockID.getMetaFromState( state ) )
{
canFurnaceable = false;
}
@@ -317,41 +331,39 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
{
this.extractAEPower( item, 1600 );
InWorldToolOperationResult or = InWorldToolOperationResult.getBlockOperationResult( out.toArray( new ItemStack[out.size()] ) );
w.playSoundEffect( x + 0.5D, y + 0.5D, z + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F );
w.playSoundEffect( pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F );
if( or.BlockItem == null )
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
w.setBlockState( pos, Platform.AIR_BLOCK.getDefaultState(), 3 );
}
else
{
w.setBlock( x, y, z, Block.getBlockFromItem( or.BlockItem.getItem() ), or.BlockItem.getItemDamage(), 3 );
Block blk = Block.getBlockFromItem( or.BlockItem.getItem() );
w.setBlockState( pos, blk.getStateFromMeta( or.BlockItem.getItemDamage() ), 3 );
}
if( or.Drops != null )
{
Platform.spawnDrops( w, x, y, z, or.Drops );
Platform.spawnDrops( w, pos, or.Drops );
}
return true;
}
else
{
ForgeDirection dir = ForgeDirection.getOrientation( side );
x += dir.offsetX;
y += dir.offsetY;
z += dir.offsetZ;
BlockPos offsetPos = pos.offset( side );
if( !p.canPlayerEdit( x, y, z, side, item ) )
if( !p.canPlayerEdit( offsetPos, side, item ) )
{
return false;
}
if( w.isAirBlock( x, y, z ) )
if( w.isAirBlock( offsetPos ) )
{
this.extractAEPower( item, 1600 );
w.playSoundEffect( x + 0.5D, y + 0.5D, z + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F );
w.setBlock( x, y, z, Blocks.fire );
w.playSoundEffect( offsetPos.getX() + 0.5D, offsetPos.getY() + 0.5D, offsetPos.getZ() + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F );
w.setBlockState( offsetPos, Blocks.fire.getDefaultState() );
}
return true;
@@ -22,8 +22,6 @@ package appeng.items.tools.powered;
import java.util.EnumSet;
import java.util.List;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDispenser;
import net.minecraft.entity.Entity;
@@ -35,14 +33,14 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
@@ -75,8 +73,11 @@ import appeng.items.misc.ItemPaintBall;
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.me.storage.CellInventoryHandler;
import appeng.tile.misc.TilePaint;
import appeng.util.LookDirection;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
{
@@ -155,26 +156,18 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
{
return item;
}
LookDirection dir = Platform.getPlayerRay( p, p.getEyeHeight() );
float f = 1.0F;
float f1 = p.prevRotationPitch + ( p.rotationPitch - p.prevRotationPitch ) * f;
float f2 = p.prevRotationYaw + ( p.rotationYaw - p.prevRotationYaw ) * f;
double d0 = p.prevPosX + ( p.posX - p.prevPosX ) * f;
double d1 = p.prevPosY + ( p.posY - p.prevPosY ) * f + 1.62D - p.yOffset;
double d2 = p.prevPosZ + ( p.posZ - p.prevPosZ ) * f;
Vec3 vec3 = Vec3.createVectorHelper( d0, d1, d2 );
float f3 = MathHelper.cos( -f2 * 0.017453292F - (float) Math.PI );
float f4 = MathHelper.sin( -f2 * 0.017453292F - (float) Math.PI );
float f5 = -MathHelper.cos( -f1 * 0.017453292F );
float f6 = MathHelper.sin( -f1 * 0.017453292F );
float f7 = f4 * f5;
float f8 = f3 * f5;
double d3 = 32.0D;
Vec3 vec31 = vec3.addVector( f7 * d3, f6 * d3, f8 * d3 );
Vec3 direction = Vec3.createVectorHelper( f7 * d3, f6 * d3, f8 * d3 );
Vec3 vec3 = dir.a;
Vec3 vec31 = dir.b;
Vec3 direction = vec31.subtract( vec3 );
direction.normalize();
double d0 = vec3.xCoord;
double d1 = vec3.yCoord;
double d2 = vec3.zCoord;
float penetration = AEApi.instance().registries().matterCannon().getPenetration( ammo ); // 196.96655f;
if( penetration <= 0 )
{
@@ -206,7 +199,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
private void shootPaintBalls( ItemStack type, World w, EntityPlayer p, Vec3 vec3, Vec3 vec31, Vec3 direction, double d0, double d1, double d2 )
{
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ), Math.min( vec3.zCoord, vec31.zCoord ), Math.max( vec3.xCoord, vec31.xCoord ), Math.max( vec3.yCoord, vec31.yCoord ), Math.max( vec3.zCoord, vec31.zCoord ) ).expand( 16, 16, 16 );
AxisAlignedBB bb = AxisAlignedBB.fromBounds( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ), Math.min( vec3.zCoord, vec31.zCoord ), Math.max( vec3.xCoord, vec31.xCoord ), Math.max( vec3.yCoord, vec31.yCoord ), Math.max( vec3.zCoord, vec31.zCoord ) ).expand( 16, 16, 16 );
Entity entity = null;
List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
@@ -229,7 +222,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
float f1 = 0.3F;
AxisAlignedBB boundingBox = entity1.boundingBox.expand( f1, f1, f1 );
AxisAlignedBB boundingBox = entity1.getBoundingBox().expand( f1, f1, f1 );
MovingObjectPosition movingObjectPosition = boundingBox.calculateIntercept( vec3, vec31 );
if( movingObjectPosition != null )
@@ -248,7 +241,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
MovingObjectPosition pos = w.rayTraceBlocks( vec3, vec31, false );
Vec3 vec = Vec3.createVectorHelper( d0, d1, d2 );
Vec3 vec = new Vec3( d0, d1, d2 );
if( entity != null && pos != null && pos.hitVec.squareDistanceTo( vec ) > closest )
{
pos = new MovingObjectPosition( entity );
@@ -283,7 +276,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
if( pos.entityHit instanceof EntitySheep )
{
EntitySheep sh = (EntitySheep) pos.entityHit;
sh.setFleeceColor( col.ordinal() );
sh.setFleeceColor( col.dye );
}
pos.entityHit.attackEntityFrom( DamageSource.causePlayerDamage( p ), 0 );
@@ -291,33 +284,28 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
}
else if( pos.typeOfHit == MovingObjectType.BLOCK )
{
ForgeDirection side = ForgeDirection.getOrientation( pos.sideHit );
EnumFacing side = pos.sideHit;
BlockPos hitPos = pos.getBlockPos().offset( side );
int x = pos.blockX + side.offsetX;
int y = pos.blockY + side.offsetY;
int z = pos.blockZ + side.offsetZ;
if( !Platform.hasPermissions( new DimensionalCoord( w, x, y, z ), p ) )
if( !Platform.hasPermissions( new DimensionalCoord( w, hitPos ), p ) )
{
return;
}
Block whatsThere = w.getBlock( x, y, z );
if( whatsThere.isReplaceable( w, x, y, z ) && w.isAirBlock( x, y, z ) )
Block whatsThere = w.getBlockState( hitPos ).getBlock();
if( whatsThere.isReplaceable( w, hitPos ) && w.isAirBlock( hitPos ) )
{
for( Block paintBlock : AEApi.instance().definitions().blocks().paint().maybeBlock().asSet() )
{
w.setBlock( x, y, z, paintBlock, 0, 3 );
w.setBlockState( hitPos, paintBlock.getDefaultState(), 3 );
}
}
TileEntity te = w.getTileEntity( x, y, z );
TileEntity te = w.getTileEntity( hitPos );
if( te instanceof TilePaint )
{
pos.hitVec.xCoord -= x;
pos.hitVec.yCoord -= y;
pos.hitVec.zCoord -= z;
( (TilePaint) te ).addBlot( type, side.getOpposite(), pos.hitVec );
Vec3 hp = pos.hitVec.subtract( hitPos.getX(), hitPos.getY(), hitPos.getZ() );
( (TilePaint) te ).addBlot( type, side.getOpposite(), hp );
}
}
}
@@ -330,7 +318,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
{
hasDestroyed = false;
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ), Math.min( vec3.zCoord, vec31.zCoord ), Math.max( vec3.xCoord, vec31.xCoord ), Math.max( vec3.yCoord, vec31.yCoord ), Math.max( vec3.zCoord, vec31.zCoord ) ).expand( 16, 16, 16 );
AxisAlignedBB bb = AxisAlignedBB.fromBounds( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ), Math.min( vec3.zCoord, vec31.zCoord ), Math.max( vec3.xCoord, vec31.xCoord ), Math.max( vec3.yCoord, vec31.yCoord ), Math.max( vec3.zCoord, vec31.zCoord ) ).expand( 16, 16, 16 );
Entity entity = null;
List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
@@ -353,7 +341,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
float f1 = 0.3F;
AxisAlignedBB boundingBox = entity1.boundingBox.expand( f1, f1, f1 );
AxisAlignedBB boundingBox = entity1.getBoundingBox().expand( f1, f1, f1 );
MovingObjectPosition movingObjectPosition = boundingBox.calculateIntercept( vec3, vec31 );
if( movingObjectPosition != null )
@@ -370,7 +358,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
}
}
Vec3 vec = Vec3.createVectorHelper( d0, d1, d2 );
Vec3 vec = new Vec3( d0, d1, d2 );
MovingObjectPosition pos = w.rayTraceBlocks( vec3, vec31, true );
if( entity != null && pos != null && pos.hitVec.squareDistanceTo( vec ) > closest )
{
@@ -429,20 +417,19 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
}
else
{
Block b = w.getBlock( pos.blockX, pos.blockY, pos.blockZ );
Block b = w.getBlockState( pos.getBlockPos() ).getBlock();
// int meta = w.getBlockMetadata(
// pos.blockX, pos.blockY, pos.blockZ );
float hardness = b.getBlockHardness( w, pos.blockX, pos.blockY, pos.blockZ ) * 9.0f;
float hardness = b.getBlockHardness( w, pos.getBlockPos() ) * 9.0f;
if( hardness >= 0.0 )
{
if( penetration > hardness && Platform.hasPermissions( new DimensionalCoord( w, pos.blockX, pos.blockY, pos.blockZ ), p ) )
if( penetration > hardness && Platform.hasPermissions( new DimensionalCoord( w, pos.getBlockPos() ), p ) )
{
hasDestroyed = true;
penetration -= hardness;
penetration *= 0.60;
w.func_147480_a( pos.blockX, pos.blockY, pos.blockZ, true );
// w.destroyBlock( pos.blockX, pos.blockY, pos.blockZ, true );
w.destroyBlock( pos.getBlockPos(), true );
}
}
}
@@ -23,17 +23,13 @@ import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import com.google.common.base.Optional;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.implementations.guiobjects.IGuiItem;
@@ -45,6 +41,7 @@ import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AEPartLocation;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
@@ -56,6 +53,8 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.me.storage.CellInventoryHandler;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell, IGuiItem, IItemGroup
{
@@ -68,7 +67,7 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
@Override
public ItemStack onItemRightClick( ItemStack item, World w, EntityPlayer player )
{
Platform.openGUI( player, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_PORTABLE_CELL );
Platform.openGUI( player, null, AEPartLocation.INTERNAL, GuiBridge.GUI_PORTABLE_CELL );
return item;
}
@@ -190,8 +189,8 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
}
@Override
public IGuiItemObject getGuiObject( ItemStack is, World w, int x, int y, int z )
public IGuiItemObject getGuiObject( ItemStack is, World w, BlockPos pos )
{
return new PortableCellViewer( is, x );
return new PortableCellViewer( is, pos.getX() );
}
}
@@ -22,17 +22,13 @@ package appeng.items.tools.powered;
import java.util.EnumSet;
import java.util.List;
import com.google.common.base.Optional;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
@@ -48,6 +44,8 @@ import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler
{
@@ -22,7 +22,7 @@ package appeng.items.tools.powered.powersink;
import com.google.common.base.Optional;
public abstract class AEBasePoweredItem extends RedstoneFlux
public abstract class AEBasePoweredItem extends AERootPoweredItem
{
public AEBasePoweredItem( double powerCapacity, Optional<String> subName )
{
@@ -22,14 +22,11 @@ package appeng.items.tools.powered.powersink;
import java.text.MessageFormat;
import java.util.List;
import com.google.common.base.Optional;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.config.AccessRestriction;
import appeng.api.config.PowerUnits;
import appeng.api.implementations.items.IAEItemPowerStorage;
@@ -37,6 +34,8 @@ import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
import com.google.common.base.Optional;
public abstract class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
{