Most of the 1.8 Port.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user