diff --git a/src/main/java/openblocks/common/entity/EntityHangGlider.java b/src/main/java/openblocks/common/entity/EntityHangGlider.java index f2557e9d..fa9d6521 100644 --- a/src/main/java/openblocks/common/entity/EntityHangGlider.java +++ b/src/main/java/openblocks/common/entity/EntityHangGlider.java @@ -1,6 +1,7 @@ package openblocks.common.entity; import java.util.Calendar; +import java.util.HashMap; import java.util.Map; import java.util.Random; @@ -12,8 +13,6 @@ import net.minecraft.world.World; import net.minecraft.world.gen.NoiseGeneratorPerlin; -import com.google.common.collect.MapMaker; - import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -48,7 +47,7 @@ public class EntityHangGlider extends Entity implements IEntityAdditionalSpawnDa private static final int PROPERTY_DEPLOYED = 17; - private static Map gliderMap = new MapMaker().weakKeys().weakValues().makeMap(); + private static Map gliderMap = new HashMap<>(); private IVarioController varioControl = IVarioController.NULL; @@ -62,6 +61,10 @@ public static boolean isGliderDeployed(Entity player) { return glider != null && glider.isDeployed(); } + public static EntityHangGlider getEntityHangGlider(Entity player) { + return gliderMap.get(player); + } + private static boolean isGliderValid(EntityPlayer player, EntityHangGlider glider) { if (player == null || player.isDead || glider == null || glider.isDead) return false; diff --git a/src/main/java/openblocks/common/item/ItemHangGlider.java b/src/main/java/openblocks/common/item/ItemHangGlider.java index 6f3bc04e..80eef7c8 100644 --- a/src/main/java/openblocks/common/item/ItemHangGlider.java +++ b/src/main/java/openblocks/common/item/ItemHangGlider.java @@ -1,7 +1,6 @@ package openblocks.common.item; import java.util.HashSet; -import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -10,8 +9,6 @@ import net.minecraft.world.World; import net.minecraftforge.common.config.Configuration; -import com.google.common.collect.MapMaker; - import cpw.mods.fml.common.event.FMLPreInitializationEvent; import openblocks.OpenBlocks; import openblocks.common.entity.EntityHangGlider; @@ -20,9 +17,6 @@ @BookDocumentation(hasVideo = true) public class ItemHangGlider extends Item { - private static final Map spawnedGlidersMap = new MapMaker().weakKeys().weakValues() - .makeMap(); - private static HashSet blacklistedDimensions = new HashSet<>(); public ItemHangGlider() { @@ -103,7 +97,7 @@ public static void loadConfig(FMLPreInitializationEvent event) { @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { if (!world.isRemote && player != null) { - EntityHangGlider glider = spawnedGlidersMap.get(player); + EntityHangGlider glider = EntityHangGlider.getEntityHangGlider(player); if (glider != null) despawnGlider(player, glider); else spawnGlider(player); } @@ -112,7 +106,6 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer private static void despawnGlider(EntityPlayer player, EntityHangGlider glider) { glider.setDead(); - spawnedGlidersMap.remove(player); } private static void spawnGlider(EntityPlayer player) { @@ -124,7 +117,6 @@ private static void spawnGlider(EntityPlayer player) { EntityHangGlider glider = new EntityHangGlider(player.worldObj, player); glider.setPositionAndRotation(player.posX, player.posY, player.posZ, player.rotationPitch, player.rotationYaw); player.worldObj.spawnEntityInWorld(glider); - spawnedGlidersMap.put(player, glider); } private static boolean isInvalidDimension(EntityPlayer player) {