diff --git a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java index 2a44e6792..0572a3cb1 100644 --- a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java +++ b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java @@ -29,6 +29,7 @@ import ellpeck.actuallyadditions.inventory.GuiHandler; import ellpeck.actuallyadditions.items.InitForeignPaxels; import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.ItemCoffee; +import ellpeck.actuallyadditions.items.tools.table.InitToolTableTools; import ellpeck.actuallyadditions.material.InitArmorMaterials; import ellpeck.actuallyadditions.material.InitToolMaterials; import ellpeck.actuallyadditions.misc.DispenserHandlerEmptyBucket; @@ -98,7 +99,7 @@ public class ActuallyAdditions{ HairyBallHandler.init(); TreasureChestHandler.init(); InitForeignPaxels.init(); - //InitToolTableTools.init(); + InitToolTableTools.init(); proxy.postInit(event); ModUtil.LOGGER.info("PostInitialization Finished."); diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java b/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java index 792ba28d1..957ad26d2 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java @@ -93,13 +93,13 @@ public class InitBlocks{ public static Block blockSmileyCloud; - //public static Block blockToolTable; + public static Block blockToolTable; public static void init(){ ModUtil.LOGGER.info("Initializing Blocks..."); - //blockToolTable = new BlockToolTable(); - //BlockUtil.register(blockToolTable); + blockToolTable = new BlockToolTable(); + BlockUtil.register(blockToolTable); blockSmileyCloud = new BlockSmileyCloud(); BlockUtil.register(blockSmileyCloud); diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java index 0458c3dfe..8c68ae328 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java @@ -15,7 +15,11 @@ import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.booklet.page.BookletPage; import ellpeck.actuallyadditions.config.GuiConfiguration; import ellpeck.actuallyadditions.update.UpdateChecker; -import ellpeck.actuallyadditions.util.*; +import ellpeck.actuallyadditions.util.AssetUtil; +import ellpeck.actuallyadditions.util.KeyUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import ellpeck.actuallyadditions.util.playerdata.PersistantClientData; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; @@ -123,7 +127,7 @@ public class GuiBooklet extends GuiScreen{ @Override public void onGuiClosed(){ - PersistantVariables.saveBookPage(this.currentIndexEntry, this.currentChapter, this.currentPage, this.pageOpenInIndex); + PersistantClientData.saveBookPage(this.currentIndexEntry, this.currentChapter, this.currentPage, this.pageOpenInIndex); } @Override @@ -167,14 +171,14 @@ public class GuiBooklet extends GuiScreen{ this.currentChapter = null; this.currentIndexEntry = null; - if(!PersistantVariables.getBoolean("BookAlreadyOpened")){ + if(!PersistantClientData.getBoolean("BookAlreadyOpened")){ this.openIndexEntry(InitBooklet.chapterIntro.entry, 1, true); this.openChapter(InitBooklet.chapterIntro, null); - PersistantVariables.setBoolean("BookAlreadyOpened", true); + PersistantClientData.setBoolean("BookAlreadyOpened", true); } else{ - PersistantVariables.openLastBookPage(this); + PersistantClientData.openLastBookPage(this); } } diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java index 03ea9f2dc..1ba624edc 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java @@ -29,8 +29,6 @@ public enum ConfigBoolValues{ PEARL_SHARD_DROP("Ender Pearl Shard", ConfigCategories.MOB_DROPS, true, "If the Ender Pearl Shard drops from Mobs"), EMERALD_SHARD_CROP("Emerald Shard", ConfigCategories.MOB_DROPS, true, "If the Emerald Shard drops from Mobs"), - DO_WAILA_INFO("Waila Display Info", ConfigCategories.OTHER, true, "If the Shift Description should display in Waila too"), - DO_UPDATE_CHECK("Do Update Check", ConfigCategories.OTHER, true, "If Actually Additions should check for an Update on joining a World"), DO_CRUSHER_SPAM("Crusher Debug", ConfigCategories.OTHER, false, "Print out Crusher Recipe Initializing Debug"), DO_CAT_DROPS("Do Cat Drops", ConfigCategories.OTHER, true, "If Cats drop Hairy Balls on Occasion"), @@ -58,7 +56,7 @@ public enum ConfigBoolValues{ NEED_BOOKLET_FOR_KEYBIND_INFO("Booklet Quick Opening", ConfigCategories.TOOL_VALUES, true, "If the booklet should have to be inside the player's inventory to be able to hover over an item and press a keybind to quickly access the item's page"), SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO("Booklet Quick Opening Info", ConfigCategories.TOOL_VALUES, true, "If the 'Press key for more information'-button should show when the item has a page in the booklet"), - GIVE_BOOKLET_ON_FIRST_CRAFT("Give Booklet on First Craft", ConfigCategories.OTHER, true, "If the booklet should be given to the player when he first crafts something from the Mod (Reduces Packet Traffic a bit when turned off!)"); + GIVE_BOOKLET_ON_FIRST_CRAFT("Give Booklet on First Craft", ConfigCategories.OTHER, true, "If the booklet should be given to the player when he first crafts something from the Mod"); public final String name; public final String category; diff --git a/src/main/java/ellpeck/actuallyadditions/event/CraftEvent.java b/src/main/java/ellpeck/actuallyadditions/event/CraftEvent.java index 59eff7985..4aa1a1f1c 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/CraftEvent.java +++ b/src/main/java/ellpeck/actuallyadditions/event/CraftEvent.java @@ -16,12 +16,11 @@ import ellpeck.actuallyadditions.achievement.InitAchievements; import ellpeck.actuallyadditions.achievement.TheAchievements; import ellpeck.actuallyadditions.config.values.ConfigBoolValues; import ellpeck.actuallyadditions.items.InitItems; -import ellpeck.actuallyadditions.network.PacketCheckBook; -import ellpeck.actuallyadditions.network.PacketHandler; import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.playerdata.PersistantServerData; import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; public class CraftEvent{ @@ -32,8 +31,13 @@ public class CraftEvent{ if(ConfigBoolValues.GIVE_BOOKLET_ON_FIRST_CRAFT.isEnabled()){ if(!event.player.worldObj.isRemote && event.crafting.getItem() != InitItems.itemLexicon && (event.crafting.getItem() instanceof INameableItem || Block.getBlockFromItem(event.crafting.getItem()) instanceof INameableItem)){ - if(event.player instanceof EntityPlayerMP){ - PacketHandler.theNetwork.sendTo(new PacketCheckBook(event.player), (EntityPlayerMP)event.player); + PersistantServerData data = PersistantServerData.get(event.player); + if(!data.bookGottenAlready){ + data.bookGottenAlready = true; + + EntityItem entityItem = new EntityItem(event.player.worldObj, event.player.posX, event.player.posY, event.player.posZ, new ItemStack(InitItems.itemLexicon)); + entityItem.delayBeforeCanPickup = 0; + event.player.worldObj.spawnEntityInWorld(entityItem); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/event/EntityConstructingEvent.java b/src/main/java/ellpeck/actuallyadditions/event/EntityConstructingEvent.java new file mode 100644 index 000000000..53960ee18 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/event/EntityConstructingEvent.java @@ -0,0 +1,29 @@ +/* + * This file ("EntityConstructingEvent.java") is part of the Actually Additions Mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.event; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.playerdata.PersistantServerData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.event.entity.EntityEvent; + +public class EntityConstructingEvent{ + + @SubscribeEvent + public void onEntityConstructing(EntityEvent.EntityConstructing event){ + if(event.entity instanceof EntityPlayer){ + if(PersistantServerData.get((EntityPlayer)event.entity) == null){ + event.entity.registerExtendedProperties(ModUtil.MOD_ID, new PersistantServerData()); + } + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java b/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java index 31103d356..798ab82dd 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java +++ b/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java @@ -26,6 +26,7 @@ public class InitEvents{ Util.registerEvent(new EntityLivingEvent()); Util.registerEvent(new BucketFillEvent()); Util.registerEvent(new LogoutEvent()); + Util.registerEvent(new EntityConstructingEvent()); MinecraftForge.TERRAIN_GEN_BUS.register(new WorldDecorationEvent()); } diff --git a/src/main/java/ellpeck/actuallyadditions/network/PacketCheckBook.java b/src/main/java/ellpeck/actuallyadditions/network/PacketCheckBook.java deleted file mode 100644 index 12009aa17..000000000 --- a/src/main/java/ellpeck/actuallyadditions/network/PacketCheckBook.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file ("PacketCheckBook.java") is part of the Actually Additions Mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015 Ellpeck - */ - -package ellpeck.actuallyadditions.network; - -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import ellpeck.actuallyadditions.util.PersistantVariables; -import io.netty.buffer.ByteBuf; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; - -public class PacketCheckBook implements IMessage{ - - @SuppressWarnings("unused") - public PacketCheckBook(){ - - } - - private EntityPlayer player; - - public PacketCheckBook(EntityPlayer player){ - this.player = player; - } - - @Override - public void fromBytes(ByteBuf buf){ - this.player = (EntityPlayer)Minecraft.getMinecraft().theWorld.getEntityByID(buf.readInt()); - } - - @Override - public void toBytes(ByteBuf buf){ - buf.writeInt(this.player.getEntityId()); - } - - public static class Handler implements IMessageHandler{ - - @Override - @SideOnly(Side.CLIENT) - public IMessage onMessage(PacketCheckBook message, MessageContext ctx){ - if(!PersistantVariables.getBoolean("BookGotten")){ - PacketHandler.theNetwork.sendToServer(new PacketGiveBook(message.player)); - PersistantVariables.setBoolean("BookGotten", true); - } - return null; - } - } -} diff --git a/src/main/java/ellpeck/actuallyadditions/network/PacketGiveBook.java b/src/main/java/ellpeck/actuallyadditions/network/PacketGiveBook.java deleted file mode 100644 index 315a206b7..000000000 --- a/src/main/java/ellpeck/actuallyadditions/network/PacketGiveBook.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file ("PacketGiveBook.java") is part of the Actually Additions Mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015 Ellpeck - */ - -package ellpeck.actuallyadditions.network; - -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import ellpeck.actuallyadditions.items.InitItems; -import io.netty.buffer.ByteBuf; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.common.DimensionManager; - -public class PacketGiveBook implements IMessage{ - - @SuppressWarnings("unused") - public PacketGiveBook(){ - - } - - private EntityPlayer player; - - public PacketGiveBook(EntityPlayer player){ - this.player = player; - } - - @Override - public void fromBytes(ByteBuf buf){ - World world = DimensionManager.getWorld(buf.readInt()); - this.player = (EntityPlayer)world.getEntityByID(buf.readInt()); - } - - @Override - public void toBytes(ByteBuf buf){ - buf.writeInt(this.player.worldObj.provider.dimensionId); - buf.writeInt(this.player.getEntityId()); - } - - public static class Handler implements IMessageHandler{ - - @Override - public IMessage onMessage(PacketGiveBook message, MessageContext ctx){ - EntityItem entityItem = new EntityItem(message.player.worldObj, message.player.posX, message.player.posY, message.player.posZ, new ItemStack(InitItems.itemLexicon)); - entityItem.delayBeforeCanPickup = 0; - message.player.worldObj.spawnEntityInWorld(entityItem); - - return null; - } - } -} diff --git a/src/main/java/ellpeck/actuallyadditions/network/PacketHandler.java b/src/main/java/ellpeck/actuallyadditions/network/PacketHandler.java index 208c5085a..ed03d2d3e 100644 --- a/src/main/java/ellpeck/actuallyadditions/network/PacketHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/network/PacketHandler.java @@ -30,7 +30,5 @@ public class PacketHandler{ theNetwork.registerMessage(PacketSyncerToClient.Handler.class, PacketSyncerToClient.class, 1, Side.CLIENT); theNetwork.registerMessage(PacketGuiNumber.Handler.class, PacketGuiNumber.class, 2, Side.SERVER); theNetwork.registerMessage(PacketGuiString.Handler.class, PacketGuiString.class, 3, Side.SERVER); - theNetwork.registerMessage(PacketGiveBook.Handler.class, PacketGiveBook.class, 4, Side.SERVER); - theNetwork.registerMessage(PacketCheckBook.Handler.class, PacketCheckBook.class, 5, Side.CLIENT); } } diff --git a/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java b/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java index 1a05eb1c4..35a57e2ae 100644 --- a/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java +++ b/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java @@ -25,7 +25,11 @@ import ellpeck.actuallyadditions.event.RenderPlayerEventAA; import ellpeck.actuallyadditions.event.TooltipEvent; import ellpeck.actuallyadditions.tile.*; import ellpeck.actuallyadditions.update.UpdateCheckerClientNotifier; -import ellpeck.actuallyadditions.util.*; +import ellpeck.actuallyadditions.util.AssetUtil; +import ellpeck.actuallyadditions.util.KeyBinds; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.Util; +import ellpeck.actuallyadditions.util.playerdata.PersistantClientData; import net.minecraft.client.Minecraft; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; @@ -40,7 +44,7 @@ public class ClientProxy implements IProxy{ public void preInit(FMLPreInitializationEvent event){ ModUtil.LOGGER.info("PreInitializing ClientProxy..."); - PersistantVariables.setTheFile(new File(Minecraft.getMinecraft().mcDataDir, ModUtil.MOD_ID+"Data.dat")); + PersistantClientData.setTheFile(new File(Minecraft.getMinecraft().mcDataDir, ModUtil.MOD_ID+"Data.dat")); KeyBinds.init(); } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java index 3db725d77..fc1ebaa94 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java @@ -71,7 +71,7 @@ public class TileEntityBase extends TileEntity{ GameRegistry.registerTileEntity(TileEntityXPSolidifier.class, ModUtil.MOD_ID_LOWER+":tileEntityXPSolidifier"); GameRegistry.registerTileEntity(TileEntityOreMagnet.class, ModUtil.MOD_ID_LOWER+":tileEntityOreMagnet"); GameRegistry.registerTileEntity(TileEntitySmileyCloud.class, ModUtil.MOD_ID_LOWER+":tileEntityCloud"); - //GameRegistry.registerTileEntity(TileEntityToolTable.class, ModUtil.MOD_ID_LOWER+":tileEntityToolTable"); + GameRegistry.registerTileEntity(TileEntityToolTable.class, ModUtil.MOD_ID_LOWER+":tileEntityToolTable"); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/util/PersistantVariables.java b/src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistantClientData.java similarity index 97% rename from src/main/java/ellpeck/actuallyadditions/util/PersistantVariables.java rename to src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistantClientData.java index 9ac87796e..eddfb75d2 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/PersistantVariables.java +++ b/src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistantClientData.java @@ -8,7 +8,7 @@ * © 2015 Ellpeck */ -package ellpeck.actuallyadditions.util; +package ellpeck.actuallyadditions.util.playerdata; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -17,6 +17,7 @@ import ellpeck.actuallyadditions.booklet.BookletIndexEntry; import ellpeck.actuallyadditions.booklet.GuiBooklet; import ellpeck.actuallyadditions.booklet.InitBooklet; import ellpeck.actuallyadditions.booklet.page.BookletPage; +import ellpeck.actuallyadditions.util.ModUtil; import net.minecraft.client.Minecraft; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; @@ -26,7 +27,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; @SideOnly(Side.CLIENT) -public class PersistantVariables{ +public class PersistantClientData{ private static File theFile; diff --git a/src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistantServerData.java b/src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistantServerData.java new file mode 100644 index 000000000..420dd0d39 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistantServerData.java @@ -0,0 +1,52 @@ +/* + * This file ("PersistantServerPlayerData.java") is part of the Actually Additions Mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.util.playerdata; + +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.IExtendedEntityProperties; + +public class PersistantServerData implements IExtendedEntityProperties{ + + public boolean bookGottenAlready; + + @Override + public void saveNBTData(NBTTagCompound aComp){ + NBTTagCompound compound = new NBTTagCompound(); + + compound.setBoolean("BookGotten", bookGottenAlready); + + aComp.setTag(ModUtil.MOD_ID, compound); + } + + @Override + public void loadNBTData(NBTTagCompound aComp){ + NBTBase base = aComp.getTag(ModUtil.MOD_ID); + if(base != null && base instanceof NBTTagCompound){ + NBTTagCompound compound = (NBTTagCompound)base; + + this.bookGottenAlready = compound.getBoolean("BookGotten"); + } + } + + @Override + public void init(Entity entity, World world){ + + } + + public static PersistantServerData get(EntityPlayer player){ + return (PersistantServerData)player.getExtendedProperties(ModUtil.MOD_ID); + } +}