mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-14 04:09:09 +01:00
Make the reconstructor convert without needing blocks
This commit is contained in:
parent
919ebfde35
commit
798a56ec63
3 changed files with 36 additions and 14 deletions
|
@ -11,6 +11,7 @@
|
||||||
package de.ellpeck.actuallyadditions.api.internal;
|
package de.ellpeck.actuallyadditions.api.internal;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,4 +53,6 @@ public interface IAtomicReconstructor{
|
||||||
int getEnergy();
|
int getEnergy();
|
||||||
|
|
||||||
Lens getLens();
|
Lens getLens();
|
||||||
|
|
||||||
|
EnumFacing getOrientation();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,10 @@ 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.EnumFacing;
|
||||||
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;
|
||||||
|
@ -133,13 +132,32 @@ public class MethodHandler implements IMethodHandler{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean invokeConversionLens(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){
|
public boolean invokeConversionLens(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){
|
||||||
if(hitBlock != null && !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock)){
|
if(hitBlock != null){
|
||||||
int range = 2;
|
int range = 1;
|
||||||
|
int rangeX = 0;
|
||||||
|
int rangeY = 0;
|
||||||
|
int rangeZ = 0;
|
||||||
|
|
||||||
|
EnumFacing facing = tile.getOrientation();
|
||||||
|
if(facing != EnumFacing.UP && facing != EnumFacing.DOWN){
|
||||||
|
rangeY = range;
|
||||||
|
|
||||||
|
if(facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH){
|
||||||
|
rangeX = range;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
rangeZ = range;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
rangeX = range;
|
||||||
|
rangeZ = range;
|
||||||
|
}
|
||||||
|
|
||||||
//Converting the Blocks
|
//Converting the Blocks
|
||||||
for(int reachX = -range; reachX < range+1; reachX++){
|
for(int reachX = -rangeX; reachX <= rangeX; reachX++){
|
||||||
for(int reachZ = -range; reachZ < range+1; reachZ++){
|
for(int reachZ = -rangeZ; reachZ <= rangeZ; reachZ++){
|
||||||
for(int reachY = -range; reachY < range+1; reachY++){
|
for(int reachY = -rangeY; reachY <= rangeY; 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);
|
||||||
if(!tile.getWorldObject().isAirBlock(pos)){
|
if(!tile.getWorldObject().isAirBlock(pos)){
|
||||||
IBlockState state = tile.getWorldObject().getBlockState(pos);
|
IBlockState state = tile.getWorldObject().getBlockState(pos);
|
||||||
|
@ -165,17 +183,12 @@ public class MethodHandler implements IMethodHandler{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Converting the Items
|
//Converting the Items
|
||||||
ArrayList<EntityItem> items = (ArrayList<EntityItem>)tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX()-range, hitBlock.getY()-range, hitBlock.getZ()-range, hitBlock.getX()+range, hitBlock.getY()+range, hitBlock.getZ()+range));
|
ArrayList<EntityItem> items = (ArrayList<EntityItem>)tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX()-rangeX, hitBlock.getY()-rangeY, hitBlock.getZ()-rangeZ, hitBlock.getX()+1+rangeX, hitBlock.getY()+1+rangeY, hitBlock.getZ()+1+rangeZ));
|
||||||
for(EntityItem item : items){
|
for(EntityItem item : items){
|
||||||
ItemStack stack = item.getEntityItem();
|
ItemStack stack = item.getEntityItem();
|
||||||
if(!item.isDead && StackUtil.isValid(stack)){
|
if(!item.isDead && StackUtil.isValid(stack)){
|
||||||
|
@ -208,7 +221,7 @@ public class MethodHandler implements IMethodHandler{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,12 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumFacing getOrientation(){
|
||||||
|
IBlockState state = this.worldObj.getBlockState(this.pos);
|
||||||
|
return WorldUtil.getDirectionByPistonRotation(state.getBlock().getMetaFromState(state));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readSyncableNBT(NBTTagCompound compound, NBTType type){
|
public void readSyncableNBT(NBTTagCompound compound, NBTType type){
|
||||||
super.readSyncableNBT(compound, type);
|
super.readSyncableNBT(compound, type);
|
||||||
|
|
Loading…
Reference in a new issue