Fixes #3866: Use blockstates to avoid the missing fluid block. (#3869)

This commit is contained in:
yueh
2018-12-23 22:42:25 +01:00
committed by GitHub
parent 32a4fcab77
commit 0f0af2349b
2 changed files with 33 additions and 34 deletions
@@ -68,23 +68,24 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
this.coolDown = new HashMap<>(); this.coolDown = new HashMap<>();
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONE.getDefaultState() ), this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONE.getDefaultState() ),
new InWorldToolOperationResult( new ItemStack( Blocks.COBBLESTONE ) ) ); new InWorldToolOperationResult( Blocks.COBBLESTONE.getDefaultState() ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONEBRICK.getDefaultState() ), this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONEBRICK.getDefaultState() ),
new InWorldToolOperationResult( new ItemStack( Blocks.STONEBRICK, 1, 2 ) ) ); new InWorldToolOperationResult( Blocks.STONEBRICK.getStateFromMeta( 2 ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.LAVA, true ), new InWorldToolOperationResult( new ItemStack( Blocks.OBSIDIAN ) ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.LAVA, true ), new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_LAVA, true ), this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_LAVA, true ),
new InWorldToolOperationResult( new ItemStack( Blocks.OBSIDIAN ) ) ); new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.GRASS, true ), new InWorldToolOperationResult( new ItemStack( Blocks.DIRT ) ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.GRASS, true ), new InWorldToolOperationResult( Blocks.DIRT.getDefaultState() ) );
final List<ItemStack> snowBalls = new ArrayList<>(); final List<ItemStack> snowBalls = new ArrayList<>();
snowBalls.add( new ItemStack( Items.SNOWBALL ) ); snowBalls.add( new ItemStack( Items.SNOWBALL ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult( ItemStack.EMPTY, snowBalls ) ); 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.coolDown.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult( Blocks.ICE.getDefaultState() ) );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.ICE.getDefaultState() ), new InWorldToolOperationResult( new ItemStack( Blocks.WATER ) ) ); this.heatUp.put( new InWorldToolOperationIngredient( Blocks.ICE.getDefaultState() ), new InWorldToolOperationResult( Blocks.WATER.getDefaultState() ) );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult() ); 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.WATER, true ), new InWorldToolOperationResult() );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.SNOW, true ), new InWorldToolOperationResult( new ItemStack( Blocks.FLOWING_WATER ) ) ); this.heatUp.put( new InWorldToolOperationIngredient( Blocks.SNOW, true ),
new InWorldToolOperationResult( Blocks.FLOWING_WATER.getStateFromMeta( 7 ) ) );
} }
private static class InWorldToolOperationIngredient private static class InWorldToolOperationIngredient
@@ -135,10 +136,9 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
r = this.heatUp.get( new InWorldToolOperationIngredient( state.getBlock(), true ) ); r = this.heatUp.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
} }
if( !r.getBlockItem().isEmpty() ) if( r.getBlockState() != null )
{ {
final Block blk = Block.getBlockFromItem( r.getBlockItem().getItem() ); w.setBlockState( pos, r.getBlockState(), 3 );
w.setBlockState( pos, blk.getStateFromMeta( r.getBlockItem().getItemDamage() ), 3 );
} }
else else
{ {
@@ -172,10 +172,9 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
r = this.coolDown.get( new InWorldToolOperationIngredient( state.getBlock(), true ) ); r = this.coolDown.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
} }
if( !r.getBlockItem().isEmpty() ) if( r.getBlockState() != null )
{ {
final Block blk = Block.getBlockFromItem( r.getBlockItem().getItem() ); w.setBlockState( pos, r.getBlockState(), 3 );
w.setBlockState( pos, blk.getStateFromMeta( r.getBlockItem().getItemDamage() ), 3 );
} }
else else
{ {
@@ -326,14 +325,13 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
w.playSound( p, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 1.0F, w.playSound( p, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 1.0F,
itemRand.nextFloat() * 0.4F + 0.8F ); itemRand.nextFloat() * 0.4F + 0.8F );
if( or.getBlockItem().isEmpty() ) if( or.getBlockState() == null )
{ {
w.setBlockState( pos, Platform.AIR_BLOCK.getDefaultState(), 3 ); w.setBlockState( pos, Platform.AIR_BLOCK.getDefaultState(), 3 );
} }
else else
{ {
final Block blk = Block.getBlockFromItem( or.getBlockItem().getItem() ); w.setBlockState( pos, or.getBlockState(), 3 );
w.setBlockState( pos, blk.getStateFromMeta( or.getBlockItem().getItemDamage() ), 3 );
} }
if( or.getDrops() != null ) if( or.getDrops() != null )
@@ -24,47 +24,48 @@ import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockAir; import net.minecraft.block.BlockAir;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class InWorldToolOperationResult public class InWorldToolOperationResult
{ {
private final ItemStack BlockItem; private final IBlockState blockState;
private final List<ItemStack> Drops; private final List<ItemStack> drops;
public InWorldToolOperationResult() public InWorldToolOperationResult()
{ {
this.BlockItem = ItemStack.EMPTY; this.blockState = null;
this.Drops = null; this.drops = null;
} }
public InWorldToolOperationResult( final ItemStack block, final List<ItemStack> drops ) public InWorldToolOperationResult( final IBlockState block, final List<ItemStack> drops )
{ {
this.BlockItem = block; this.blockState = block;
this.Drops = drops; this.drops = drops;
} }
public InWorldToolOperationResult( final ItemStack block ) public InWorldToolOperationResult( final IBlockState block )
{ {
this.BlockItem = block; this.blockState = block;
this.Drops = null; this.drops = null;
} }
public static InWorldToolOperationResult getBlockOperationResult( final ItemStack[] items ) public static InWorldToolOperationResult getBlockOperationResult( final ItemStack[] items )
{ {
final List<ItemStack> temp = new ArrayList<>(); final List<ItemStack> temp = new ArrayList<>();
ItemStack b = ItemStack.EMPTY; IBlockState b = null;
for( final ItemStack l : items ) for( final ItemStack l : items )
{ {
if( b.isEmpty() ) if( b == null )
{ {
final Block bl = Block.getBlockFromItem( l.getItem() ); final Block bl = Block.getBlockFromItem( l.getItem() );
if( bl != null && !( bl instanceof BlockAir ) ) if( bl != null && !( bl instanceof BlockAir ) )
{ {
b = l; b = bl.getDefaultState();
continue; continue;
} }
} }
@@ -75,13 +76,13 @@ public class InWorldToolOperationResult
return new InWorldToolOperationResult( b, temp ); return new InWorldToolOperationResult( b, temp );
} }
public ItemStack getBlockItem() public IBlockState getBlockState()
{ {
return this.BlockItem; return this.blockState;
} }
public List<ItemStack> getDrops() public List<ItemStack> getDrops()
{ {
return this.Drops; return this.drops;
} }
} }