From b983246ef92ff82fc339ede28cb5427a65daf9c2 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 27 Jan 2019 13:57:34 +0100 Subject: [PATCH] added mystical magnifier --- .../java/de/ellpeck/naturesaura/Helper.java | 38 ++++++++ .../api/render/IVisualizableBlock.java | 16 ++++ .../blocks/BlockAnimalGenerator.java | 19 +++- .../blocks/BlockContainerImpl.java | 6 +- .../blocks/BlockHopperUpgrade.java | 20 +++- .../naturesaura/blocks/BlockOakGenerator.java | 18 +++- .../blocks/BlockPickupStopper.java | 28 +++++- .../naturesaura/blocks/BlockSpawnLamp.java | 26 +++++- .../blocks/tiles/TileEntityImpl.java | 4 + .../blocks/tiles/TileEntityPickupStopper.java | 6 ++ .../blocks/tiles/TileEntitySpawnLamp.java | 5 + .../naturesaura/events/ClientEvents.java | 87 ++++++++++-------- .../items/ItemRangeVisualizer.java | 38 ++++++++ .../ellpeck/naturesaura/items/ModItems.java | 1 + .../assets/naturesaura/lang/en_US.lang | 1 + .../models/item/range_visualizer.json | 6 ++ .../en_us/entries/items/range_visualizer.json | 17 ++++ .../naturesaura/recipes/range_visualizer.json | 25 +++++ .../textures/items/range_visualizer.png | Bin 0 -> 436 bytes 19 files changed, 313 insertions(+), 48 deletions(-) create mode 100644 src/main/java/de/ellpeck/naturesaura/api/render/IVisualizableBlock.java create mode 100644 src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java create mode 100644 src/main/resources/assets/naturesaura/models/item/range_visualizer.json create mode 100644 src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/items/range_visualizer.json create mode 100644 src/main/resources/assets/naturesaura/recipes/range_visualizer.json create mode 100644 src/main/resources/assets/naturesaura/textures/items/range_visualizer.png diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index 04f93540..ae8163da 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -16,6 +16,7 @@ import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.SoundEvents; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.NBTBase; @@ -254,4 +255,41 @@ public final class Helper { highestAmount = stack.getCount(); return highestAmount; } + + @SideOnly(Side.CLIENT) + public static void renderWeirdBox(double x, double y, double z, double width, double height, double depth) { + GL11.glVertex3d(x, y + height, z); + GL11.glVertex3d(x + width, y + height, z); + GL11.glVertex3d(x + width, y, z); + GL11.glVertex3d(x, y, z); + GL11.glVertex3d(x + width, y, z + depth); + GL11.glVertex3d(x + width, y, z); + GL11.glVertex3d(x + width, y + height, z); + GL11.glVertex3d(x + width, y + height, z + depth); + GL11.glVertex3d(x + width, y + height, z + depth); + GL11.glVertex3d(x, y + height, z + depth); + GL11.glVertex3d(x, y, z + depth); + GL11.glVertex3d(x + width, y, z + depth); + GL11.glVertex3d(x, y + height, z + depth); + GL11.glVertex3d(x, y + height, z); + GL11.glVertex3d(x, y, z); + GL11.glVertex3d(x, y, z + depth); + GL11.glVertex3d(x, y + height, z); + GL11.glVertex3d(x, y + height, z + depth); + GL11.glVertex3d(x + width, y + height, z + depth); + GL11.glVertex3d(x + width, y + height, z); + GL11.glVertex3d(x + width, y, z); + GL11.glVertex3d(x + width, y, z + depth); + GL11.glVertex3d(x, y, z + depth); + GL11.glVertex3d(x, y, z); + } + + public static boolean isHoldingItem(EntityPlayer player, Item item) { + for (EnumHand hand : EnumHand.values()) { + ItemStack stack = player.getHeldItem(hand); + if (!stack.isEmpty() && stack.getItem() == item) + return true; + } + return false; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/api/render/IVisualizableBlock.java b/src/main/java/de/ellpeck/naturesaura/api/render/IVisualizableBlock.java new file mode 100644 index 00000000..0011f5e9 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/api/render/IVisualizableBlock.java @@ -0,0 +1,16 @@ +package de.ellpeck.naturesaura.api.render; + +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public interface IVisualizableBlock { + + @SideOnly(Side.CLIENT) + AxisAlignedBB getVisualizationBounds(World world, BlockPos pos); + + @SideOnly(Side.CLIENT) + int getVisualizationColor(World world, BlockPos pos); +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java index f43a7fc8..16c439cf 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.api.render.IVisualizableBlock; import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalGenerator; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; @@ -12,16 +13,20 @@ import net.minecraft.entity.INpc; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.passive.IAnimals; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; +import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.living.LivingExperienceDropEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockAnimalGenerator extends BlockContainerImpl { +public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizableBlock { public BlockAnimalGenerator() { super(Material.ROCK, "animal_generator", TileEntityAnimalGenerator.class, "animal_generator"); this.setSoundType(SoundType.STONE); @@ -91,4 +96,16 @@ public class BlockAnimalGenerator extends BlockContainerImpl { if (entity.getEntityData().getBoolean(NaturesAura.MOD_ID + ":no_drops")) event.setCanceled(true); } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + return new AxisAlignedBB(pos).grow(5); + } + + @Override + @SideOnly(Side.CLIENT) + public int getVisualizationColor(World world, BlockPos pos) { + return 0x11377a; + } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java index 48e81135..b0e728c5 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java @@ -130,7 +130,11 @@ public class BlockContainerImpl extends BlockContainer implements IModItem, ICre TileEntity tile = world.getTileEntity(pos); if (tile instanceof TileEntityImpl) { TileEntityImpl impl = (TileEntityImpl) tile; - impl.redstonePower = world.getRedstonePowerFromNeighbors(pos); + int newPower = world.getRedstonePowerFromNeighbors(pos); + if (impl.redstonePower != newPower) { + impl.redstonePower = newPower; + impl.onRedstonePowerChange(); + } } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java index 62c41ecb..877ac574 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java @@ -1,13 +1,31 @@ package de.ellpeck.naturesaura.blocks; +import de.ellpeck.naturesaura.api.render.IVisualizableBlock; import de.ellpeck.naturesaura.blocks.tiles.TileEntityHopperUpgrade; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockHopperUpgrade extends BlockContainerImpl { +public class BlockHopperUpgrade extends BlockContainerImpl implements IVisualizableBlock { public BlockHopperUpgrade() { super(Material.IRON, "hopper_upgrade", TileEntityHopperUpgrade.class, "hopper_upgrade"); this.setSoundType(SoundType.METAL); this.setHardness(2.5F); } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + return new AxisAlignedBB(pos).grow(7); + } + + @Override + @SideOnly(Side.CLIENT) + public int getVisualizationColor(World world, BlockPos pos) { + return 0x434f3f; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java index 610cbca0..cda72712 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java @@ -2,19 +2,23 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import de.ellpeck.naturesaura.api.render.IVisualizableBlock; import de.ellpeck.naturesaura.blocks.tiles.TileEntityOakGenerator; import net.minecraft.block.BlockSapling; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; +import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Random; -public class BlockOakGenerator extends BlockContainerImpl { +public class BlockOakGenerator extends BlockContainerImpl implements IVisualizableBlock { public BlockOakGenerator() { super(Material.WOOD, "oak_generator", TileEntityOakGenerator.class, "oak_generator"); @@ -50,4 +54,16 @@ public class BlockOakGenerator extends BlockContainerImpl { }); } } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + return new AxisAlignedBB(pos).grow(10); + } + + @Override + @SideOnly(Side.CLIENT) + public int getVisualizationColor(World world, BlockPos pos) { + return 0x2e7a11; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java index 4ea05b56..2fcefab7 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.Helper; +import de.ellpeck.naturesaura.api.render.IVisualizableBlock; import de.ellpeck.naturesaura.blocks.tiles.TileEntityPickupStopper; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; @@ -8,12 +9,17 @@ import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; 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.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockPickupStopper extends BlockContainerImpl { +public class BlockPickupStopper extends BlockContainerImpl implements IVisualizableBlock { public BlockPickupStopper() { super(Material.ROCK, "pickup_stopper", TileEntityPickupStopper.class, "pickup_stopper"); this.setSoundType(SoundType.STONE); @@ -36,7 +42,7 @@ public class BlockPickupStopper extends BlockContainerImpl { if (radius <= 0F) return false; BlockPos stopperPos = stopper.getPos(); - if (item.getDistanceSq(stopperPos.getX() + 0.5F, stopperPos.getY() + 0.5F, stopperPos.getZ() + 0.5F) > radius * radius) + if (!new AxisAlignedBB(stopperPos).grow(radius).intersects(item.getEntityBoundingBox())) return false; event.setCanceled(true); @@ -48,4 +54,22 @@ public class BlockPickupStopper extends BlockContainerImpl { }); } } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + TileEntity tile = world.getTileEntity(pos); + if (tile instanceof TileEntityPickupStopper) { + double radius = ((TileEntityPickupStopper) tile).getRadius(); + if (radius > 0) + return new AxisAlignedBB(pos).grow(radius); + } + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public int getVisualizationColor(World world, BlockPos pos) { + return 0xf4aa42; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java index eabeb937..89e97a1e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import de.ellpeck.naturesaura.api.render.IVisualizableBlock; import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; @@ -10,10 +11,12 @@ import net.minecraft.block.material.Material; import net.minecraft.block.state.BlockFaceShape; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLiving; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -23,7 +26,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockSpawnLamp extends BlockContainerImpl { +public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizableBlock { private static final AxisAlignedBB AABB = new AxisAlignedBB(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F); @@ -50,7 +53,7 @@ public class BlockSpawnLamp extends BlockContainerImpl { return false; BlockPos lampPos = lamp.getPos(); - if (pos.distanceSq(lampPos.getX() + 0.5F, lampPos.getY() + 0.5F, lampPos.getZ() + 0.5F) > range * range) + if (!new AxisAlignedBB(lampPos).grow(range).contains(new Vec3d(pos))) return false; EntityLiving entity = (EntityLiving) event.getEntityLiving(); @@ -102,4 +105,23 @@ public class BlockSpawnLamp extends BlockContainerImpl { public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { return BlockFaceShape.UNDEFINED; } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + TileEntity tile = world.getTileEntity(pos); + if (tile instanceof TileEntitySpawnLamp) { + int radius = ((TileEntitySpawnLamp) tile).getRadius(); + if (radius > 0) + return new AxisAlignedBB(pos).grow(radius); + System.out.println(radius); + } + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public int getVisualizationColor(World world, BlockPos pos) { + return 0x825ee5; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java index acb64401..77ec065f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java @@ -56,6 +56,10 @@ public class TileEntityImpl extends TileEntity { } } + public void onRedstonePowerChange(){ + + } + @Override public final SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound compound = new NBTTagCompound(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java index 4e57ecbc..f980fb06 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java @@ -5,4 +5,10 @@ public class TileEntityPickupStopper extends TileEntityImpl { public float getRadius() { return this.redstonePower / 2F; } + + @Override + public void onRedstonePowerChange() { + if (!this.world.isRemote) + this.sendToClients(); + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySpawnLamp.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySpawnLamp.java index e8999e95..b6abbcf7 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySpawnLamp.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySpawnLamp.java @@ -6,4 +6,9 @@ public class TileEntitySpawnLamp extends TileEntityImpl { return this.redstonePower * 3; } + @Override + public void onRedstonePowerChange() { + if (!this.world.isRemote) + this.sendToClients(); + } } diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index 411c9941..90df51fe 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -1,18 +1,22 @@ package de.ellpeck.naturesaura.events; import baubles.api.BaublesApi; +import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.type.IAuraType; +import de.ellpeck.naturesaura.api.render.IVisualizableBlock; import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar; import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter; import de.ellpeck.naturesaura.compat.Compat; +import de.ellpeck.naturesaura.items.ItemRangeVisualizer; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.particles.ParticleHandler; import de.ellpeck.naturesaura.particles.ParticleMagic; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; @@ -22,6 +26,7 @@ import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.TextFormatting; @@ -102,19 +107,18 @@ public class ClientEvents { public void onWorldRender(RenderWorldLastEvent event) { Minecraft mc = Minecraft.getMinecraft(); mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onWorldRender"); + GL11.glPushMatrix(); + float partial = event.getPartialTicks(); + GL11.glTranslated( + -mc.player.prevPosX - (mc.player.posX - mc.player.prevPosX) * partial, + -mc.player.prevPosY - (mc.player.posY - mc.player.prevPosY) * partial, + -mc.player.prevPosZ - (mc.player.posZ - mc.player.prevPosZ) * partial); + if (mc.gameSettings.showDebugInfo && mc.player.capabilities.isCreativeMode && ModConfig.client.debugWorld) { + Map spots = new HashMap<>(); GL11.glPushMatrix(); GL11.glDisable(GL11.GL_DEPTH_TEST); - float partial = event.getPartialTicks(); - GL11.glTranslated( - -mc.player.prevPosX - (mc.player.posX - mc.player.prevPosX) * partial, - -mc.player.prevPosY - (mc.player.posY - mc.player.prevPosY) * partial, - -mc.player.prevPosZ - (mc.player.posZ - mc.player.prevPosZ) * partial); - - Map spots = new HashMap<>(); - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - GL11.glPushMatrix(); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBegin(GL11.GL_QUADS); @@ -122,40 +126,11 @@ public class ClientEvents { spots.put(pos, spot); GlStateManager.color(spot > 0 ? 0F : 1F, spot > 0 ? 1F : 0F, 0F, 0.35F); - int x = pos.getX(); - int y = pos.getY(); - int z = pos.getZ(); - GL11.glVertex3d(x, y + 1, z); - GL11.glVertex3d(x + 1, y + 1, z); - GL11.glVertex3d(x + 1, y, z); - GL11.glVertex3d(x, y, z); - GL11.glVertex3d(x + 1, y, z + 1); - GL11.glVertex3d(x + 1, y, z); - GL11.glVertex3d(x + 1, y + 1, z); - GL11.glVertex3d(x + 1, y + 1, z + 1); - GL11.glVertex3d(x + 1, y + 1, z + 1); - GL11.glVertex3d(x, y + 1, z + 1); - GL11.glVertex3d(x, y, z + 1); - GL11.glVertex3d(x + 1, y, z + 1); - GL11.glVertex3d(x, y + 1, z + 1); - GL11.glVertex3d(x, y + 1, z); - GL11.glVertex3d(x, y, z); - GL11.glVertex3d(x, y, z + 1); - GL11.glVertex3d(x, y + 1, z); - GL11.glVertex3d(x, y + 1, z + 1); - GL11.glVertex3d(x + 1, y + 1, z + 1); - GL11.glVertex3d(x + 1, y + 1, z); - GL11.glVertex3d(x + 1, y, z); - GL11.glVertex3d(x + 1, y, z + 1); - GL11.glVertex3d(x, y, z + 1); - GL11.glVertex3d(x, y, z); + Helper.renderWeirdBox(pos.getX(), pos.getY(), pos.getZ(), 1, 1, 1); }); GL11.glEnd(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glPopMatrix(); GL11.glPopAttrib(); - GL11.glPushMatrix(); float scale = 0.03F; GlStateManager.scale(scale, scale, scale); for (Map.Entry spot : spots.entrySet()) { @@ -166,11 +141,43 @@ public class ClientEvents { mc.fontRenderer.drawString(spot.getValue().toString(), 0, 0, 0); GlStateManager.popMatrix(); } - GL11.glPopMatrix(); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glPopMatrix(); } + + if (mc.objectMouseOver != null) { + if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER)) { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBegin(GL11.GL_QUADS); + for (BlockPos pos : ItemRangeVisualizer.VISUALIZED_POSITIONS) { + if (!mc.world.isBlockLoaded(pos)) + continue; + IBlockState state = mc.world.getBlockState(pos); + Block block = state.getBlock(); + if (!(block instanceof IVisualizableBlock)) + continue; + IVisualizableBlock visualize = (IVisualizableBlock) block; + AxisAlignedBB box = visualize.getVisualizationBounds(mc.world, pos); + if (box == null) + continue; + box = box.grow(0.05F); + int color = visualize.getVisualizationColor(mc.world, pos); + GlStateManager.color(((color >> 16) & 255) / 255F, ((color >> 8) & 255) / 255F, (color & 255) / 255F, 0.5F); + Helper.renderWeirdBox(box.minX, box.minY, box.minZ, box.maxX - box.minX, box.maxY - box.minY, box.maxZ - box.minZ); + } + GL11.glEnd(); + GL11.glPopAttrib(); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + } + } + + GL11.glPopMatrix(); mc.profiler.endSection(); } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java b/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java new file mode 100644 index 00000000..3178ed39 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java @@ -0,0 +1,38 @@ +package de.ellpeck.naturesaura.items; + +import de.ellpeck.naturesaura.api.render.IVisualizableBlock; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import java.util.HashSet; +import java.util.Set; + +public class ItemRangeVisualizer extends ItemImpl { + + public static final Set VISUALIZED_POSITIONS = new HashSet<>(); + + public ItemRangeVisualizer() { + super("range_visualizer"); + } + + @Override + public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + IBlockState state = worldIn.getBlockState(pos); + Block block = state.getBlock(); + if (block instanceof IVisualizableBlock) { + if (worldIn.isRemote) + if (VISUALIZED_POSITIONS.contains(pos)) + VISUALIZED_POSITIONS.remove(pos); + else + VISUALIZED_POSITIONS.add(pos); + return EnumActionResult.SUCCESS; + } + return EnumActionResult.PASS; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java index 1efee405..6b72beca 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java @@ -44,4 +44,5 @@ public final class ModItems { public static final Item EFFECT_POWDER = new ItemEffectPowder(); public static final Item BIRTH_SPIRIT = new ItemBirthSpirit(); public static final Item MOVER_MINECART = new ItemMoverMinecart(); + public static final Item RANGE_VISUALIZER = new ItemRangeVisualizer(); } diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index 092c7faa..25678540 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -75,6 +75,7 @@ item.naturesaura.effect_powder.naturesaura:plant_boost.name=Powder of Steady Gro item.naturesaura.effect_powder.naturesaura:cache_recharge.name=Powder of no Storage item.naturesaura.effect_powder.naturesaura:animal.name=Powder of Chastity item.naturesaura.mover_cart.name=Aura Attraction Cart +item.naturesaura.range_visualizer.name=Mystical Magnifier container.naturesaura.tree_ritual.name=Ritual of the Forest container.naturesaura.altar.name=Natural Altar Infusion diff --git a/src/main/resources/assets/naturesaura/models/item/range_visualizer.json b/src/main/resources/assets/naturesaura/models/item/range_visualizer.json new file mode 100644 index 00000000..0e887a81 --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/item/range_visualizer.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "naturesaura:items/range_visualizer" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/items/range_visualizer.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/items/range_visualizer.json new file mode 100644 index 00000000..410771db --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/items/range_visualizer.json @@ -0,0 +1,17 @@ +{ + "name": "Mystical Magnifier", + "icon": "naturesaura:range_visualizer", + "category": "items", + "advancement": "naturesaura:infused_materials", + "pages": [ + { + "type": "text", + "text": "The $(item)Mystical Magnifier$() is a $(t:is a mod by vazkii)neat$() device for any magical botanist working with machinery. When equipped in either hand, and interacting with a compatible device, its $(thing)range of operation$() will be displayed around it, allowing any contraptions built with it to be inspected easily and precisely. To stop a device from displaying its range, simply interact with it a second time." + }, + { + "type": "crafting", + "text": "Creating the $(item)Mystical Magnifier$()", + "recipe": "naturesaura:range_visualizer" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/recipes/range_visualizer.json b/src/main/resources/assets/naturesaura/recipes/range_visualizer.json new file mode 100644 index 00000000..fe372a3a --- /dev/null +++ b/src/main/resources/assets/naturesaura/recipes/range_visualizer.json @@ -0,0 +1,25 @@ +{ + "type": "forge:ore_shaped", + "pattern": [ + "IA ", + "AGA", + " AS" + ], + "key": { + "A": { + "item": "naturesaura:ancient_planks" + }, + "I": { + "item": "naturesaura:infused_iron" + }, + "G": { + "item": "minecraft:glass" + }, + "S": { + "item": "naturesaura:ancient_stick" + } + }, + "result": { + "item": "naturesaura:range_visualizer" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/items/range_visualizer.png b/src/main/resources/assets/naturesaura/textures/items/range_visualizer.png new file mode 100644 index 0000000000000000000000000000000000000000..5726c3fd750bade0e54c1471cfe7b4895a9bdd2d GIT binary patch literal 436 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`3dtTpz6=aistgPb%?u1b{{!il z3=E|P3=FRl7#OT(FffScPl`Y422{&g;1OBOz`)G|!i@F~N+*DV5+$w?CBgY=CFO}l zsSE{)nRz98d8s7|CVGZ?Cc+LGM;I6w#XMacLoEDzCmr-U>>%R$oBNV)YgwR+BUfHm zcKNO^?Dy?G1XVaic4r=J6-Zv_CFm05X)M^{YR6v&R>3@KiIf`k>u7_p`ytw z8s+b7V+*cKuJ4ZAbG>D1Mx%0=M$~DpqQeu!AGFD@Uz_@dwNIp^i?#38j@uav56_Eu zmSVne!99xw&39#|rn59p=luRls(#la)(C}4k^1Ta(er0}&ObhNfM>#&`EoCua&M%5 zS@*yF!Sb52D^s4otrgW4VDJby(ezrqoi}WfwPw@gCr+t1RQ@}q=6J1HXtYTvJ3)G% cs_#!$rdxZozJ_;(0z;9()78&qol`;+07he|PXGV_ literal 0 HcmV?d00001