mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Fix booklet stand not working on servers & crash when initializing booklet
This commit is contained in:
parent
abec9c81af
commit
a99ff70c4d
14 changed files with 52 additions and 15 deletions
|
@ -89,8 +89,8 @@ public class BlockBookletStand extends BlockContainerBase implements IActAddItem
|
|||
TileEntityBookletStand tile = (TileEntityBookletStand)world.getTileEntity(x, y, z);
|
||||
if(tile != null){
|
||||
//Assign a UUID
|
||||
if(tile.assignedPlayerUUID == null){
|
||||
tile.assignedPlayerUUID = player.getUniqueID();
|
||||
if(tile.assignedPlayer == null){
|
||||
tile.assignedPlayer = player.getCommandSenderName();
|
||||
tile.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ import ellpeck.actuallyadditions.tile.TileEntityBookletStand;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiBookletStand extends GuiBooklet{
|
||||
|
||||
|
@ -52,7 +54,7 @@ public class GuiBookletStand extends GuiBooklet{
|
|||
};
|
||||
this.buttonList.add(this.buttonSetPage);
|
||||
|
||||
this.buttonSetPage.visible = Minecraft.getMinecraft().thePlayer.getUniqueID().equals(this.theStand.assignedPlayerUUID);
|
||||
this.buttonSetPage.visible = Objects.equals(Minecraft.getMinecraft().thePlayer.getCommandSenderName(), this.theStand.assignedPlayer);
|
||||
|
||||
//Open the pages the book was assigned
|
||||
BookletUtils.openIndexEntry(this, this.theStand.assignedEntry, this.theStand.assignedPageInIndex, true);
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
package ellpeck.actuallyadditions.booklet.page;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.booklet.BookletUtils;
|
||||
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
||||
import ellpeck.actuallyadditions.booklet.InitBooklet;
|
||||
|
@ -58,6 +60,7 @@ public class BookletPage{
|
|||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderItem(GuiScreen gui, ItemStack stack, int x, int y, float scale){
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
|
@ -113,19 +116,23 @@ public class BookletPage{
|
|||
return this;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateScreen(int ticksElapsed){
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void renderTooltipAndTransfer(GuiBooklet gui, ItemStack stack, int x, int y, boolean checkAndTransfer, boolean mousePressed){
|
||||
boolean flagBefore = gui.mc.fontRenderer.getUnicodeFlag();
|
||||
gui.mc.fontRenderer.setUnicodeFlag(false);
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
package ellpeck.actuallyadditions.booklet.page;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
||||
import ellpeck.actuallyadditions.items.InitItems;
|
||||
import ellpeck.actuallyadditions.items.ItemCoffee;
|
||||
|
@ -28,6 +30,7 @@ public class PageCoffeeRecipe extends BookletPage{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
gui.mc.getTextureManager().bindTexture(ClientProxy.bulletForMyValentine ? GuiBooklet.resLocValentine : GuiBooklet.resLoc);
|
||||
gui.drawTexturedModalRect(gui.guiLeft+19, gui.guiTop+20, 146, 94, 99, 60);
|
||||
|
@ -35,6 +38,7 @@ public class PageCoffeeRecipe extends BookletPage{
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
String strg = "Coffee Machine Recipe";
|
||||
gui.mc.fontRenderer.drawString(strg, gui.guiLeft+gui.xSize/2-gui.mc.fontRenderer.getStringWidth(strg)/2, gui.guiTop+10, 0);
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
package ellpeck.actuallyadditions.booklet.page;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
||||
import ellpeck.actuallyadditions.proxy.ClientProxy;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
|
@ -43,6 +45,7 @@ public class PageCrafting extends BookletPage{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
if(this.recipes[this.recipePos] != null){
|
||||
gui.mc.getTextureManager().bindTexture(ClientProxy.bulletForMyValentine ? GuiBooklet.resLocValentine : GuiBooklet.resLoc);
|
||||
|
@ -52,6 +55,7 @@ public class PageCrafting extends BookletPage{
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
IRecipe recipe = this.recipes[this.recipePos];
|
||||
|
||||
|
@ -139,6 +143,7 @@ public class PageCrafting extends BookletPage{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateScreen(int ticksElapsed){
|
||||
if(ticksElapsed%15 == 0){
|
||||
if(this.recipePos+1 >= this.recipes.length){
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
package ellpeck.actuallyadditions.booklet.page;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
||||
import ellpeck.actuallyadditions.proxy.ClientProxy;
|
||||
import ellpeck.actuallyadditions.recipe.CrusherRecipeRegistry;
|
||||
|
@ -35,6 +37,7 @@ public class PageCrusherRecipe extends BookletPage{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
if(recipe != null){
|
||||
gui.mc.getTextureManager().bindTexture(ClientProxy.bulletForMyValentine ? GuiBooklet.resLocValentine : GuiBooklet.resLoc);
|
||||
|
@ -44,6 +47,7 @@ public class PageCrusherRecipe extends BookletPage{
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
if(recipe == null){
|
||||
gui.mc.fontRenderer.drawSplitString(EnumChatFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0);
|
||||
|
@ -105,6 +109,7 @@ public class PageCrusherRecipe extends BookletPage{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateScreen(int ticksElapsed){
|
||||
if(ticksElapsed%10 == 0){
|
||||
List<ItemStack> outputTwos = this.recipe.getRecipeOutputTwos();
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
package ellpeck.actuallyadditions.booklet.page;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
||||
import ellpeck.actuallyadditions.proxy.ClientProxy;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
|
@ -38,6 +40,7 @@ public class PageFurnace extends BookletPage{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
if(this.input != null || this.getInputForOutput(this.result) != null){
|
||||
gui.mc.getTextureManager().bindTexture(ClientProxy.bulletForMyValentine ? GuiBooklet.resLocValentine : GuiBooklet.resLoc);
|
||||
|
@ -47,6 +50,7 @@ public class PageFurnace extends BookletPage{
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
ItemStack input = this.input != null ? this.input : this.getInputForOutput(this.result);
|
||||
if(input == null){
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
package ellpeck.actuallyadditions.booklet.page;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
||||
import ellpeck.actuallyadditions.util.AssetUtil;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -26,6 +28,7 @@ public class PagePicture extends PageTextOnly{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
gui.mc.getTextureManager().bindTexture(this.resLoc);
|
||||
gui.drawTexturedModalRect(gui.guiLeft, gui.guiTop, 0, 0, gui.xSize, gui.ySize);
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
package ellpeck.actuallyadditions.booklet.page;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
||||
import ellpeck.actuallyadditions.proxy.ClientProxy;
|
||||
|
@ -40,6 +42,7 @@ public class PageReconstructor extends BookletPage{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateScreen(int ticksElapsed){
|
||||
if(ticksElapsed%15 == 0){
|
||||
if(this.recipePos+1 >= this.recipes.length){
|
||||
|
@ -52,6 +55,7 @@ public class PageReconstructor extends BookletPage{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
if(this.recipes[this.recipePos] != null){
|
||||
gui.mc.getTextureManager().bindTexture(ClientProxy.bulletForMyValentine ? GuiBooklet.resLocValentine : GuiBooklet.resLoc);
|
||||
|
@ -61,6 +65,7 @@ public class PageReconstructor extends BookletPage{
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
ReconstructorRecipeHandler.Recipe recipe = this.recipes[this.recipePos];
|
||||
if(recipe == null){
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
package ellpeck.actuallyadditions.booklet.page;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
@ -28,6 +30,7 @@ public class PageTextOnly extends BookletPage{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
||||
String text = gui.currentPage.getText();
|
||||
if(text != null && !text.isEmpty()){
|
||||
|
|
|
@ -119,7 +119,7 @@ public class ItemDrill extends ItemEnergy{
|
|||
//Notify the Player and log the Exception
|
||||
catch(Exception e){
|
||||
player.addChatComponentMessage(new ChatComponentText("Ouch! That really hurt! You must have done something wrong, don't do that again please!"));
|
||||
ModUtil.LOGGER.error("Player "+player.getDisplayName()+" who should place a Block using a Drill at "+player.posX+", "+player.posY+", "+player.posZ+" in World "+world.provider.dimensionId+" threw an Exception! Don't let that happen again!");
|
||||
ModUtil.LOGGER.error("Player "+player.getCommandSenderName()+" who should place a Block using a Drill at "+player.posX+", "+player.posY+", "+player.posZ+" in World "+world.provider.dimensionId+" threw an Exception! Don't let that happen again!");
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -37,7 +37,7 @@ public class SpecialRenderInit{
|
|||
if(!specialList.isEmpty()){
|
||||
for(Map.Entry<String, RenderSpecial> entry : specialList.entrySet()){
|
||||
//Does the player have one of the names from the list?
|
||||
if(StringUtil.equalsToLowerCase(entry.getKey(), event.entityPlayer.getDisplayName())){
|
||||
if(StringUtil.equalsToLowerCase(entry.getKey(), event.entityPlayer.getCommandSenderName())){
|
||||
//Render the special Item/Block
|
||||
entry.getValue().render(event.entityPlayer);
|
||||
break;
|
||||
|
|
|
@ -24,6 +24,8 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PacketBookletStandButton implements IMessage{
|
||||
|
||||
private int tileX;
|
||||
|
@ -92,7 +94,7 @@ public class PacketBookletStandButton implements IMessage{
|
|||
EntityPlayer player = (EntityPlayer)world.getEntityByID(message.playerID);
|
||||
|
||||
if(tile instanceof TileEntityBookletStand){
|
||||
if(player.getUniqueID().equals(((TileEntityBookletStand)tile).assignedPlayerUUID)){
|
||||
if(Objects.equals(player.getCommandSenderName(), ((TileEntityBookletStand)tile).assignedPlayer)){
|
||||
((TileEntityBookletStand)tile).setEntry(message.entryID, message.chapterID, message.pageID, message.pageInIndex);
|
||||
world.markBlockForUpdate(message.tileX, message.tileY, message.tileZ);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@ import ellpeck.actuallyadditions.booklet.entry.BookletEntry;
|
|||
import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TileEntityBookletStand extends TileEntityBase{
|
||||
|
||||
public BookletChapter assignedChapter;
|
||||
|
@ -25,7 +23,7 @@ public class TileEntityBookletStand extends TileEntityBase{
|
|||
public BookletEntry assignedEntry;
|
||||
public int assignedPageInIndex;
|
||||
|
||||
public UUID assignedPlayerUUID;
|
||||
public String assignedPlayer;
|
||||
|
||||
@Override
|
||||
public boolean canUpdate(){
|
||||
|
@ -39,9 +37,8 @@ public class TileEntityBookletStand extends TileEntityBase{
|
|||
compound.setInteger("Page", this.assignedPage == null ? -1 : this.assignedPage.getID());
|
||||
compound.setInteger("PageInIndex", this.assignedPageInIndex);
|
||||
|
||||
if(this.assignedPlayerUUID != null){
|
||||
compound.setLong("PlayerLeastSignificant", this.assignedPlayerUUID.getLeastSignificantBits());
|
||||
compound.setLong("PlayerMostSignificant", this.assignedPlayerUUID.getMostSignificantBits());
|
||||
if(this.assignedPlayer != null){
|
||||
compound.setString("Player", this.assignedPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,9 +46,9 @@ public class TileEntityBookletStand extends TileEntityBase{
|
|||
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||
this.setEntry(compound.getInteger("Entry"), compound.getInteger("Chapter"), compound.getInteger("Page"), compound.getInteger("PageInIndex"));
|
||||
|
||||
long mostSigBits = compound.getLong("PlayerMostSignificant");
|
||||
if(mostSigBits > 0){
|
||||
this.assignedPlayerUUID = new UUID(mostSigBits, compound.getLong("PlayerLeastSignificant"));
|
||||
String player = compound.getString("Player");
|
||||
if(player != null){
|
||||
this.assignedPlayer = player;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue