Add visual indication of where the Atomic Reconstructor hits

This commit is contained in:
Ellpeck 2016-10-19 18:38:57 +02:00
parent 1d5a40804d
commit e3e5910443

View file

@ -34,9 +34,11 @@ import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -138,33 +140,40 @@ public class MethodHandler implements IMethodHandler{
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++){
BlockPos pos = new BlockPos(hitBlock.getX()+reachX, hitBlock.getY()+reachY, hitBlock.getZ()+reachZ); BlockPos pos = new BlockPos(hitBlock.getX()+reachX, hitBlock.getY()+reachY, hitBlock.getZ()+reachZ);
IBlockState state = tile.getWorldObject().getBlockState(pos); if(!tile.getWorldObject().isAirBlock(pos)){
List<LensConversionRecipe> recipes = LensRecipeHandler.getRecipesFor(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state))); IBlockState state = tile.getWorldObject().getBlockState(pos);
for(LensConversionRecipe recipe : recipes){ List<LensConversionRecipe> recipes = LensRecipeHandler.getRecipesFor(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)));
if(recipe != null && recipe.type == tile.getLens() && tile.getEnergy() >= recipe.energyUse){ for(LensConversionRecipe recipe : recipes){
List<ItemStack> outputs = RecipeUtil.getConversionLensOutputs(recipe); if(recipe != null && recipe.type == tile.getLens() && tile.getEnergy() >= recipe.energyUse){
if(outputs != null && !outputs.isEmpty()){ List<ItemStack> outputs = RecipeUtil.getConversionLensOutputs(recipe);
ItemStack output = outputs.get(0); if(outputs != null && !outputs.isEmpty()){
if(output != null){ ItemStack output = outputs.get(0);
if(!ConfigBoolValues.LESS_BLOCK_BREAKING_EFFECTS.isEnabled()){ if(output != null){
tile.getWorldObject().playEvent(2001, pos, Block.getStateId(tile.getWorldObject().getBlockState(pos))); if(!ConfigBoolValues.LESS_BLOCK_BREAKING_EFFECTS.isEnabled()){
} tile.getWorldObject().playEvent(2001, pos, Block.getStateId(tile.getWorldObject().getBlockState(pos)));
}
if(output.getItem() instanceof ItemBlock){ if(output.getItem() instanceof ItemBlock){
tile.getWorldObject().setBlockState(pos, Block.getBlockFromItem(output.getItem()).getStateFromMeta(output.getItemDamage()), 2); tile.getWorldObject().setBlockState(pos, Block.getBlockFromItem(output.getItem()).getStateFromMeta(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());
tile.getWorldObject().spawnEntityInWorld(item); tile.getWorldObject().spawnEntityInWorld(item);
tile.getWorldObject().setBlockToAir(pos); tile.getWorldObject().setBlockToAir(pos);
} }
tile.extractEnergy(recipe.energyUse); tile.extractEnergy(recipe.energyUse);
break; 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);
}
}
} }
} }
} }