mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-13 16:54:06 +00:00
Fix reach ring (#95)
Co-authored-by: Martin Robertz <dream-master@gmx.net>
This commit is contained in:
1 parent
7c42710a1a
commit
33be87e896
4 files changed
+15
-81
No files matched your search
@@ -383,7 +383,8 @@ public class ClientProxy extends CommonProxy {
|
||||
super.setExtraReach(entity, reach);
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
if(entity == player) {
|
||||
// Player object might have changed, need to check the UUID.
|
||||
if(entity.worldObj.isRemote && entity.getUniqueID().equals(player.getUniqueID())) {
|
||||
if(!(mc.playerController instanceof IExtendedPlayerController)) {
|
||||
GameType type = ReflectionHelper.getPrivateValue(PlayerControllerMP.class, mc.playerController, LibObfuscation.CURRENT_GAME_TYPE);
|
||||
NetHandlerPlayClient net = ReflectionHelper.getPrivateValue(PlayerControllerMP.class, mc.playerController, LibObfuscation.NET_CLIENT_HANDLER);
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package vazkii.botania.common.core.handler;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemBauble;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class ItemBaubleHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void disconnectFromServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
|
||||
if(Minecraft.getMinecraft().thePlayer != null) {
|
||||
ItemBauble.removePlayer(Minecraft.getMinecraft().thePlayer.getUniqueID());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerDisconnect(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
ItemBauble.removePlayer(event.player.getUniqueID());
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,6 @@ import vazkii.botania.common.core.handler.ChestGenHandler;
|
||||
import vazkii.botania.common.core.handler.CommonTickHandler;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.core.handler.InternalMethodHandler;
|
||||
import vazkii.botania.common.core.handler.ItemBaubleHandler;
|
||||
import vazkii.botania.common.core.handler.ManaNetworkHandler;
|
||||
import vazkii.botania.common.core.handler.PixieHandler;
|
||||
import vazkii.botania.common.core.handler.SheddingHandler;
|
||||
@@ -146,7 +145,6 @@ public class CommonProxy {
|
||||
MinecraftForge.EVENT_BUS.register(new SkyblockWorldEvents());
|
||||
|
||||
FMLCommonHandler.instance().bus().register(new CommonTickHandler());
|
||||
FMLCommonHandler.instance().bus().register(new ItemBaubleHandler());
|
||||
|
||||
FMLInterModComms.sendMessage("ProjectE", "interdictionblacklist", EntityManaBurst.class.getCanonicalName());
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.equipment.bauble;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import baubles.api.BaublesApi;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
@@ -45,9 +45,6 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
|
||||
private static final String TAG_COSMETIC_ITEM = "cosmeticItem";
|
||||
private static final String TAG_PHANTOM_INK = "phantomInk";
|
||||
|
||||
private static final HashMap<UUID, UUID> itemToPlayerRemote = new HashMap<>();
|
||||
private static final HashMap<UUID, UUID> itemToPlayer = new HashMap<>();
|
||||
private static final HashSet<UUID> toRemoveItems = new HashSet<>();
|
||||
|
||||
public ItemBauble(String name) {
|
||||
super();
|
||||
@@ -127,18 +124,12 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, EntityLivingBase player) {
|
||||
UUID itemUUID = getBaubleUUID(stack);
|
||||
if(toRemoveItems.contains(itemUUID)) {
|
||||
// this is done like this because on server worn tick gets called after unequip
|
||||
// so it would get reapplied
|
||||
unapplyItem(itemUUID, player.worldObj.isRemote);
|
||||
toRemoveItems.remove(itemUUID);
|
||||
return;
|
||||
}
|
||||
if(!wasPlayerApplied(itemUUID, player.getUniqueID(), player.worldObj.isRemote)) {
|
||||
onEquippedOrLoadedIntoWorld(stack, player);
|
||||
applyToPlayer(itemUUID, player.getUniqueID(), player.worldObj.isRemote);
|
||||
}
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerLoad(ItemStack stack, EntityLivingBase player) {
|
||||
onEquippedOrLoadedIntoWorld(stack, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,17 +142,16 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
|
||||
((EntityPlayer) player).addStat(ModAchievements.baubleWear, 1);
|
||||
|
||||
onEquippedOrLoadedIntoWorld(stack, player);
|
||||
applyToPlayer(getBaubleUUID(stack), player.getUniqueID(), player.worldObj.isRemote);
|
||||
}
|
||||
}
|
||||
|
||||
public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
|
||||
toRemoveItems.add(getBaubleUUID(stack));
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,39 +198,6 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
|
||||
return new UUID(most, least);
|
||||
}
|
||||
|
||||
public static boolean wasPlayerApplied(UUID itemUUID, UUID playerUUID, boolean remote) {
|
||||
return playerUUID.equals(remote ? itemToPlayerRemote.get(itemUUID) : itemToPlayer.get(itemUUID));
|
||||
}
|
||||
|
||||
public static void applyToPlayer(UUID itemUUID, UUID playerUUID, boolean remote) {
|
||||
if(remote) {
|
||||
itemToPlayerRemote.put(itemUUID, playerUUID);
|
||||
} else {
|
||||
itemToPlayer.put(itemUUID, playerUUID);
|
||||
}
|
||||
}
|
||||
|
||||
public static void unapplyItem(UUID itemUUID, boolean remote) {
|
||||
if(remote) {
|
||||
itemToPlayerRemote.remove(itemUUID);
|
||||
} else {
|
||||
itemToPlayer.remove(itemUUID);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removePlayer(UUID playerUUID) {
|
||||
for(UUID item : itemToPlayerRemote.keySet().toArray(new UUID[0])) {
|
||||
if(playerUUID.equals(itemToPlayerRemote.get(item))) {
|
||||
itemToPlayerRemote.remove(item);
|
||||
}
|
||||
}
|
||||
for(UUID item : itemToPlayer.keySet().toArray(new UUID[0])) {
|
||||
if(playerUUID.equals(itemToPlayer.get(item))) {
|
||||
itemToPlayer.remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPhantomInk(ItemStack stack) {
|
||||
return ItemNBTHelper.getBoolean(stack, TAG_PHANTOM_INK, false);
|
||||
|
||||
Reference in new issue
Block a user