mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
added the eye
This commit is contained in:
parent
e068c48ca2
commit
d7df934151
13 changed files with 165 additions and 17 deletions
|
@ -1,6 +1,7 @@
|
||||||
package de.ellpeck.naturesaura;
|
package de.ellpeck.naturesaura;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||||
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.proxy.IProxy;
|
import de.ellpeck.naturesaura.proxy.IProxy;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
|
@ -32,13 +33,14 @@ public final class NaturesAura {
|
||||||
public static final CreativeTabs CREATIVE_TAB = new CreativeTabs(MOD_ID) {
|
public static final CreativeTabs CREATIVE_TAB = new CreativeTabs(MOD_ID) {
|
||||||
@Override
|
@Override
|
||||||
public ItemStack createIcon() {
|
public ItemStack createIcon() {
|
||||||
return new ItemStack(Items.BEETROOT);
|
return new ItemStack(ModItems.EYE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
new ModBlocks();
|
new ModBlocks();
|
||||||
|
new ModItems();
|
||||||
PacketHandler.init();
|
PacketHandler.init();
|
||||||
ModRegistry.preInit(event);
|
ModRegistry.preInit(event);
|
||||||
proxy.preInit(event);
|
proxy.preInit(event);
|
||||||
|
|
|
@ -3,4 +3,6 @@ package de.ellpeck.naturesaura.aura;
|
||||||
public interface IAuraContainerProvider {
|
public interface IAuraContainerProvider {
|
||||||
|
|
||||||
IAuraContainer container();
|
IAuraContainer container();
|
||||||
|
|
||||||
|
boolean isArtificial();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,11 @@ public class TileEntityAncientLeaves extends TileEntityImpl implements IAuraCont
|
||||||
return this.container;
|
return this.container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isArtificial() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(NBTTagCompound compound, boolean syncing) {
|
public void writeNBT(NBTTagCompound compound, boolean syncing) {
|
||||||
super.writeNBT(compound, syncing);
|
super.writeNBT(compound, syncing);
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable,
|
||||||
new BlockPos(-1, -1, -1),
|
new BlockPos(-1, -1, -1),
|
||||||
new BlockPos(1, -1, -1)
|
new BlockPos(1, -1, -1)
|
||||||
};
|
};
|
||||||
private static final BlockPos[] GRASS_POSITIONS = new BlockPos[]{
|
private static final BlockPos[] WOOD_POSITIONS = new BlockPos[]{
|
||||||
new BlockPos(-1, -1, 0),
|
new BlockPos(-1, -1, 0),
|
||||||
new BlockPos(1, -1, 0),
|
new BlockPos(1, -1, 0),
|
||||||
new BlockPos(0, -1, -1),
|
new BlockPos(0, -1, -1),
|
||||||
|
@ -101,10 +101,10 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable,
|
||||||
|
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.world.getTotalWorldTime() % 40 == 0) {
|
if (this.world.getTotalWorldTime() % 40 == 0) {
|
||||||
boolean fine = this.check(BRICK_POSITIONS, Blocks.STONEBRICK.getDefaultState())
|
boolean fine = this.check(BRICK_POSITIONS, Blocks.STONEBRICK.getDefaultState(), false)
|
||||||
&& this.check(MOSSY_POSITIONS, Blocks.STONEBRICK.getDefaultState().withProperty(BlockStoneBrick.VARIANT, EnumType.MOSSY))
|
&& this.check(MOSSY_POSITIONS, Blocks.STONEBRICK.getDefaultState().withProperty(BlockStoneBrick.VARIANT, EnumType.MOSSY), false)
|
||||||
&& this.check(CHISELED_POSITIONS, Blocks.STONEBRICK.getDefaultState().withProperty(BlockStoneBrick.VARIANT, EnumType.CHISELED))
|
&& this.check(CHISELED_POSITIONS, Blocks.STONEBRICK.getDefaultState().withProperty(BlockStoneBrick.VARIANT, EnumType.CHISELED), false)
|
||||||
&& this.check(GRASS_POSITIONS, Blocks.GRASS.getDefaultState());
|
&& this.check(WOOD_POSITIONS, Blocks.PLANKS.getDefaultState(), true);
|
||||||
if (fine != this.structureFine) {
|
if (fine != this.structureFine) {
|
||||||
this.structureFine = fine;
|
this.structureFine = fine;
|
||||||
this.sendToClients();
|
this.sendToClients();
|
||||||
|
@ -173,9 +173,10 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean check(BlockPos[] positions, IBlockState state) {
|
private boolean check(BlockPos[] positions, IBlockState state, boolean blockOnly) {
|
||||||
for (BlockPos offset : positions) {
|
for (BlockPos offset : positions) {
|
||||||
if (this.world.getBlockState(this.pos.add(offset)) != state) {
|
IBlockState world = this.world.getBlockState(this.pos.add(offset));
|
||||||
|
if (blockOnly ? world.getBlock() != state.getBlock() : world != state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,4 +201,9 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable,
|
||||||
public IAuraContainer container() {
|
public IAuraContainer container() {
|
||||||
return this.container;
|
return this.container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isArtificial() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
package de.ellpeck.naturesaura.events;
|
package de.ellpeck.naturesaura.events;
|
||||||
|
|
||||||
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
import de.ellpeck.naturesaura.aura.IAuraContainer;
|
||||||
|
import de.ellpeck.naturesaura.aura.IAuraContainerProvider;
|
||||||
|
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.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.ScaledResolution;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
@ -48,4 +57,45 @@ public class ClientEvents {
|
||||||
ParticleHandler.clearParticles();
|
ParticleHandler.clearParticles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onOverlayRender(RenderGameOverlayEvent.Post event) {
|
||||||
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
if (event.getType() == ElementType.ALL && mc.currentScreen == null) {
|
||||||
|
ScaledResolution res = event.getResolution();
|
||||||
|
if (mc.player != null) {
|
||||||
|
ItemStack stack = mc.player.getHeldItemMainhand();
|
||||||
|
if (!stack.isEmpty() && stack.getItem() == ModItems.EYE) {
|
||||||
|
int maxAura = 0;
|
||||||
|
int aura = 0;
|
||||||
|
for (TileEntity tile : Helper.getTileEntitiesInArea(mc.world, mc.player.getPosition(), 15)) {
|
||||||
|
if (tile instanceof IAuraContainerProvider) {
|
||||||
|
IAuraContainerProvider provider = (IAuraContainerProvider) tile;
|
||||||
|
if (!provider.isArtificial()) {
|
||||||
|
IAuraContainer container = provider.container();
|
||||||
|
maxAura += container.getMaxAura();
|
||||||
|
aura += container.getStoredAura();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String area = "Aura in the area: " + aura + " / " + maxAura;
|
||||||
|
mc.fontRenderer.drawString(area, 5, 5, 0xFFFFFF, true);
|
||||||
|
|
||||||
|
if (mc.objectMouseOver != null) {
|
||||||
|
BlockPos pos = mc.objectMouseOver.getBlockPos();
|
||||||
|
if (pos != null) {
|
||||||
|
TileEntity tile = mc.world.getTileEntity(pos);
|
||||||
|
if (tile instanceof IAuraContainerProvider) {
|
||||||
|
IAuraContainer container = ((IAuraContainerProvider) tile).container();
|
||||||
|
String s = "Aura stored: " + container.getStoredAura() + " / " + container.getMaxAura();
|
||||||
|
mc.fontRenderer.drawString(s,
|
||||||
|
(res.getScaledWidth() - mc.fontRenderer.getStringWidth(s)) / 2, res.getScaledHeight() / 4 * 3,
|
||||||
|
container.getAuraColor(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
8
src/main/java/de/ellpeck/naturesaura/items/ItemEye.java
Normal file
8
src/main/java/de/ellpeck/naturesaura/items/ItemEye.java
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package de.ellpeck.naturesaura.items;
|
||||||
|
|
||||||
|
public class ItemEye extends ItemImpl {
|
||||||
|
|
||||||
|
public ItemEye() {
|
||||||
|
super("eye");
|
||||||
|
}
|
||||||
|
}
|
55
src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java
Normal file
55
src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
package de.ellpeck.naturesaura.items;
|
||||||
|
|
||||||
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
|
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||||
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
|
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||||
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ItemImpl extends Item implements IModItem, IModelProvider {
|
||||||
|
|
||||||
|
private final String baseName;
|
||||||
|
|
||||||
|
public ItemImpl(String baseName) {
|
||||||
|
this.baseName = baseName;
|
||||||
|
ModRegistry.addItemOrBlock(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBaseName() {
|
||||||
|
return this.baseName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldAddCreative() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPreInit(FMLPreInitializationEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit(FMLInitializationEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPostInit(FMLPostInitializationEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<ItemStack, ModelVariant> getModelLocations() {
|
||||||
|
return Collections.singletonMap(new ItemStack(this), new ModelVariant(new ResourceLocation(NaturesAura.MOD_ID, this.getBaseName()), "inventory"));
|
||||||
|
}
|
||||||
|
}
|
8
src/main/java/de/ellpeck/naturesaura/items/ModItems.java
Normal file
8
src/main/java/de/ellpeck/naturesaura/items/ModItems.java
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package de.ellpeck.naturesaura.items;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
|
public final class ModItems {
|
||||||
|
|
||||||
|
public static final Item EYE = new ItemEye();
|
||||||
|
}
|
|
@ -15,26 +15,31 @@ import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public final class ParticleHandler {
|
public final class ParticleHandler {
|
||||||
|
|
||||||
private static final List<Particle> PARTICLES = new ArrayList<>();
|
private static final List<Particle> PARTICLES = new ArrayList<>();
|
||||||
|
|
||||||
public static void spawnParticle(Particle particle, double x, double y, double z, int range) {
|
public static void spawnParticle(Supplier<Particle> particle, double x, double y, double z, int range) {
|
||||||
if (particle != null && Minecraft.getMinecraft().player.getDistanceSq(x, y, z) <= range * range) {
|
if (Minecraft.getMinecraft().player.getDistanceSq(x, y, z) <= range * range) {
|
||||||
PARTICLES.add(particle);
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
int setting = mc.gameSettings.particleSetting;
|
||||||
|
if (setting == 0 ||
|
||||||
|
setting == 1 && mc.world.rand.nextInt(3) == 0 ||
|
||||||
|
setting == 2 && mc.world.rand.nextInt(10) == 0) {
|
||||||
|
PARTICLES.add(particle.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateParticles() {
|
public static void updateParticles() {
|
||||||
for (int i = 0; i < PARTICLES.size(); i++) {
|
for (int i = PARTICLES.size() - 1; i >= 0; i--) {
|
||||||
Particle particle = PARTICLES.get(i);
|
Particle particle = PARTICLES.get(i);
|
||||||
particle.onUpdate();
|
particle.onUpdate();
|
||||||
|
|
||||||
if (!particle.isAlive()) {
|
if (!particle.isAlive()) {
|
||||||
PARTICLES.remove(i);
|
PARTICLES.remove(i);
|
||||||
i--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,8 +63,7 @@ public class ClientProxy implements IProxy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawnMagicParticle(World world, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) {
|
public void spawnMagicParticle(World world, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) {
|
||||||
ParticleMagic particle = new ParticleMagic(world, posX, posY, posZ, motionX, motionY, motionZ, color, scale, maxAge, gravity, collision, fade);
|
ParticleHandler.spawnParticle(() -> new ParticleMagic(world, posX, posY, posZ, motionX, motionY, motionZ, color, scale, maxAge, gravity, collision, fade), posX, posY, posZ, 32);
|
||||||
ParticleHandler.spawnParticle(particle, posX, posY, posZ, 32);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,3 +6,5 @@ tile.naturesaura.ancient_leaves.name=Ancient Leaves
|
||||||
tile.naturesaura.ancient_sapling.name=Ancient Sapling
|
tile.naturesaura.ancient_sapling.name=Ancient Sapling
|
||||||
tile.naturesaura.nature_altar.name=Natural Altar
|
tile.naturesaura.nature_altar.name=Natural Altar
|
||||||
tile.naturesaura.decayed_leaves.name=Decayed Leaves
|
tile.naturesaura.decayed_leaves.name=Decayed Leaves
|
||||||
|
|
||||||
|
item.naturesaura.eye.name=Environmental Eye
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "naturesaura:items/eye"
|
||||||
|
}
|
||||||
|
}
|
BIN
src/main/resources/assets/naturesaura/textures/items/eye.png
Normal file
BIN
src/main/resources/assets/naturesaura/textures/items/eye.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 662 B |
Loading…
Reference in a new issue