From 56489b362a47bf519a7ed0bfd41494b1c051ef52 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 1 Feb 2016 20:39:11 +0100 Subject: [PATCH] There we go. I fixed it. --- .../api/internal/EntrySet.java | 14 ++-- .../mod/blocks/base/BlockPlant.java | 5 +- .../mod/event/PlayerObtainEvents.java | 26 +++--- .../mod/inventory/gui/GuiGrinder.java | 1 + .../mod/items/ItemCoffee.java | 18 ++--- .../mod/items/ItemPhantomConnector.java | 80 +++++++++---------- .../mod/proxy/ClientProxy.java | 40 +++++----- .../mod/recipe/FuelHandler.java | 10 +-- .../mod/tile/TileEntityGrinder.java | 8 +- .../mod/tile/TileEntityInventoryBase.java | 5 +- .../mod/tile/TileEntityItemRepairer.java | 8 +- .../mod/tile/TileEntityPhantomface.java | 28 +++---- .../actuallyadditions/mod/util/ModUtil.java | 1 + 13 files changed, 124 insertions(+), 120 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/EntrySet.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/EntrySet.java index f3b91b773..fb67d6e6f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/EntrySet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/internal/EntrySet.java @@ -31,13 +31,6 @@ public class EntrySet{ this.setEntry(page, chapter, entry, pageInIndex); } - public void setEntry(BookletPage page, IBookletChapter chapter, IBookletEntry entry, int pageInIndex){ - this.page = page; - this.chapter = chapter; - this.entry = entry; - this.pageInIndex = pageInIndex; - } - public static EntrySet readFromNBT(NBTTagCompound compound){ if(compound != null){ if(compound.hasKey("Entry")){ @@ -56,6 +49,13 @@ public class EntrySet{ return new EntrySet(null); } + public void setEntry(BookletPage page, IBookletChapter chapter, IBookletEntry entry, int pageInIndex){ + this.page = page; + this.chapter = chapter; + this.entry = entry; + this.pageInIndex = pageInIndex; + } + public void removeEntry(){ this.setEntry(null, null, null, 1); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java index 105bc1bdc..665a8baa6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java @@ -121,7 +121,9 @@ public class BlockPlant extends BlockCrops{ @Override public int getDamageValue(World world, BlockPos pos){ return 0; - } @Override + } + + @Override public Item getSeed(){ return this.seedItem; } @@ -137,7 +139,6 @@ public class BlockPlant extends BlockCrops{ } - @Override public Item getItemDropped(IBlockState state, Random rand, int par3){ return this.getMetaFromState(state) >= 7 ? this.getCrop() : this.getSeed(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/PlayerObtainEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/PlayerObtainEvents.java index 1ca2eefd8..d8f009d22 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/PlayerObtainEvents.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/PlayerObtainEvents.java @@ -28,6 +28,19 @@ import java.util.Locale; public class PlayerObtainEvents{ + public static void checkAchievements(ItemStack gotten, EntityPlayer player, InitAchievements.Type type){ + for(int i = 0; i < TheAchievements.values().length; i++){ + TheAchievements ach = TheAchievements.values()[i]; + if(ach.type == type){ + if(gotten != null && ach.ach.theItemStack != null && gotten.getItem() == ach.ach.theItemStack.getItem()){ + if(gotten.getItemDamage() == ach.ach.theItemStack.getItemDamage()){ + player.addStat(ach.ach, 1); + } + } + } + } + } + @SubscribeEvent public void onCraftedEvent(PlayerEvent.ItemCraftedEvent event){ checkAchievements(event.crafting, event.player, InitAchievements.Type.CRAFTING); @@ -51,19 +64,6 @@ public class PlayerObtainEvents{ } } - public static void checkAchievements(ItemStack gotten, EntityPlayer player, InitAchievements.Type type){ - for(int i = 0; i < TheAchievements.values().length; i++){ - TheAchievements ach = TheAchievements.values()[i]; - if(ach.type == type){ - if(gotten != null && ach.ach.theItemStack != null && gotten.getItem() == ach.ach.theItemStack.getItem()){ - if(gotten.getItemDamage() == ach.ach.theItemStack.getItemDamage()){ - player.addStat(ach.ach, 1); - } - } - } - } - } - @SubscribeEvent public void onSmeltedEvent(PlayerEvent.ItemSmeltedEvent event){ checkAchievements(event.smelting, event.player, InitAchievements.Type.SMELTING); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGrinder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGrinder.java index e6436a084..db7c2e000 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGrinder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGrinder.java @@ -84,6 +84,7 @@ public class GuiGrinder extends GuiContainer{ } public static class GuiGrinderDouble extends GuiGrinder{ + public GuiGrinderDouble(InventoryPlayer inventory, TileEntityBase tile){ super(inventory, tile, true); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java index 58400ae70..492f9f6d1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java @@ -72,6 +72,15 @@ public class ItemCoffee extends ItemFoodBase{ return null; } + public static void applyPotionEffectsFromStack(ItemStack stack, EntityPlayer player){ + PotionEffect[] effects = CoffeeBrewing.getEffectsFromStack(stack); + if(effects != null && effects.length > 0){ + for(PotionEffect effect : effects){ + player.addPotionEffect(new PotionEffect(effect.getPotionID(), effect.getDuration()*20, effect.getAmplifier())); + } + } + } + @Override public ItemStack onItemUseFinish(ItemStack stack, World world, EntityPlayer player){ ItemStack theStack = stack.copy(); @@ -86,15 +95,6 @@ public class ItemCoffee extends ItemFoodBase{ } } - public static void applyPotionEffectsFromStack(ItemStack stack, EntityPlayer player){ - PotionEffect[] effects = CoffeeBrewing.getEffectsFromStack(stack); - if(effects != null && effects.length > 0){ - for(PotionEffect effect : effects){ - player.addPotionEffect(new PotionEffect(effect.getPotionID(), effect.getDuration()*20, effect.getAmplifier())); - } - } - } - @Override public EnumAction getItemUseAction(ItemStack stack){ return EnumAction.DRINK; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java index e8bb77c13..6ae2a195e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java @@ -39,46 +39,6 @@ public class ItemPhantomConnector extends ItemBase{ this.setMaxStackSize(1); } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing par7, float par8, float par9, float par10){ - if(!world.isRemote){ - //Passing Data to Phantoms - TileEntity tile = world.getTileEntity(pos); - if(tile != null){ - //Passing to Phantom - if(tile instanceof IPhantomTile){ - if(this.checkHasConnection(stack, player, tile) && getStoredWorld(stack) == world){ - ((IPhantomTile)tile).setBoundPosition(getStoredPosition(stack)); - if(tile instanceof TileEntityBase){ - ((TileEntityBase)tile).sendUpdate(); - } - clearStorage(stack); - player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc"))); - return true; - } - return false; - } - } - //Storing Connections - storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world); - player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.stored.desc"))); - } - return true; - } - - public boolean checkHasConnection(ItemStack stack, EntityPlayer player, TileEntity tile){ - if(getStoredPosition(stack) != null){ - return true; - } - else{ - if(tile instanceof IPhantomTile){ - ((IPhantomTile)tile).setBoundPosition(null); - } - player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.unbound.desc"))); - return false; - } - } - public static World getStoredWorld(ItemStack stack){ NBTTagCompound tag = stack.getTagCompound(); if(tag != null){ @@ -118,6 +78,46 @@ public class ItemPhantomConnector extends ItemBase{ stack.setTagCompound(tag); } + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing par7, float par8, float par9, float par10){ + if(!world.isRemote){ + //Passing Data to Phantoms + TileEntity tile = world.getTileEntity(pos); + if(tile != null){ + //Passing to Phantom + if(tile instanceof IPhantomTile){ + if(this.checkHasConnection(stack, player, tile) && getStoredWorld(stack) == world){ + ((IPhantomTile)tile).setBoundPosition(getStoredPosition(stack)); + if(tile instanceof TileEntityBase){ + ((TileEntityBase)tile).sendUpdate(); + } + clearStorage(stack); + player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc"))); + return true; + } + return false; + } + } + //Storing Connections + storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world); + player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.stored.desc"))); + } + return true; + } + + public boolean checkHasConnection(ItemStack stack, EntityPlayer player, TileEntity tile){ + if(getStoredPosition(stack) != null){ + return true; + } + else{ + if(tile instanceof IPhantomTile){ + ((IPhantomTile)tile).setBoundPosition(null); + } + player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.unbound.desc"))); + return false; + } + } + @Override public boolean getShareTag(){ return true; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java index 2c7e01d30..a33b7322e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java @@ -54,6 +54,26 @@ public class ClientProxy implements IProxy{ private static Map modelLocationsForRegistering = new HashMap(); private static Map modelVariantsForRegistering = new HashMap(); + private static void countBookletWords(){ + bookletWordCount = 0; + bookletCharCount = 0; + + for(IBookletEntry entry : ActuallyAdditionsAPI.bookletEntries){ + for(IBookletChapter chapter : entry.getChapters()){ + for(BookletPage page : chapter.getPages()){ + if(page.getText() != null){ + bookletWordCount += page.getText().split(" ").length; + bookletCharCount += page.getText().length(); + } + } + bookletWordCount += chapter.getLocalizedName().split(" ").length; + bookletCharCount += chapter.getLocalizedName().length(); + } + bookletWordCount += entry.getLocalizedName().split(" ").length; + bookletCharCount += entry.getLocalizedName().length(); + } + } + @Override public void preInit(FMLPreInitializationEvent event){ ModUtil.LOGGER.info("PreInitializing ClientProxy..."); @@ -99,26 +119,6 @@ public class ClientProxy implements IProxy{ ModelLoader.setCustomStateMapper(block, mapper); } - private static void countBookletWords(){ - bookletWordCount = 0; - bookletCharCount = 0; - - for(IBookletEntry entry : ActuallyAdditionsAPI.bookletEntries){ - for(IBookletChapter chapter : entry.getChapters()){ - for(BookletPage page : chapter.getPages()){ - if(page.getText() != null){ - bookletWordCount += page.getText().split(" ").length; - bookletCharCount += page.getText().length(); - } - } - bookletWordCount += chapter.getLocalizedName().split(" ").length; - bookletCharCount += chapter.getLocalizedName().length(); - } - bookletWordCount += entry.getLocalizedName().split(" ").length; - bookletCharCount += entry.getLocalizedName().length(); - } - } - @Override public void init(FMLInitializationEvent event){ ModUtil.LOGGER.info("Initializing ClientProxy..."); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/FuelHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/FuelHandler.java index dd8cdb85a..080f057f9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/FuelHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/FuelHandler.java @@ -50,11 +50,6 @@ public class FuelHandler implements IFuelHandler{ addFuel(Item.getItemFromBlock(block), metadata, value); } - @Override - public int getBurnTime(ItemStack fuel){ - return getFuelValue(fuel); - } - private static int getFuelValue(ItemStack stack){ if(stack != null && stack.getItem() != null){ Pair pair = Pair.of(stack.getItem(), stack.getItemDamage()); @@ -71,4 +66,9 @@ public class FuelHandler implements IFuelHandler{ } return 0; } + + @Override + public int getBurnTime(ItemStack fuel){ + return getFuelValue(fuel); + } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java index f55b00d5e..90d944eeb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java @@ -51,6 +51,10 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg this.isDouble = false; } + public static int getEnergyUse(boolean isDouble){ + return isDouble ? 60 : 40; + } + @Override public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){ return this.storage.receiveEnergy(maxReceive, simulate); @@ -193,10 +197,6 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg return false; } - public static int getEnergyUse(boolean isDouble){ - return isDouble ? 60 : 40; - } - private int getMaxCrushTime(){ return this.isDouble ? 150 : 100; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java index 588f4a1c6..8af8f3240 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java @@ -110,7 +110,9 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements @Override public boolean hasCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.util.EnumFacing facing){ return this.getCapability(capability, facing) != null; - } @Override + } + + @Override public int getInventoryStackLimit(){ return 64; } @@ -131,7 +133,6 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements } - @Override public void openInventory(EntityPlayer player){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java index 209f091c4..b0abbbe7f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java @@ -31,6 +31,10 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I super(2, "repairer"); } + public static boolean canBeRepaired(ItemStack stack){ + return stack != null && stack.getItem().isRepairable(); + } + @Override public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ compound.setInteger("NextRepairTick", this.nextRepairTick); @@ -82,10 +86,6 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I return i == SLOT_INPUT; } - public static boolean canBeRepaired(ItemStack stack){ - return stack != null && stack.getItem().isRepairable(); - } - @SideOnly(Side.CLIENT) public int getEnergyScaled(int i){ return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java index fa9dee768..5950f7ab0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java @@ -48,6 +48,20 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP this.capabilities = ForgeEventFactory.gatherCapabilities(this); } + public static int upgradeRange(int defaultRange, World world, BlockPos pos){ + int newRange = defaultRange; + for(int i = 0; i < 3; i++){ + Block block = PosUtil.getBlock(PosUtil.offset(pos, 0, 1+i, 0), world); + if(block == InitBlocks.blockPhantomBooster){ + newRange = newRange*2; + } + else{ + break; + } + } + return newRange; + } + @Override public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ super.writeSyncableNBT(compound, sync); @@ -114,20 +128,6 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP return false; } - public static int upgradeRange(int defaultRange, World world, BlockPos pos){ - int newRange = defaultRange; - for(int i = 0; i < 3; i++){ - Block block = PosUtil.getBlock(PosUtil.offset(pos, 0, 1+i, 0), world); - if(block == InitBlocks.blockPhantomBooster){ - newRange = newRange*2; - } - else{ - break; - } - } - return newRange; - } - @Override public boolean hasBoundPosition(){ if(this.boundPosition != null){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ModUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ModUtil.java index ddc3cce50..0f052f5e3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ModUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ModUtil.java @@ -17,6 +17,7 @@ import org.apache.logging.log4j.Logger; import java.util.Locale; public class ModUtil{ + public static final String VERSION = "@VERSION@"; //build.gradle public static final String MOD_ID = ActuallyAdditionsAPI.MOD_ID;