mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Fixed goggles being a little broken
This commit is contained in:
parent
9b21323c4f
commit
bdabd081be
1 changed files with 25 additions and 8 deletions
|
@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemArmorAA;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemArmorAA;
|
||||||
import de.ellpeck.actuallyadditions.mod.material.InitArmorMaterials;
|
import de.ellpeck.actuallyadditions.mod.material.InitArmorMaterials;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
import io.netty.util.internal.ConcurrentSet;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
|
@ -26,9 +27,12 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class ItemInfraredGoggles extends ItemArmorAA{
|
public class ItemInfraredGoggles extends ItemArmorAA{
|
||||||
|
|
||||||
|
private final Set<Entity> cachedGlowingEntities = new ConcurrentSet<Entity>();
|
||||||
|
|
||||||
public ItemInfraredGoggles(String name){
|
public ItemInfraredGoggles(String name){
|
||||||
super(name, InitArmorMaterials.armorMaterialGoggles, 0, StackUtil.getNull());
|
super(name, InitArmorMaterials.armorMaterialGoggles, 0, StackUtil.getNull());
|
||||||
this.setMaxDamage(0);
|
this.setMaxDamage(0);
|
||||||
|
@ -41,21 +45,34 @@ public class ItemInfraredGoggles extends ItemArmorAA{
|
||||||
public void onClientTick(ClientTickEvent event){
|
public void onClientTick(ClientTickEvent event){
|
||||||
EntityPlayer player = ActuallyAdditions.proxy.getCurrentPlayer();
|
EntityPlayer player = ActuallyAdditions.proxy.getCurrentPlayer();
|
||||||
if(player != null && isWearing(player)){
|
if(player != null && isWearing(player)){
|
||||||
double innerRange = 8;
|
double range = 8;
|
||||||
double remRange = innerRange+2;
|
AxisAlignedBB aabb = new AxisAlignedBB(player.posX-range, player.posY-range, player.posZ-range, player.posX+range, player.posY+range, player.posZ+range);
|
||||||
|
|
||||||
AxisAlignedBB aabb = new AxisAlignedBB(player.posX-remRange, player.posY-remRange, player.posZ-remRange, player.posX+remRange, player.posY+remRange, player.posZ+remRange);
|
|
||||||
List<Entity> entities = player.world.getEntitiesWithinAABB(Entity.class, aabb);
|
List<Entity> entities = player.world.getEntitiesWithinAABB(Entity.class, aabb);
|
||||||
|
if(entities != null && !entities.isEmpty()){
|
||||||
|
this.cachedGlowingEntities.addAll(entities);
|
||||||
|
}
|
||||||
|
|
||||||
for(Entity entity : entities){
|
if(!this.cachedGlowingEntities.isEmpty()){
|
||||||
if(entity != player){
|
for(Entity entity : this.cachedGlowingEntities){
|
||||||
if(entity.getDistanceSq(player.posX, player.posY, player.posZ) <= innerRange*innerRange){
|
if(entity.getDistanceSq(player.posX, player.posY, player.posZ) > range*range){
|
||||||
entity.setGlowing(true);
|
entity.setGlowing(false);
|
||||||
|
|
||||||
|
this.cachedGlowingEntities.remove(entity);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
entity.setGlowing(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(!this.cachedGlowingEntities.isEmpty()){
|
||||||
|
for(Entity entity : this.cachedGlowingEntities){
|
||||||
|
if(!entity.isDead){
|
||||||
entity.setGlowing(false);
|
entity.setGlowing(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.cachedGlowingEntities.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue