From e3e5910443228233b77904941e1ab71a67be2e3a Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 19 Oct 2016 18:38:57 +0200 Subject: [PATCH] Add visual indication of where the Atomic Reconstructor hits --- .../mod/misc/MethodHandler.java | 51 +++++++++++-------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/MethodHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/MethodHandler.java index f051aedf8..bb3a19af8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/MethodHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/MethodHandler.java @@ -34,9 +34,11 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.WorldServer; import java.util.ArrayList; import java.util.List; @@ -138,33 +140,40 @@ public class MethodHandler implements IMethodHandler{ for(int reachZ = -range; reachZ < range+1; reachZ++){ for(int reachY = -range; reachY < range+1; reachY++){ BlockPos pos = new BlockPos(hitBlock.getX()+reachX, hitBlock.getY()+reachY, hitBlock.getZ()+reachZ); - IBlockState state = tile.getWorldObject().getBlockState(pos); - List recipes = LensRecipeHandler.getRecipesFor(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state))); - for(LensConversionRecipe recipe : recipes){ - if(recipe != null && recipe.type == tile.getLens() && tile.getEnergy() >= recipe.energyUse){ - List outputs = RecipeUtil.getConversionLensOutputs(recipe); - if(outputs != null && !outputs.isEmpty()){ - ItemStack output = outputs.get(0); - if(output != null){ - if(!ConfigBoolValues.LESS_BLOCK_BREAKING_EFFECTS.isEnabled()){ - tile.getWorldObject().playEvent(2001, pos, Block.getStateId(tile.getWorldObject().getBlockState(pos))); - } + if(!tile.getWorldObject().isAirBlock(pos)){ + IBlockState state = tile.getWorldObject().getBlockState(pos); + List recipes = LensRecipeHandler.getRecipesFor(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state))); + for(LensConversionRecipe recipe : recipes){ + if(recipe != null && recipe.type == tile.getLens() && tile.getEnergy() >= recipe.energyUse){ + List outputs = RecipeUtil.getConversionLensOutputs(recipe); + if(outputs != null && !outputs.isEmpty()){ + ItemStack output = outputs.get(0); + if(output != null){ + if(!ConfigBoolValues.LESS_BLOCK_BREAKING_EFFECTS.isEnabled()){ + tile.getWorldObject().playEvent(2001, pos, Block.getStateId(tile.getWorldObject().getBlockState(pos))); + } - if(output.getItem() instanceof ItemBlock){ - tile.getWorldObject().setBlockState(pos, Block.getBlockFromItem(output.getItem()).getStateFromMeta(output.getItemDamage()), 2); - } - else{ - EntityItem item = new EntityItem(tile.getWorldObject(), pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, output.copy()); - tile.getWorldObject().spawnEntityInWorld(item); - tile.getWorldObject().setBlockToAir(pos); - } + if(output.getItem() instanceof ItemBlock){ + tile.getWorldObject().setBlockState(pos, Block.getBlockFromItem(output.getItem()).getStateFromMeta(output.getItemDamage()), 2); + } + else{ + EntityItem item = new EntityItem(tile.getWorldObject(), pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, output.copy()); + tile.getWorldObject().spawnEntityInWorld(item); + tile.getWorldObject().setBlockToAir(pos); + } - tile.extractEnergy(recipe.energyUse); - break; + tile.extractEnergy(recipe.energyUse); + break; + } } } } } + else{ + if(tile.getWorldObject() instanceof WorldServer){ + ((WorldServer)tile.getWorldObject()).spawnParticle(EnumParticleTypes.END_ROD, false, pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, 1, 0, 0, 0, 0D); + } + } } } }