Caveman debugging the rename bit sync...

This commit is contained in:
Ammon Lauritzen 2016-02-23 15:12:05 -06:00
parent 186234b17a
commit c2ab723e19
4 changed files with 23 additions and 6 deletions

View File

@ -19,6 +19,8 @@ public class GuiName extends GuiScreen
public GuiName(EntityFairy entityfairy)
{
FairyFactions.LOGGER.info("GuiName: constructed");
screenTitle = "Enter custom name or leave blank for default:";
fairy = entityfairy;
nameText = "";
@ -44,6 +46,8 @@ public class GuiName extends GuiScreen
if (fairy != null)
{
FairyFactions.LOGGER.info("GuiName.onGuiClosed: isRemote = "+fairy.worldObj.isRemote);
if (fairy.worldObj.isRemote)
{
//String s1 = "setfryname " + fairy.getEntityId() + " " + nameText;

View File

@ -256,7 +256,7 @@ public class EntityFairy extends EntityAnimal {
}
}
@SuppressWarnings("unused")
//@SuppressWarnings("unused")
@Override
public void onUpdate() {
super.onUpdate();
@ -393,11 +393,12 @@ public class EntityFairy extends EntityAnimal {
*/
}
}
}
// not sure why this was inside the check above...
if (nameEnabled() && tamed() && hasRuler()) {
FairyFactions.proxy.openRenameGUI(this);
// not sure why this was inside the check above...
if (nameEnabled() && tamed() && hasRuler()) {
FairyFactions.LOGGER.info("EntityFairy.onUpdate: calling proxy.openRenameGUI");
FairyFactions.proxy.openRenameGUI(this);
}
}
// NB: this was only on the client in the original
@ -2390,6 +2391,8 @@ public class EntityFairy extends EntityAnimal {
return true;
} else if (onGround && stack != null
&& namingItem(stack.getItem()) && stack.stackSize > 0) {
FairyFactions.LOGGER.info("EntityFairy.interract: consuming paper and setting name enabled");
// right-clicking with paper will open the rename gui
stack.stackSize--;

View File

@ -28,6 +28,8 @@ public class PacketSetFairyName extends FairyPacket {
@Override
protected void pack() {
FairyFactions.LOGGER.info("PacketSetFairyName.pack");
final PacketBuffer buf = (PacketBuffer)this.payload();
buf.writeInt(this.fairyID);
try {
@ -40,6 +42,8 @@ public class PacketSetFairyName extends FairyPacket {
@Override
public void init(PacketBuffer buf) {
FairyFactions.LOGGER.info("PacketSetFairyName.init");
fairyID = buf.readInt();
try {
name = buf.readStringFromBuffer(MAX_NAME_LENGTH).trim();
@ -53,6 +57,8 @@ public class PacketSetFairyName extends FairyPacket {
@Override
public void handle(NetworkManager origin) {
FairyFactions.LOGGER.info("PacketSetFairyName.handle");
final EntityPlayerMP player = ((NetHandlerPlayServer)origin.getNetHandler()).playerEntity;
if( player != null ) {
final EntityFairy fairy = FairyFactions.getFairy(this.fairyID);

View File

@ -3,6 +3,7 @@ package fairies.proxy;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import fairies.FairyFactions;
import fairies.client.gui.GuiName;
import fairies.client.render.ModelFairy;
import fairies.client.render.RenderFairy;
@ -38,7 +39,10 @@ public class ClientProxy extends CommonProxy {
@Override
public void openRenameGUI(EntityFairy fairy) {
FairyFactions.LOGGER.info("ClientProxy.openRenameGUI");
if( fairy.isRuler(getCurrentPlayer()) ) {
FairyFactions.LOGGER.info("ClientProxy.openRenameGUI: current player is ruler, displaying gui");
fairy.setNameEnabled(false);
Minecraft.getMinecraft().displayGuiScreen(new GuiName(fairy));
}