From 83262093ebf682bbcc9f369d5416ea07666f96b2 Mon Sep 17 00:00:00 2001 From: thatsIch Date: Tue, 4 Nov 2014 02:18:37 +0100 Subject: [PATCH] Adding save handle to get Entities Within AABB Excluding Entity --- .../java/appeng/entity/AEBaseEntityItem.java | 43 +++++++++++++++++++ .../appeng/entity/EntityChargedQuartz.java | 8 +--- .../java/appeng/entity/EntitySingularity.java | 8 +--- 3 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 src/main/java/appeng/entity/AEBaseEntityItem.java diff --git a/src/main/java/appeng/entity/AEBaseEntityItem.java b/src/main/java/appeng/entity/AEBaseEntityItem.java new file mode 100644 index 000000000..6eac2d192 --- /dev/null +++ b/src/main/java/appeng/entity/AEBaseEntityItem.java @@ -0,0 +1,43 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.entity; + + +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +import java.util.List; + + +public abstract class AEBaseEntityItem extends EntityItem +{ + public AEBaseEntityItem( World p_i1710_1_, double p_i1710_2_, double p_i1710_4_, double p_i1710_6_, ItemStack p_i1710_8_ ) + { + super( p_i1710_1_, p_i1710_2_, p_i1710_4_, p_i1710_6_, p_i1710_8_ ); + } + + @SuppressWarnings( "unchecked" ) + public List getCheckedEntitiesWithinAABBExcludingEntity( AxisAlignedBB region ) + { + return this.worldObj.getEntitiesWithinAABBExcludingEntity( this, region ); + } +} diff --git a/src/main/java/appeng/entity/EntityChargedQuartz.java b/src/main/java/appeng/entity/EntityChargedQuartz.java index 32277ecec..1d11461b9 100644 --- a/src/main/java/appeng/entity/EntityChargedQuartz.java +++ b/src/main/java/appeng/entity/EntityChargedQuartz.java @@ -18,16 +18,12 @@ import appeng.core.CommonHelper; import appeng.core.features.AEFeature; import appeng.util.Platform; -final public class EntityChargedQuartz extends EntityItem +final public class EntityChargedQuartz extends AEBaseEntityItem { int delay = 0; int transformTime = 0; - public EntityChargedQuartz(World w) { - super( w ); - } - public EntityChargedQuartz(World w, double x, double y, double z, ItemStack is) { super( w, x, y, z, is ); } @@ -70,7 +66,7 @@ final public class EntityChargedQuartz extends EntityItem if ( AEApi.instance().materials().materialCertusQuartzCrystalCharged.sameAsStack( item ) ) { AxisAlignedBB region = AxisAlignedBB.getBoundingBox( posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1 ); - List l = worldObj.getEntitiesWithinAABBExcludingEntity( this, region ); + List l = this.getCheckedEntitiesWithinAABBExcludingEntity( region ); EntityItem redstone = null; EntityItem netherQuartz = null; diff --git a/src/main/java/appeng/entity/EntitySingularity.java b/src/main/java/appeng/entity/EntitySingularity.java index 2b0e9c576..513330aaf 100644 --- a/src/main/java/appeng/entity/EntitySingularity.java +++ b/src/main/java/appeng/entity/EntitySingularity.java @@ -16,15 +16,11 @@ import appeng.core.AEConfig; import appeng.core.features.AEFeature; import appeng.util.Platform; -final public class EntitySingularity extends EntityItem +final public class EntitySingularity extends AEBaseEntityItem { static private int randTickSeed = 0; - public EntitySingularity(World w) { - super( w ); - } - public EntitySingularity(World w, double x, double y, double z, ItemStack is) { super( w, x, y, z, is ); } @@ -53,7 +49,7 @@ final public class EntitySingularity extends EntityItem if ( AEApi.instance().materials().materialSingularity.sameAsStack( item ) ) { AxisAlignedBB region = AxisAlignedBB.getBoundingBox( posX - 4, posY - 4, posZ - 4, posX + 4, posY + 4, posZ + 4 ); - List l = worldObj.getEntitiesWithinAABBExcludingEntity( this, region ); + List l = this.getCheckedEntitiesWithinAABBExcludingEntity( region ); for (Entity e : l) {