mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
added mystical magnifier
This commit is contained in:
parent
fc1723a78d
commit
b983246ef9
19 changed files with 313 additions and 48 deletions
|
@ -16,6 +16,7 @@ import net.minecraft.entity.item.EntityItemFrame;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.init.SoundEvents;
|
import net.minecraft.init.SoundEvents;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.nbt.NBTBase;
|
import net.minecraft.nbt.NBTBase;
|
||||||
|
@ -254,4 +255,41 @@ public final class Helper {
|
||||||
highestAmount = stack.getCount();
|
highestAmount = stack.getCount();
|
||||||
return highestAmount;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
import de.ellpeck.naturesaura.api.render.IVisualizableBlock;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalGenerator;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalGenerator;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
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.monster.IMob;
|
||||||
import net.minecraft.entity.passive.IAnimals;
|
import net.minecraft.entity.passive.IAnimals;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingExperienceDropEvent;
|
import net.minecraftforge.event.entity.living.LivingExperienceDropEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
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() {
|
public BlockAnimalGenerator() {
|
||||||
super(Material.ROCK, "animal_generator", TileEntityAnimalGenerator.class, "animal_generator");
|
super(Material.ROCK, "animal_generator", TileEntityAnimalGenerator.class, "animal_generator");
|
||||||
this.setSoundType(SoundType.STONE);
|
this.setSoundType(SoundType.STONE);
|
||||||
|
@ -91,4 +96,16 @@ public class BlockAnimalGenerator extends BlockContainerImpl {
|
||||||
if (entity.getEntityData().getBoolean(NaturesAura.MOD_ID + ":no_drops"))
|
if (entity.getEntityData().getBoolean(NaturesAura.MOD_ID + ":no_drops"))
|
||||||
event.setCanceled(true);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -130,7 +130,11 @@ public class BlockContainerImpl extends BlockContainer implements IModItem, ICre
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if (tile instanceof TileEntityImpl) {
|
if (tile instanceof TileEntityImpl) {
|
||||||
TileEntityImpl impl = (TileEntityImpl) tile;
|
TileEntityImpl impl = (TileEntityImpl) tile;
|
||||||
impl.redstonePower = world.getRedstonePowerFromNeighbors(pos);
|
int newPower = world.getRedstonePowerFromNeighbors(pos);
|
||||||
|
if (impl.redstonePower != newPower) {
|
||||||
|
impl.redstonePower = newPower;
|
||||||
|
impl.onRedstonePowerChange();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,31 @@
|
||||||
package de.ellpeck.naturesaura.blocks;
|
package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
|
import de.ellpeck.naturesaura.api.render.IVisualizableBlock;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityHopperUpgrade;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityHopperUpgrade;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
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() {
|
public BlockHopperUpgrade() {
|
||||||
super(Material.IRON, "hopper_upgrade", TileEntityHopperUpgrade.class, "hopper_upgrade");
|
super(Material.IRON, "hopper_upgrade", TileEntityHopperUpgrade.class, "hopper_upgrade");
|
||||||
this.setSoundType(SoundType.METAL);
|
this.setSoundType(SoundType.METAL);
|
||||||
this.setHardness(2.5F);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,19 +2,23 @@ package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
|
import de.ellpeck.naturesaura.api.render.IVisualizableBlock;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOakGenerator;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOakGenerator;
|
||||||
import net.minecraft.block.BlockSapling;
|
import net.minecraft.block.BlockSapling;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent;
|
import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class BlockOakGenerator extends BlockContainerImpl {
|
public class BlockOakGenerator extends BlockContainerImpl implements IVisualizableBlock {
|
||||||
|
|
||||||
public BlockOakGenerator() {
|
public BlockOakGenerator() {
|
||||||
super(Material.WOOD, "oak_generator", TileEntityOakGenerator.class, "oak_generator");
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package de.ellpeck.naturesaura.blocks;
|
package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
|
import de.ellpeck.naturesaura.api.render.IVisualizableBlock;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPickupStopper;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPickupStopper;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
|
@ -8,12 +9,17 @@ import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
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.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
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() {
|
public BlockPickupStopper() {
|
||||||
super(Material.ROCK, "pickup_stopper", TileEntityPickupStopper.class, "pickup_stopper");
|
super(Material.ROCK, "pickup_stopper", TileEntityPickupStopper.class, "pickup_stopper");
|
||||||
this.setSoundType(SoundType.STONE);
|
this.setSoundType(SoundType.STONE);
|
||||||
|
@ -36,7 +42,7 @@ public class BlockPickupStopper extends BlockContainerImpl {
|
||||||
if (radius <= 0F)
|
if (radius <= 0F)
|
||||||
return false;
|
return false;
|
||||||
BlockPos stopperPos = stopper.getPos();
|
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;
|
return false;
|
||||||
|
|
||||||
event.setCanceled(true);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
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.blocks.tiles.TileEntitySpawnLamp;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
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.BlockFaceShape;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.BlockRenderLayer;
|
import net.minecraft.util.BlockRenderLayer;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
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.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
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);
|
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;
|
return false;
|
||||||
|
|
||||||
BlockPos lampPos = lamp.getPos();
|
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;
|
return false;
|
||||||
|
|
||||||
EntityLiving entity = (EntityLiving) event.getEntityLiving();
|
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) {
|
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
|
||||||
return BlockFaceShape.UNDEFINED;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,10 @@ public class TileEntityImpl extends TileEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onRedstonePowerChange(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final SPacketUpdateTileEntity getUpdatePacket() {
|
public final SPacketUpdateTileEntity getUpdatePacket() {
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
|
|
|
@ -5,4 +5,10 @@ public class TileEntityPickupStopper extends TileEntityImpl {
|
||||||
public float getRadius() {
|
public float getRadius() {
|
||||||
return this.redstonePower / 2F;
|
return this.redstonePower / 2F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRedstonePowerChange() {
|
||||||
|
if (!this.world.isRemote)
|
||||||
|
this.sendToClients();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,4 +6,9 @@ public class TileEntitySpawnLamp extends TileEntityImpl {
|
||||||
return this.redstonePower * 3;
|
return this.redstonePower * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRedstonePowerChange() {
|
||||||
|
if (!this.world.isRemote)
|
||||||
|
this.sendToClients();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,22 @@
|
||||||
package de.ellpeck.naturesaura.events;
|
package de.ellpeck.naturesaura.events;
|
||||||
|
|
||||||
import baubles.api.BaublesApi;
|
import baubles.api.BaublesApi;
|
||||||
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.ModConfig;
|
import de.ellpeck.naturesaura.ModConfig;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
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.TileEntityNatureAltar;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter;
|
||||||
import de.ellpeck.naturesaura.compat.Compat;
|
import de.ellpeck.naturesaura.compat.Compat;
|
||||||
|
import de.ellpeck.naturesaura.items.ItemRangeVisualizer;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.particles.ParticleHandler;
|
import de.ellpeck.naturesaura.particles.ParticleHandler;
|
||||||
import de.ellpeck.naturesaura.particles.ParticleMagic;
|
import de.ellpeck.naturesaura.particles.ParticleMagic;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
|
@ -22,6 +26,7 @@ import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
@ -102,19 +107,18 @@ public class ClientEvents {
|
||||||
public void onWorldRender(RenderWorldLastEvent event) {
|
public void onWorldRender(RenderWorldLastEvent event) {
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onWorldRender");
|
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) {
|
if (mc.gameSettings.showDebugInfo && mc.player.capabilities.isCreativeMode && ModConfig.client.debugWorld) {
|
||||||
|
Map<BlockPos, Integer> spots = new HashMap<>();
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
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<BlockPos, Integer> spots = new HashMap<>();
|
|
||||||
|
|
||||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
GL11.glBegin(GL11.GL_QUADS);
|
GL11.glBegin(GL11.GL_QUADS);
|
||||||
|
@ -122,40 +126,11 @@ public class ClientEvents {
|
||||||
spots.put(pos, spot);
|
spots.put(pos, spot);
|
||||||
|
|
||||||
GlStateManager.color(spot > 0 ? 0F : 1F, spot > 0 ? 1F : 0F, 0F, 0.35F);
|
GlStateManager.color(spot > 0 ? 0F : 1F, spot > 0 ? 1F : 0F, 0F, 0.35F);
|
||||||
int x = pos.getX();
|
Helper.renderWeirdBox(pos.getX(), pos.getY(), pos.getZ(), 1, 1, 1);
|
||||||
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);
|
|
||||||
});
|
});
|
||||||
GL11.glEnd();
|
GL11.glEnd();
|
||||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
GL11.glPopAttrib();
|
GL11.glPopAttrib();
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
float scale = 0.03F;
|
float scale = 0.03F;
|
||||||
GlStateManager.scale(scale, scale, scale);
|
GlStateManager.scale(scale, scale, scale);
|
||||||
for (Map.Entry<BlockPos, Integer> spot : spots.entrySet()) {
|
for (Map.Entry<BlockPos, Integer> spot : spots.entrySet()) {
|
||||||
|
@ -166,11 +141,43 @@ public class ClientEvents {
|
||||||
mc.fontRenderer.drawString(spot.getValue().toString(), 0, 0, 0);
|
mc.fontRenderer.drawString(spot.getValue().toString(), 0, 0, 0);
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
GL11.glPopMatrix();
|
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||||
GL11.glPopMatrix();
|
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();
|
mc.profiler.endSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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<BlockPos> 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -44,4 +44,5 @@ public final class ModItems {
|
||||||
public static final Item EFFECT_POWDER = new ItemEffectPowder();
|
public static final Item EFFECT_POWDER = new ItemEffectPowder();
|
||||||
public static final Item BIRTH_SPIRIT = new ItemBirthSpirit();
|
public static final Item BIRTH_SPIRIT = new ItemBirthSpirit();
|
||||||
public static final Item MOVER_MINECART = new ItemMoverMinecart();
|
public static final Item MOVER_MINECART = new ItemMoverMinecart();
|
||||||
|
public static final Item RANGE_VISUALIZER = new ItemRangeVisualizer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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:cache_recharge.name=Powder of no Storage
|
||||||
item.naturesaura.effect_powder.naturesaura:animal.name=Powder of Chastity
|
item.naturesaura.effect_powder.naturesaura:animal.name=Powder of Chastity
|
||||||
item.naturesaura.mover_cart.name=Aura Attraction Cart
|
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.tree_ritual.name=Ritual of the Forest
|
||||||
container.naturesaura.altar.name=Natural Altar Infusion
|
container.naturesaura.altar.name=Natural Altar Infusion
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "naturesaura:items/range_visualizer"
|
||||||
|
}
|
||||||
|
}
|
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 436 B |
Loading…
Reference in a new issue