diff --git a/lang b/lang index d39f07201..080830fa7 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit d39f07201c8e8f249f4af27504b7f803e93d3359 +Subproject commit 080830fa73f563683c1dc7c266ac9d9a422b2bf7 diff --git a/src/main/java/forestry/Forestry.java b/src/main/java/forestry/Forestry.java index 16283f25c..8a886601b 100644 --- a/src/main/java/forestry/Forestry.java +++ b/src/main/java/forestry/Forestry.java @@ -90,6 +90,7 @@ public class Forestry { MinecraftForge.EVENT_BUS.register(eventHandlerCore); MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler()); MinecraftForge.EVENT_BUS.register(new ClimateEventHandler()); + Proxies.common.registerEventHandlers(); configFolder = new File(event.getModConfigurationDirectory(), Constants.MOD_ID); Config.load(); diff --git a/src/main/java/forestry/apiculture/blocks/BlockAlveary.java b/src/main/java/forestry/apiculture/blocks/BlockAlveary.java index 1be8b906e..68a9ede4c 100644 --- a/src/main/java/forestry/apiculture/blocks/BlockAlveary.java +++ b/src/main/java/forestry/apiculture/blocks/BlockAlveary.java @@ -35,6 +35,7 @@ import forestry.core.proxy.Proxies; import forestry.core.tiles.IActivatable; import forestry.core.tiles.TileUtil; import forestry.core.utils.BlockUtil; +import forestry.core.utils.Translator; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.properties.PropertyEnum; @@ -42,7 +43,9 @@ import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.statemap.StateMapperBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; @@ -255,4 +258,10 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe Proxies.net.sendNetworkPacket(new PacketAlvearyChange(referenceCoord), referenceCoord, worldIn); } } + + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { + tooltip.add(Translator.translateToLocal("tile.for.alveary.tooltip")); + } } diff --git a/src/main/java/forestry/core/multiblock/MultiblockEventHandler.java b/src/main/java/forestry/core/multiblock/MultiblockEventHandler.java index bd00c3a68..a6142b507 100644 --- a/src/main/java/forestry/core/multiblock/MultiblockEventHandler.java +++ b/src/main/java/forestry/core/multiblock/MultiblockEventHandler.java @@ -1,22 +1,9 @@ package forestry.core.multiblock; -import java.util.Set; - -import forestry.api.multiblock.IMultiblockController; -import forestry.core.utils.Log; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderGlobal; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.WorldEvent; -import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; /** @@ -26,7 +13,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; * process any blocks that are in chunks which are still loading. */ public class MultiblockEventHandler { - @SubscribeEvent(priority = EventPriority.NORMAL) + @SubscribeEvent public void onChunkLoad(ChunkEvent.Load loadEvent) { Chunk chunk = loadEvent.getChunk(); World world = loadEvent.getWorld(); @@ -34,49 +21,8 @@ public class MultiblockEventHandler { } // Cleanup, for nice memory usageness - @SubscribeEvent(priority = EventPriority.NORMAL) + @SubscribeEvent public void onWorldUnload(WorldEvent.Unload unloadWorldEvent) { MultiblockRegistry.onWorldUnloaded(unloadWorldEvent.getWorld()); } - - @SubscribeEvent - public void onWorldRenderLast(RenderWorldLastEvent event){ - try{ - World world = Minecraft.getMinecraft().world; - Set controllers = MultiblockRegistry.getControllersFromWorld(world); - if(!controllers.isEmpty()){ - float partialTicks = event.getPartialTicks(); - EntityPlayer player = Minecraft.getMinecraft().player; - double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks; - double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks; - double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks; - - GlStateManager.pushMatrix(); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); - GlStateManager.disableTexture2D(); - GlStateManager.glLineWidth(2.0F); - GlStateManager.depthMask(false); - for(IMultiblockController controller : controllers){ - if(controller != null){ - BlockPos lastErrorPosition = controller.getLastValidationErrorPosition(); - if(lastErrorPosition != null){ - if(world.isBlockLoaded(lastErrorPosition) && player.getDistanceSq(lastErrorPosition) < 64F){ - AxisAlignedBB box = Block.FULL_BLOCK_AABB.offset(lastErrorPosition.getX() - playerX, lastErrorPosition.getY() - playerY, lastErrorPosition.getZ() - playerZ); - RenderGlobal.drawSelectionBoundingBox(box, 1.0F, 0.0F, 0.0F, 0.25F); - RenderGlobal.renderFilledBox(box, 1.0F, 0.0F, 0.0F, 0.125F); - } - } - } - } - - GlStateManager.depthMask(true); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - GlStateManager.popMatrix(); - } - }catch(Exception e){ - Log.error("Failed to render the position of a multiblock exeption.", e); - } - } } diff --git a/src/main/java/forestry/core/multiblock/MultiblockEventHandlerClient.java b/src/main/java/forestry/core/multiblock/MultiblockEventHandlerClient.java new file mode 100644 index 000000000..c88b73b47 --- /dev/null +++ b/src/main/java/forestry/core/multiblock/MultiblockEventHandlerClient.java @@ -0,0 +1,93 @@ +package forestry.core.multiblock; + +import java.util.Set; + +import forestry.api.multiblock.IMultiblockComponent; +import forestry.api.multiblock.IMultiblockController; +import forestry.core.utils.Log; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.World; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class MultiblockEventHandlerClient { + + @SubscribeEvent + public void onGameOverlay(RenderGameOverlayEvent.Post event){ + if(event.getType() == RenderGameOverlayEvent.ElementType.ALL && Minecraft.getMinecraft().currentScreen == null){ + Minecraft minecraft = Minecraft.getMinecraft(); + RayTraceResult posHit = minecraft.objectMouseOver; + FontRenderer font = minecraft.fontRendererObj; + ScaledResolution resolution = event.getResolution(); + + if(posHit != null && posHit.getBlockPos() != null){ + TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos()); + if(tile instanceof IMultiblockComponent){ + IMultiblockComponent component = (IMultiblockComponent) tile; + IMultiblockController controller = component.getMultiblockLogic().getController(); + String lastValidationError = controller.getLastValidationError(); + if(lastValidationError != null){ + lastValidationError = TextFormatting.DARK_RED.toString() + TextFormatting.ITALIC.toString() + lastValidationError; + minecraft.fontRendererObj.drawSplitString(lastValidationError, resolution.getScaledWidth() / 2 + 35, resolution.getScaledHeight() / 2 - 25, 128, 16777215); + } + } + } + } + } + + @SubscribeEvent + public void onWorldRenderLast(RenderWorldLastEvent event){ + try{ + World world = Minecraft.getMinecraft().world; + Set controllers = MultiblockRegistry.getControllersFromWorld(world); + if(!controllers.isEmpty()){ + float partialTicks = event.getPartialTicks(); + EntityPlayer player = Minecraft.getMinecraft().player; + double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks; + double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks; + double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks; + + GlStateManager.pushMatrix(); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + GlStateManager.disableTexture2D(); + GlStateManager.glLineWidth(2.0F); + GlStateManager.depthMask(false); + for(IMultiblockController controller : controllers){ + if(controller != null){ + BlockPos lastErrorPosition = controller.getLastValidationErrorPosition(); + if(lastErrorPosition != null){ + if(world.isBlockLoaded(lastErrorPosition) && player.getDistanceSq(lastErrorPosition) < 64F){ + AxisAlignedBB box = Block.FULL_BLOCK_AABB.offset(lastErrorPosition.getX() - playerX, lastErrorPosition.getY() - playerY, lastErrorPosition.getZ() - playerZ); + RenderGlobal.drawSelectionBoundingBox(box, 1.0F, 0.0F, 0.0F, 0.25F); + RenderGlobal.renderFilledBox(box, 1.0F, 0.0F, 0.0F, 0.125F); + } + } + } + } + + GlStateManager.depthMask(true); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GlStateManager.popMatrix(); + } + }catch(Exception e){ + Log.error("Failed to render the position of a multiblock exeption.", e); + } + } +} diff --git a/src/main/java/forestry/core/proxy/ProxyClient.java b/src/main/java/forestry/core/proxy/ProxyClient.java index afe831194..fba85924f 100644 --- a/src/main/java/forestry/core/proxy/ProxyClient.java +++ b/src/main/java/forestry/core/proxy/ProxyClient.java @@ -15,6 +15,7 @@ import java.io.File; import forestry.core.TickHandlerCoreClient; import forestry.core.models.ModelManager; import forestry.core.multiblock.MultiblockClientTickHandler; +import forestry.core.multiblock.MultiblockEventHandlerClient; import forestry.core.render.TextureManager; import forestry.core.worldgen.WorldGenerator; import net.minecraft.block.Block; @@ -43,6 +44,11 @@ public class ProxyClient extends ProxyCommon { MinecraftForge.EVENT_BUS.register(new MultiblockClientTickHandler()); } + @Override + public void registerEventHandlers() { + MinecraftForge.EVENT_BUS.register(new MultiblockEventHandlerClient()); + } + @Override public void registerBlock(Block block) { ModelManager.getInstance().registerBlockClient(block); diff --git a/src/main/java/forestry/core/proxy/ProxyCommon.java b/src/main/java/forestry/core/proxy/ProxyCommon.java index 2e45a355b..365e5600a 100755 --- a/src/main/java/forestry/core/proxy/ProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ProxyCommon.java @@ -48,6 +48,10 @@ public class ProxyCommon { MultiblockServerTickHandler multiblockServerTickHandler = new MultiblockServerTickHandler(); MinecraftForge.EVENT_BUS.register(multiblockServerTickHandler); } + + public void registerEventHandlers(){ + + } public String getDisplayName(ItemStack itemstack) { return null; diff --git a/src/main/java/forestry/farming/items/ItemBlockFarm.java b/src/main/java/forestry/farming/items/ItemBlockFarm.java index 2fe5dc0b0..dfca8db5f 100644 --- a/src/main/java/forestry/farming/items/ItemBlockFarm.java +++ b/src/main/java/forestry/farming/items/ItemBlockFarm.java @@ -38,8 +38,9 @@ public class ItemBlockFarm extends ItemBlock { if (itemstack.getTagCompound() == null) { return; } + EnumFarmBlockTexture texture = EnumFarmBlockTexture.getFromCompound(itemstack.getTagCompound()); - info.add(TextFormatting.ITALIC + EnumFarmBlockTexture.getFromCompound(itemstack.getTagCompound()).getName()); + info.add(Translator.translateToLocal("tile.for.ffarm.material.tooltip") + texture.getFormatting() + TextFormatting.ITALIC + " "+ texture.getName()); } @Override diff --git a/src/main/java/forestry/farming/models/EnumFarmBlockTexture.java b/src/main/java/forestry/farming/models/EnumFarmBlockTexture.java index 612d7f681..6e8cb98f6 100644 --- a/src/main/java/forestry/farming/models/EnumFarmBlockTexture.java +++ b/src/main/java/forestry/farming/models/EnumFarmBlockTexture.java @@ -18,28 +18,35 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public enum EnumFarmBlockTexture { - BRICK_STONE(new ItemStack(Blocks.STONEBRICK, 1, 0)), - BRICK_MOSSY(new ItemStack(Blocks.STONEBRICK, 1, 1)), - BRICK_CRACKED(new ItemStack(Blocks.STONEBRICK, 1, 2)), - BRICK(new ItemStack(Blocks.BRICK_BLOCK)), - SANDSTONE_SMOOTH(new ItemStack(Blocks.SANDSTONE, 1, 2)), - SANDSTONE_CHISELED(new ItemStack(Blocks.SANDSTONE, 1, 1)), - BRICK_NETHER(new ItemStack(Blocks.NETHER_BRICK)), - BRICK_CHISELED(new ItemStack(Blocks.STONEBRICK, 1, 3)), - QUARTZ(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 0)), - QUARTZ_CHISELED(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 1)), - QUARTZ_LINES(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 2)); + BRICK_STONE(new ItemStack(Blocks.STONEBRICK, 1, 0), TextFormatting.DARK_GRAY), + BRICK_MOSSY(new ItemStack(Blocks.STONEBRICK, 1, 1), TextFormatting.DARK_GRAY), + BRICK_CRACKED(new ItemStack(Blocks.STONEBRICK, 1, 2), TextFormatting.DARK_GRAY), + BRICK(new ItemStack(Blocks.BRICK_BLOCK), TextFormatting.GOLD), + SANDSTONE_SMOOTH(new ItemStack(Blocks.SANDSTONE, 1, 2), TextFormatting.YELLOW), + SANDSTONE_CHISELED(new ItemStack(Blocks.SANDSTONE, 1, 1), TextFormatting.YELLOW), + BRICK_NETHER(new ItemStack(Blocks.NETHER_BRICK), TextFormatting.DARK_RED), + BRICK_CHISELED(new ItemStack(Blocks.STONEBRICK, 1, 3), TextFormatting.GOLD), + QUARTZ(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 0), TextFormatting.WHITE), + QUARTZ_CHISELED(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 1), TextFormatting.WHITE), + QUARTZ_LINES(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 2), TextFormatting.WHITE); private final ItemStack base; + private final TextFormatting formatting; - EnumFarmBlockTexture(ItemStack base) { + EnumFarmBlockTexture(ItemStack base, TextFormatting formatting) { this.base = base; + this.formatting = formatting; } - + + public TextFormatting getFormatting() { + return formatting; + } + /** * @return The texture sprite from the material of the farm block */ diff --git a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java index 81b4c7348..97771ac68 100644 --- a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java +++ b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java @@ -12,6 +12,7 @@ package forestry.greenhouse.blocks; import javax.annotation.Nullable; import java.util.EnumMap; +import java.util.List; import java.util.Locale; import java.util.Map; @@ -33,6 +34,7 @@ import forestry.core.tiles.IActivatable; import forestry.core.utils.CamouflageUtil; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; +import forestry.core.utils.Translator; import forestry.greenhouse.tiles.TileGreenhouseButterflyHatch; import forestry.greenhouse.tiles.TileGreenhouseClimateControl; import forestry.greenhouse.tiles.TileGreenhouseControl; @@ -74,6 +76,7 @@ import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.client.model.ModelLoader; @@ -447,4 +450,11 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR public abstract BlockGreenhouseType getGreenhouseType(); + + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { + tooltip.add(Translator.translateToLocal("tile.for.greenhouse.tooltip")); + tooltip.add(TextFormatting.GREEN.toString() + TextFormatting.ITALIC.toString() + Translator.translateToLocal("tile.for.greenhouse.camouflage.tooltip")); + } }