From 434d36e9849f27e77e04a9d6e05056ffc9e1719e Mon Sep 17 00:00:00 2001 From: ata4 Date: Wed, 13 Aug 2014 16:29:02 +0200 Subject: [PATCH] Looks like Minecraft uses UUIDs for owners now, so this is the *actual* fix for the sitting bug --- .../dragon/client/gui/GuiDragonDebug.java | 16 +++++++++--- .../server/entity/EntityTameableDragon.java | 25 ++++--------------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/main/java/info/ata4/minecraft/dragon/client/gui/GuiDragonDebug.java b/src/main/java/info/ata4/minecraft/dragon/client/gui/GuiDragonDebug.java index 7a6930e9..8b31e9a0 100644 --- a/src/main/java/info/ata4/minecraft/dragon/client/gui/GuiDragonDebug.java +++ b/src/main/java/info/ata4/minecraft/dragon/client/gui/GuiDragonDebug.java @@ -32,6 +32,7 @@ import net.minecraft.entity.DataWatcher; import net.minecraft.entity.DataWatcher.WatchableObject; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAITasks; import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; import net.minecraft.entity.ai.attributes.IAttributeInstance; @@ -44,6 +45,7 @@ import net.minecraftforge.client.GuiIngameForge; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.lwjgl.input.Keyboard; @@ -191,6 +193,7 @@ private void renderEntityInfo() { text.println("Side: " + (dragon.isServer() ? "server" : "client")); text.println("ID: " + dragon.getEntityId()); + text.println("UUID: " + StringUtils.abbreviate(dragon.getUniqueID().toString(), 22)); text.println("Name: " + dragon.getCommandSenderName()); // position @@ -232,11 +235,16 @@ private void renderEntityInfo() { // tamed flag/owner name //String tamedString = dragon.getOwnerName(); - String tamedString = dragon.func_152113_b(); - if (tamedString.isEmpty()) { - tamedString = "no"; + String tamedString; + if (dragon.isTamed()) { + EntityLivingBase player = dragon.getOwner(); + if (player != null) { + tamedString = "yes (" + player.getCommandSenderName() + ")"; + } else { + tamedString = "yes (" + StringUtils.abbreviate(dragon.func_152113_b(), 22) + ")"; + } } else { - tamedString = "yes (" + tamedString + ")"; + tamedString = "no"; } text.println("Tamed: " + tamedString); diff --git a/src/main/java/info/ata4/minecraft/dragon/server/entity/EntityTameableDragon.java b/src/main/java/info/ata4/minecraft/dragon/server/entity/EntityTameableDragon.java index 2920fa3e..e41f8001 100644 --- a/src/main/java/info/ata4/minecraft/dragon/server/entity/EntityTameableDragon.java +++ b/src/main/java/info/ata4/minecraft/dragon/server/entity/EntityTameableDragon.java @@ -451,7 +451,8 @@ public boolean interact(EntityPlayer player) { return true; } - if (!isOwner(player)) { + //if (!isOwner(player)) { + if (!func_152114_e(player)) { if (isServer()) { // that's not your dragon! player.addChatMessage(new ChatComponentTranslation("dragon.owned")); @@ -465,9 +466,7 @@ public boolean interact(EntityPlayer player) { } else if (ItemUtils.hasEquipped(player, Items.bone)) { if (isServer()) { // toggle sitting state with the bone item - boolean sitting = !isSitting(); - setSitting(sitting); - aiSit.setSitting(sitting); + aiSit.setSitting(!isSitting()); isJumping = false; setPathToEntity(null); } @@ -505,7 +504,7 @@ public void tamedFor(EntityPlayer player, boolean successful) { setPathToEntity(null); setAttackTarget(null); //setOwner(player.getCommandSenderName()); - func_152115_b(player.getCommandSenderName()); + func_152115_b(player.getUniqueID().toString()); playTameEffect(true); worldObj.setEntityState(this, (byte) 7); } else { @@ -773,15 +772,6 @@ public DragonBreed getBreed() { public void setBreed(DragonBreed breed) { getBreedHelper().setBreed(breed); } - - public boolean isOwner(EntityPlayer player) { - //return player.getCommandSenderName().equalsIgnoreCase(getOwnerName()); - return player.getCommandSenderName().equalsIgnoreCase(func_152113_b()); - } - - public boolean isRiddenByOwner() { - return riddenByEntity == getOwner(); - } public EntityPlayer getRidingPlayer() { if (riddenByEntity instanceof EntityPlayer) { @@ -853,12 +843,7 @@ public boolean isInvulnerableTo(DamageSource src) { return true; } - // breed-dependent immunities - if (getBreed().isImmuneToDamage(src)) { - return true; - } - - return false; + return getBreed().isImmuneToDamage(src); } /**