mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
allow for entities to be visualized as well and visualize effect powder
This commit is contained in:
parent
47d565a70c
commit
5fe865f299
11 changed files with 107 additions and 36 deletions
|
@ -105,7 +105,7 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
||||||
return false;
|
return false;
|
||||||
AxisAlignedBB bounds = new AxisAlignedBB(
|
AxisAlignedBB bounds = new AxisAlignedBB(
|
||||||
entity.posX, entity.posY, entity.posZ,
|
entity.posX, entity.posY, entity.posZ,
|
||||||
entity.posX, entity.posY, entity.posZ).grow(entity.amount);
|
entity.posX, entity.posY, entity.posZ).grow(entity.getAmount());
|
||||||
return bounds.contains(new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5));
|
return bounds.contains(new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5));
|
||||||
});
|
});
|
||||||
return !inhibitors.isEmpty();
|
return !inhibitors.isEmpty();
|
||||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraft.world.World;
|
||||||
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 interface IVisualizableBlock {
|
public interface IVisualizable {
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
AxisAlignedBB getVisualizationBounds(World world, BlockPos pos);
|
AxisAlignedBB getVisualizationBounds(World world, BlockPos pos);
|
|
@ -2,7 +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.api.render.IVisualizable;
|
||||||
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;
|
||||||
|
@ -26,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 BlockAnimalGenerator extends BlockContainerImpl implements IVisualizableBlock {
|
public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizable {
|
||||||
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);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.ellpeck.naturesaura.blocks;
|
package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.render.IVisualizableBlock;
|
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||||
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;
|
||||||
|
@ -10,7 +10,7 @@ import net.minecraft.world.World;
|
||||||
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 BlockHopperUpgrade extends BlockContainerImpl implements IVisualizableBlock {
|
public class BlockHopperUpgrade extends BlockContainerImpl implements IVisualizable {
|
||||||
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);
|
||||||
|
|
|
@ -2,7 +2,7 @@ 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.api.render.IVisualizable;
|
||||||
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;
|
||||||
|
@ -18,7 +18,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class BlockOakGenerator extends BlockContainerImpl implements IVisualizableBlock {
|
public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable {
|
||||||
|
|
||||||
public BlockOakGenerator() {
|
public BlockOakGenerator() {
|
||||||
super(Material.WOOD, "oak_generator", TileEntityOakGenerator.class, "oak_generator");
|
super(Material.WOOD, "oak_generator", TileEntityOakGenerator.class, "oak_generator");
|
||||||
|
|
|
@ -1,7 +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.api.render.IVisualizable;
|
||||||
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;
|
||||||
|
@ -19,7 +19,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 BlockPickupStopper extends BlockContainerImpl implements IVisualizableBlock {
|
public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable {
|
||||||
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);
|
||||||
|
|
|
@ -2,7 +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.api.render.IVisualizable;
|
||||||
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;
|
||||||
|
@ -26,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 implements IVisualizableBlock {
|
public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable {
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package de.ellpeck.naturesaura.entities;
|
package de.ellpeck.naturesaura.entities;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||||
import de.ellpeck.naturesaura.items.ItemEffectPowder;
|
import de.ellpeck.naturesaura.items.ItemEffectPowder;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -12,13 +13,17 @@ import net.minecraft.network.datasync.EntityDataManager;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
import net.minecraft.util.EntityDamageSource;
|
import net.minecraft.util.EntityDamageSource;
|
||||||
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.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class EntityEffectInhibitor extends Entity {
|
public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
||||||
|
|
||||||
private static final DataParameter<String> INHIBITED_EFFECT = EntityDataManager.createKey(EntityEffectInhibitor.class, DataSerializers.STRING);
|
private static final DataParameter<String> INHIBITED_EFFECT = EntityDataManager.createKey(EntityEffectInhibitor.class, DataSerializers.STRING);
|
||||||
private static final DataParameter<Integer> COLOR = EntityDataManager.createKey(EntityEffectInhibitor.class, DataSerializers.VARINT);
|
private static final DataParameter<Integer> COLOR = EntityDataManager.createKey(EntityEffectInhibitor.class, DataSerializers.VARINT);
|
||||||
public int amount;
|
private static final DataParameter<Integer> AMOUNT = EntityDataManager.createKey(EntityEffectInhibitor.class, DataSerializers.VARINT);
|
||||||
|
|
||||||
public EntityEffectInhibitor(World worldIn) {
|
public EntityEffectInhibitor(World worldIn) {
|
||||||
super(worldIn);
|
super(worldIn);
|
||||||
|
@ -29,20 +34,21 @@ public class EntityEffectInhibitor extends Entity {
|
||||||
this.setSize(0.25F, 0.25F);
|
this.setSize(0.25F, 0.25F);
|
||||||
this.dataManager.register(INHIBITED_EFFECT, null);
|
this.dataManager.register(INHIBITED_EFFECT, null);
|
||||||
this.dataManager.register(COLOR, 0);
|
this.dataManager.register(COLOR, 0);
|
||||||
|
this.dataManager.register(AMOUNT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readEntityFromNBT(NBTTagCompound compound) {
|
protected void readEntityFromNBT(NBTTagCompound compound) {
|
||||||
this.setInhibitedEffect(new ResourceLocation(compound.getString("effect")));
|
this.setInhibitedEffect(new ResourceLocation(compound.getString("effect")));
|
||||||
this.setColor(compound.getInteger("color"));
|
this.setColor(compound.getInteger("color"));
|
||||||
this.amount = compound.hasKey("amount") ? compound.getInteger("amount") : 24;
|
this.setAmount(compound.hasKey("amount") ? compound.getInteger("amount") : 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void writeEntityToNBT(NBTTagCompound compound) {
|
protected void writeEntityToNBT(NBTTagCompound compound) {
|
||||||
compound.setString("effect", this.getInhibitedEffect().toString());
|
compound.setString("effect", this.getInhibitedEffect().toString());
|
||||||
compound.setInteger("color", this.getColor());
|
compound.setInteger("color", this.getColor());
|
||||||
compound.setInteger("amount", this.amount);
|
compound.setInteger("amount", this.getAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -70,7 +76,7 @@ public class EntityEffectInhibitor extends Entity {
|
||||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||||
if (source instanceof EntityDamageSource && !this.world.isRemote) {
|
if (source instanceof EntityDamageSource && !this.world.isRemote) {
|
||||||
this.setDead();
|
this.setDead();
|
||||||
this.entityDropItem(ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER, this.amount), this.getInhibitedEffect()), 0F);
|
this.entityDropItem(ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER, this.getAmount()), this.getInhibitedEffect()), 0F);
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
return super.attackEntityFrom(source, amount);
|
return super.attackEntityFrom(source, amount);
|
||||||
|
@ -91,4 +97,26 @@ public class EntityEffectInhibitor extends Entity {
|
||||||
public int getColor() {
|
public int getColor() {
|
||||||
return this.dataManager.get(COLOR);
|
return this.dataManager.get(COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAmount(int amount) {
|
||||||
|
this.dataManager.set(AMOUNT, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAmount() {
|
||||||
|
return this.dataManager.get(AMOUNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
|
||||||
|
return new AxisAlignedBB(
|
||||||
|
this.posX, this.posY, this.posZ,
|
||||||
|
this.posX, this.posY, this.posZ).grow(this.getAmount());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public int getVisualizationColor(World world, BlockPos pos) {
|
||||||
|
return this.getColor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ 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.api.render.IVisualizable;
|
||||||
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;
|
||||||
|
@ -23,6 +23,7 @@ import net.minecraft.client.gui.Gui;
|
||||||
import net.minecraft.client.gui.ScaledResolution;
|
import net.minecraft.client.gui.ScaledResolution;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
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;
|
||||||
|
@ -30,6 +31,7 @@ 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;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
|
@ -97,12 +99,19 @@ public class ClientEvents {
|
||||||
public void onClientTick(ClientTickEvent event) {
|
public void onClientTick(ClientTickEvent event) {
|
||||||
if (event.phase == Phase.END) {
|
if (event.phase == Phase.END) {
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":updateParticles");
|
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":updateParticles");
|
||||||
if (!mc.isGamePaused())
|
if (!mc.isGamePaused())
|
||||||
ParticleHandler.updateParticles();
|
ParticleHandler.updateParticles();
|
||||||
if (mc.world == null)
|
|
||||||
ParticleHandler.clearParticles();
|
|
||||||
mc.profiler.endSection();
|
mc.profiler.endSection();
|
||||||
|
|
||||||
|
if (mc.world == null) {
|
||||||
|
ParticleHandler.clearParticles();
|
||||||
|
if (!ItemRangeVisualizer.VISUALIZED_BLOCKS.isEmpty())
|
||||||
|
ItemRangeVisualizer.VISUALIZED_BLOCKS.clear();
|
||||||
|
if (!ItemRangeVisualizer.VISUALIZED_ENTITIES.isEmpty())
|
||||||
|
ItemRangeVisualizer.VISUALIZED_ENTITIES.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,21 +166,19 @@ public class ClientEvents {
|
||||||
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);
|
||||||
for (BlockPos pos : ItemRangeVisualizer.VISUALIZED_POSITIONS) {
|
for (BlockPos pos : ItemRangeVisualizer.VISUALIZED_BLOCKS) {
|
||||||
if (!mc.world.isBlockLoaded(pos))
|
if (!mc.world.isBlockLoaded(pos))
|
||||||
continue;
|
continue;
|
||||||
IBlockState state = mc.world.getBlockState(pos);
|
IBlockState state = mc.world.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (!(block instanceof IVisualizableBlock))
|
if (!(block instanceof IVisualizable))
|
||||||
continue;
|
continue;
|
||||||
IVisualizableBlock visualize = (IVisualizableBlock) block;
|
this.renderVisualize((IVisualizable) block, mc.world, pos);
|
||||||
AxisAlignedBB box = visualize.getVisualizationBounds(mc.world, pos);
|
}
|
||||||
if (box == null)
|
for (Entity entity : ItemRangeVisualizer.VISUALIZED_ENTITIES) {
|
||||||
|
if (entity.isDead || !(entity instanceof IVisualizable))
|
||||||
continue;
|
continue;
|
||||||
box = box.grow(0.05F);
|
this.renderVisualize((IVisualizable) entity, mc.world, entity.getPosition());
|
||||||
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.glEnd();
|
||||||
GL11.glPopAttrib();
|
GL11.glPopAttrib();
|
||||||
|
@ -184,6 +191,16 @@ public class ClientEvents {
|
||||||
mc.profiler.endSection();
|
mc.profiler.endSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void renderVisualize(IVisualizable visualize, World world, BlockPos pos) {
|
||||||
|
AxisAlignedBB box = visualize.getVisualizationBounds(world, pos);
|
||||||
|
if (box == null)
|
||||||
|
return;
|
||||||
|
box = box.grow(0.05F);
|
||||||
|
int color = visualize.getVisualizationColor(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);
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onOverlayRender(RenderGameOverlayEvent.Post event) {
|
public void onOverlayRender(RenderGameOverlayEvent.Post event) {
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem {
|
||||||
EntityEffectInhibitor entity = new EntityEffectInhibitor(worldIn);
|
EntityEffectInhibitor entity = new EntityEffectInhibitor(worldIn);
|
||||||
entity.setInhibitedEffect(effect);
|
entity.setInhibitedEffect(effect);
|
||||||
entity.setColor(NaturesAuraAPI.EFFECT_POWDERS.get(effect));
|
entity.setColor(NaturesAuraAPI.EFFECT_POWDERS.get(effect));
|
||||||
entity.amount = stack.getCount();
|
entity.setAmount(stack.getCount());
|
||||||
entity.setPosition(pos.getX() + hitX, pos.getY() + hitY + 1, pos.getZ() + hitZ);
|
entity.setPosition(pos.getX() + hitX, pos.getY() + hitY + 1, pos.getZ() + hitZ);
|
||||||
worldIn.spawnEntity(entity);
|
worldIn.spawnEntity(entity);
|
||||||
stack.setCount(0);
|
stack.setCount(0);
|
||||||
|
|
|
@ -1,38 +1,64 @@
|
||||||
package de.ellpeck.naturesaura.items;
|
package de.ellpeck.naturesaura.items;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.render.IVisualizableBlock;
|
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
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.event.entity.player.PlayerInteractEvent;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ItemRangeVisualizer extends ItemImpl {
|
public class ItemRangeVisualizer extends ItemImpl {
|
||||||
|
|
||||||
public static final Set<BlockPos> VISUALIZED_POSITIONS = new HashSet<>();
|
public static final Set<BlockPos> VISUALIZED_BLOCKS = new HashSet<>();
|
||||||
|
public static final Set<Entity> VISUALIZED_ENTITIES = new HashSet<>();
|
||||||
|
|
||||||
public ItemRangeVisualizer() {
|
public ItemRangeVisualizer() {
|
||||||
super("range_visualizer");
|
super("range_visualizer");
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||||
IBlockState state = worldIn.getBlockState(pos);
|
IBlockState state = worldIn.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof IVisualizableBlock) {
|
if (block instanceof IVisualizable) {
|
||||||
if (worldIn.isRemote)
|
if (worldIn.isRemote)
|
||||||
if (VISUALIZED_POSITIONS.contains(pos))
|
if (VISUALIZED_BLOCKS.contains(pos))
|
||||||
VISUALIZED_POSITIONS.remove(pos);
|
VISUALIZED_BLOCKS.remove(pos);
|
||||||
else
|
else
|
||||||
VISUALIZED_POSITIONS.add(pos);
|
VISUALIZED_BLOCKS.add(pos);
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
return EnumActionResult.PASS;
|
return EnumActionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onInteract(PlayerInteractEvent.EntityInteractSpecific event) {
|
||||||
|
ItemStack stack = event.getItemStack();
|
||||||
|
if (stack.isEmpty() || stack.getItem() != this)
|
||||||
|
return;
|
||||||
|
Entity entity = event.getTarget();
|
||||||
|
if (entity instanceof IVisualizable) {
|
||||||
|
if (entity.world.isRemote) {
|
||||||
|
if (VISUALIZED_ENTITIES.contains(entity))
|
||||||
|
VISUALIZED_ENTITIES.remove(entity);
|
||||||
|
else
|
||||||
|
VISUALIZED_ENTITIES.add(entity);
|
||||||
|
}
|
||||||
|
event.getEntityPlayer().swingArm(event.getHand());
|
||||||
|
event.setCancellationResult(EnumActionResult.SUCCESS);
|
||||||
|
event.setCanceled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue