mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 11:53:29 +01:00
added aura cache
This commit is contained in:
parent
677418fdce
commit
f3906141a1
32 changed files with 567 additions and 135 deletions
|
@ -1,5 +1,7 @@
|
|||
package de.ellpeck.naturesaura;
|
||||
|
||||
import de.ellpeck.naturesaura.aura.Capabilities;
|
||||
import de.ellpeck.naturesaura.aura.IAuraRecharge;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -9,14 +11,19 @@ import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -122,4 +129,27 @@ public final class Helper {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ICapabilityProvider makeRechargeProvider(ItemStack stack) {
|
||||
return new ICapabilityProvider() {
|
||||
private final IAuraRecharge recharge = () -> {
|
||||
if (stack.getItemDamage() > 0) {
|
||||
stack.setItemDamage(stack.getItemDamage() - 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == Capabilities.auraRecharge;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
return capability == Capabilities.auraRecharge ? (T) this.recharge : null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package de.ellpeck.naturesaura;
|
||||
|
||||
import de.ellpeck.naturesaura.aura.Capabilities.CapabilityAuraContainer;
|
||||
import de.ellpeck.naturesaura.aura.Capabilities.CapabilityAuraRecharge;
|
||||
import de.ellpeck.naturesaura.aura.IAuraContainer;
|
||||
import de.ellpeck.naturesaura.aura.IAuraRecharge;
|
||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import de.ellpeck.naturesaura.events.TerrainGenEvents;
|
||||
|
@ -11,10 +15,13 @@ import de.ellpeck.naturesaura.reg.ModRegistry;
|
|||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.*;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
@ -40,6 +47,9 @@ public final class NaturesAura {
|
|||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
CapabilityManager.INSTANCE.register(IAuraContainer.class, new CapabilityAuraContainer(), () -> null);
|
||||
CapabilityManager.INSTANCE.register(IAuraRecharge.class, new CapabilityAuraRecharge(), () -> null);
|
||||
|
||||
new ModBlocks();
|
||||
new ModItems();
|
||||
|
||||
|
|
|
@ -5,10 +5,12 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
public class BasicAuraContainer implements IAuraContainer {
|
||||
|
||||
protected final int maxAura;
|
||||
protected final boolean artificial;
|
||||
protected int aura;
|
||||
|
||||
public BasicAuraContainer(int maxAura) {
|
||||
public BasicAuraContainer(int maxAura, boolean artificial) {
|
||||
this.maxAura = maxAura;
|
||||
this.artificial = artificial;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,6 +46,11 @@ public class BasicAuraContainer implements IAuraContainer {
|
|||
return 0x1E891E;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isArtificial() {
|
||||
return this.artificial;
|
||||
}
|
||||
|
||||
public void writeNBT(NBTTagCompound compound) {
|
||||
compound.setInteger("aura", this.aura);
|
||||
}
|
||||
|
|
45
src/main/java/de/ellpeck/naturesaura/aura/Capabilities.java
Normal file
45
src/main/java/de/ellpeck/naturesaura/aura/Capabilities.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package de.ellpeck.naturesaura.aura;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.Capability.IStorage;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class Capabilities {
|
||||
|
||||
@CapabilityInject(IAuraContainer.class)
|
||||
public static Capability<IAuraContainer> auraContainer;
|
||||
|
||||
@CapabilityInject(IAuraRecharge.class)
|
||||
public static Capability<IAuraRecharge> auraRecharge;
|
||||
|
||||
public static class CapabilityAuraContainer implements IStorage<IAuraContainer> {
|
||||
|
||||
@Override
|
||||
public NBTBase writeNBT(Capability<IAuraContainer> capability, IAuraContainer instance, EnumFacing side) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(Capability<IAuraContainer> capability, IAuraContainer instance, EnumFacing side, NBTBase nbt) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static class CapabilityAuraRecharge implements IStorage<IAuraRecharge>{
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public NBTBase writeNBT(Capability<IAuraRecharge> capability, IAuraRecharge instance, EnumFacing side) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(Capability<IAuraRecharge> capability, IAuraRecharge instance, EnumFacing side, NBTBase nbt) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ package de.ellpeck.naturesaura.aura;
|
|||
|
||||
public class FiniteAuraContainer extends BasicAuraContainer {
|
||||
|
||||
public FiniteAuraContainer(int aura) {
|
||||
super(aura);
|
||||
public FiniteAuraContainer(int aura, boolean artificial) {
|
||||
super(aura, artificial);
|
||||
this.aura = aura;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,4 +10,6 @@ public interface IAuraContainer {
|
|||
int getMaxAura();
|
||||
|
||||
int getAuraColor();
|
||||
|
||||
boolean isArtificial();
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package de.ellpeck.naturesaura.aura;
|
||||
|
||||
public interface IAuraContainerProvider {
|
||||
|
||||
IAuraContainer container();
|
||||
|
||||
boolean isArtificial();
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package de.ellpeck.naturesaura.aura;
|
||||
|
||||
public interface IAuraRecharge {
|
||||
|
||||
boolean recharge();
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package de.ellpeck.naturesaura.aura;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ItemAuraContainer implements IAuraContainer {
|
||||
|
||||
protected final ItemStack stack;
|
||||
protected final int maxAura;
|
||||
protected final boolean artificial;
|
||||
|
||||
public ItemAuraContainer(ItemStack stack, int maxAura, boolean artificial) {
|
||||
this.stack = stack;
|
||||
this.maxAura = maxAura;
|
||||
this.artificial = artificial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int storeAura(int amountToStore, boolean simulate) {
|
||||
int aura = this.getStoredAura();
|
||||
int actual = Math.min(amountToStore, this.getMaxAura() - aura);
|
||||
if (!simulate) {
|
||||
this.setAura(aura + actual);
|
||||
}
|
||||
return actual;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drainAura(int amountToDrain, boolean simulate) {
|
||||
int aura = this.getStoredAura();
|
||||
int actual = Math.min(amountToDrain, aura);
|
||||
if (!simulate) {
|
||||
this.setAura(aura - actual);
|
||||
}
|
||||
return actual;
|
||||
}
|
||||
|
||||
private void setAura(int amount) {
|
||||
if (!this.stack.hasTagCompound()) {
|
||||
this.stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
this.stack.getTagCompound().setInteger("aura", amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredAura() {
|
||||
if (this.stack.hasTagCompound()) {
|
||||
return this.stack.getTagCompound().getInteger("aura");
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxAura() {
|
||||
return this.maxAura;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAuraColor() {
|
||||
return 0x42a6bc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isArtificial() {
|
||||
return this.artificial;
|
||||
}
|
||||
}
|
|
@ -27,7 +27,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockAncientLeaves extends BlockLeaves implements
|
||||
|
@ -132,7 +131,7 @@ public class BlockAncientLeaves extends BlockLeaves implements
|
|||
if (rand.nextFloat() >= 0.95F && !worldIn.getBlockState(pos.down()).isFullBlock()) {
|
||||
TileEntity tile = worldIn.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityAncientLeaves) {
|
||||
if (((TileEntityAncientLeaves) tile).container().getStoredAura() > 0) {
|
||||
if (((TileEntityAncientLeaves) tile).getAuraContainer(null).getStoredAura() > 0) {
|
||||
NaturesAura.proxy.spawnMagicParticle(worldIn,
|
||||
pos.getX() + rand.nextDouble(), pos.getY(), pos.getZ() + rand.nextDouble(),
|
||||
0F, 0F, 0F, 0xc46df9,
|
||||
|
@ -156,7 +155,7 @@ public class BlockAncientLeaves extends BlockLeaves implements
|
|||
if (!worldIn.isRemote) {
|
||||
TileEntity tile = worldIn.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityAncientLeaves) {
|
||||
if (((TileEntityAncientLeaves) tile).container().getStoredAura() <= 0) {
|
||||
if (((TileEntityAncientLeaves) tile).getAuraContainer(null).getStoredAura() <= 0) {
|
||||
worldIn.setBlockState(pos, ModBlocks.DECAYED_LEAVES.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,4 +16,5 @@ public final class ModBlocks {
|
|||
public static final Block GOLDEN_LEAVES = new BlockGoldenLeaves();
|
||||
public static final Block GOLD_POWDER = new BlockGoldPowder();
|
||||
public static final Block WOOD_STAND = new BlockWoodStand();
|
||||
public static final Block INFUSED_STONE = new BlockImpl("infused_stone", Material.ROCK).setSoundType(SoundType.STONE).setHardness(1.75F);
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
|
||||
import de.ellpeck.naturesaura.aura.FiniteAuraContainer;
|
||||
import de.ellpeck.naturesaura.aura.IAuraContainer;
|
||||
import de.ellpeck.naturesaura.aura.IAuraContainerProvider;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public class TileEntityAncientLeaves extends TileEntityImpl implements IAuraContainerProvider {
|
||||
public class TileEntityAncientLeaves extends TileEntityImpl {
|
||||
|
||||
private final FiniteAuraContainer container = new FiniteAuraContainer(20) {
|
||||
private final FiniteAuraContainer container = new FiniteAuraContainer(20, false) {
|
||||
@Override
|
||||
public int getAuraColor() {
|
||||
return 0xc46df9;
|
||||
|
@ -24,15 +24,10 @@ public class TileEntityAncientLeaves extends TileEntityImpl implements IAuraCont
|
|||
};
|
||||
|
||||
@Override
|
||||
public IAuraContainer container() {
|
||||
public IAuraContainer getAuraContainer(EnumFacing facing) {
|
||||
return this.container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isArtificial() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound compound, boolean syncing) {
|
||||
super.writeNBT(compound, syncing);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import de.ellpeck.naturesaura.aura.Capabilities;
|
||||
import de.ellpeck.naturesaura.aura.IAuraContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
|
@ -12,7 +14,6 @@ import net.minecraft.world.World;
|
|||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -79,10 +80,16 @@ public class TileEntityImpl extends TileEntity {
|
|||
return null;
|
||||
}
|
||||
|
||||
public IAuraContainer getAuraContainer(EnumFacing facing) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return this.getItemHandler(facing) != null;
|
||||
} else if (capability == Capabilities.auraContainer) {
|
||||
return this.getAuraContainer(facing) != null;
|
||||
} else {
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
|
@ -93,6 +100,8 @@ public class TileEntityImpl extends TileEntity {
|
|||
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return (T) this.getItemHandler(facing);
|
||||
} else if (capability == Capabilities.auraContainer) {
|
||||
return (T) this.getAuraContainer(facing);
|
||||
} else {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.aura.BasicAuraContainer;
|
||||
import de.ellpeck.naturesaura.aura.Capabilities;
|
||||
import de.ellpeck.naturesaura.aura.IAuraContainer;
|
||||
import de.ellpeck.naturesaura.aura.IAuraContainerProvider;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
|
@ -26,7 +26,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class TileEntityNatureAltar extends TileEntityImpl implements ITickable, IAuraContainerProvider {
|
||||
public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
||||
|
||||
private static final BlockPos[] BRICK_POSITIONS = new BlockPos[]{
|
||||
new BlockPos(-2, -1, 0),
|
||||
|
@ -101,7 +101,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable,
|
|||
|
||||
@Override
|
||||
protected boolean canInsert(ItemStack stack, int slot) {
|
||||
return AltarRecipe.forInput(stack) != null;
|
||||
return AltarRecipe.forInput(stack) != null || stack.hasCapability(Capabilities.auraContainer, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -110,8 +110,8 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable,
|
|||
}
|
||||
};
|
||||
|
||||
private final List<IAuraContainerProvider> cachedProviders = new ArrayList<>();
|
||||
private final BasicAuraContainer container = new BasicAuraContainer(5000);
|
||||
private final List<TileEntity> cachedProviders = new ArrayList<>();
|
||||
private final BasicAuraContainer container = new BasicAuraContainer(5000, true);
|
||||
public boolean structureFine;
|
||||
|
||||
private AltarRecipe currentRecipe;
|
||||
|
@ -139,25 +139,26 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable,
|
|||
if (this.world.getTotalWorldTime() % 100 == 0) {
|
||||
this.cachedProviders.clear();
|
||||
for (TileEntity tile : Helper.getTileEntitiesInArea(this.world, this.pos, 15)) {
|
||||
if (tile instanceof IAuraContainerProvider && tile != this) {
|
||||
this.cachedProviders.add((IAuraContainerProvider) tile);
|
||||
if (tile.hasCapability(Capabilities.auraContainer, null) && tile != this) {
|
||||
this.cachedProviders.add(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.cachedProviders.isEmpty()) {
|
||||
int index = rand.nextInt(this.cachedProviders.size());
|
||||
IAuraContainerProvider provider = this.cachedProviders.get(index);
|
||||
if (!((TileEntity) provider).isInvalid()) {
|
||||
int stored = this.container.storeAura(provider.container().drainAura(5, true), false);
|
||||
TileEntity provider = this.cachedProviders.get(index);
|
||||
if (!provider.isInvalid() && provider.hasCapability(Capabilities.auraContainer, null)) {
|
||||
IAuraContainer container = provider.getCapability(Capabilities.auraContainer, null);
|
||||
int stored = this.container.storeAura(container.drainAura(5, true), false);
|
||||
if (stored > 0) {
|
||||
provider.container().drainAura(stored, false);
|
||||
container.drainAura(stored, false);
|
||||
|
||||
BlockPos pos = ((TileEntity) provider).getPos();
|
||||
BlockPos pos = provider.getPos();
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
|
||||
pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F,
|
||||
this.pos.getX() + 0.5F, this.pos.getY() + 0.5F, this.pos.getZ() + 0.5F,
|
||||
rand.nextFloat() * 0.05F + 0.05F, provider.container().getAuraColor(), rand.nextFloat() * 1F + 1F
|
||||
rand.nextFloat() * 0.05F + 0.05F, container.getAuraColor(), rand.nextFloat() * 1F + 1F
|
||||
));
|
||||
}
|
||||
} else {
|
||||
|
@ -166,6 +167,20 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable,
|
|||
}
|
||||
|
||||
ItemStack stack = this.items.getStackInSlot(0);
|
||||
if (!stack.isEmpty() && stack.hasCapability(Capabilities.auraContainer, null)) {
|
||||
IAuraContainer container = stack.getCapability(Capabilities.auraContainer, null);
|
||||
int theoreticalDrain = this.container.drainAura(10, true);
|
||||
if (theoreticalDrain > 0) {
|
||||
int stored = container.storeAura(theoreticalDrain, false);
|
||||
if (stored > 0) {
|
||||
this.container.drainAura(stored, false);
|
||||
|
||||
if (this.world.getTotalWorldTime() % 4 == 0) {
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.currentRecipe == null) {
|
||||
if (!stack.isEmpty()) {
|
||||
this.currentRecipe = AltarRecipe.forInput(stack);
|
||||
|
@ -192,6 +207,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.world.getTotalWorldTime() % 10 == 0 && this.lastAura != this.container.getStoredAura()) {
|
||||
this.lastAura = this.container.getStoredAura();
|
||||
|
@ -262,15 +278,10 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public IAuraContainer container() {
|
||||
public IAuraContainer getAuraContainer(EnumFacing facing) {
|
||||
return this.container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isArtificial() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandlerModifiable getItemHandler(EnumFacing facing) {
|
||||
return this.items;
|
||||
|
|
|
@ -20,11 +20,19 @@ import javax.annotation.Nullable;
|
|||
public class BaublesCompat {
|
||||
|
||||
private final IBauble eye = stack -> BaubleType.CHARM;
|
||||
private final IBauble cache = stack -> BaubleType.BELT;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) {
|
||||
Item item = event.getObject().getItem();
|
||||
if (item == ModItems.EYE) {
|
||||
this.addCap(event, this.eye);
|
||||
} else if (item == ModItems.AURA_CACHE) {
|
||||
this.addCap(event, this.cache);
|
||||
}
|
||||
}
|
||||
|
||||
private void addCap(AttachCapabilitiesEvent<ItemStack> event, IBauble type) {
|
||||
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "bauble"), new ICapabilityProvider() {
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
|
@ -34,9 +42,8 @@ public class BaublesCompat {
|
|||
@Nullable
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
return capability == BaublesCapabilities.CAPABILITY_ITEM_BAUBLE ? (T) BaublesCompat.this.eye : null;
|
||||
return capability == BaublesCapabilities.CAPABILITY_ITEM_BAUBLE ? (T) type : null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,9 @@ package de.ellpeck.naturesaura.events;
|
|||
import baubles.api.BaublesApi;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.aura.Capabilities;
|
||||
import de.ellpeck.naturesaura.aura.IAuraContainer;
|
||||
import de.ellpeck.naturesaura.aura.IAuraContainerProvider;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.particles.ParticleHandler;
|
||||
|
@ -35,7 +36,7 @@ import java.util.List;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class ClientEvents {
|
||||
|
||||
private static final ResourceLocation OVERLAYS = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/overlays.png");
|
||||
public static final ResourceLocation OVERLAYS = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/overlays.png");
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDebugRender(RenderGameOverlayEvent.Text event) {
|
||||
|
@ -71,20 +72,20 @@ public class ClientEvents {
|
|||
@SubscribeEvent
|
||||
public void onOverlayRender(RenderGameOverlayEvent.Post event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (event.getType() == ElementType.ALL && mc.currentScreen == null) {
|
||||
if (event.getType() == ElementType.ALL) {
|
||||
ScaledResolution res = event.getResolution();
|
||||
if (mc.player != null) {
|
||||
ItemStack stack = mc.player.getHeldItemMainhand();
|
||||
if (mc.currentScreen == null) {
|
||||
if (!stack.isEmpty() && stack.getItem() == ModItems.EYE || Compat.baubles && BaublesApi.isBaubleEquipped(mc.player, ModItems.EYE) >= 0) {
|
||||
int maxAura = 0;
|
||||
int aura = 0;
|
||||
int total = 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();
|
||||
if (tile.hasCapability(Capabilities.auraContainer, null)) {
|
||||
IAuraContainer container = tile.getCapability(Capabilities.auraContainer, null);
|
||||
if (!container.isArtificial()) {
|
||||
maxAura += container.getMaxAura();
|
||||
aura += container.getStoredAura();
|
||||
total++;
|
||||
|
@ -97,42 +98,37 @@ public class ClientEvents {
|
|||
|
||||
GlStateManager.color(0.8F, 0.25F, 0.25F);
|
||||
float totalPercentage = total / 1500F;
|
||||
int tHeight = MathHelper.ceil(Math.min(1F, totalPercentage) * 75);
|
||||
if (tHeight < 75)
|
||||
Gui.drawModalRectWithCustomSizedTexture(3, 17, 6, 12, 6, 75 - tHeight, 256, 256);
|
||||
int tHeight = MathHelper.ceil(Math.min(1F, totalPercentage) * 50);
|
||||
if (tHeight < 50)
|
||||
Gui.drawModalRectWithCustomSizedTexture(3, 17, 6, 12, 6, 50 - tHeight, 256, 256);
|
||||
if (tHeight > 0)
|
||||
Gui.drawModalRectWithCustomSizedTexture(3, 17 + 75 - tHeight, 0, 12 + 75 - tHeight, 6, tHeight, 256, 256);
|
||||
Gui.drawModalRectWithCustomSizedTexture(3, 17 + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256);
|
||||
|
||||
GlStateManager.color(0.25F, 0.8F, 0.25F);
|
||||
int aHeight = MathHelper.ceil(aura / (float) maxAura * 75);
|
||||
if (aHeight < 75)
|
||||
Gui.drawModalRectWithCustomSizedTexture(12, 17, 6, 12, 6, 75 - aHeight, 256, 256);
|
||||
int aHeight = MathHelper.ceil(aura / (float) maxAura * 50);
|
||||
if (aHeight < 50)
|
||||
Gui.drawModalRectWithCustomSizedTexture(12, 17, 6, 12, 6, 50 - aHeight, 256, 256);
|
||||
if (aHeight > 0)
|
||||
Gui.drawModalRectWithCustomSizedTexture(12, 17 + 75 - aHeight, 0, 12 + 75 - aHeight, 6, aHeight, 256, 256);
|
||||
Gui.drawModalRectWithCustomSizedTexture(12, 17 + 50 - aHeight, 0, 12 + 50 - aHeight, 6, aHeight, 256, 256);
|
||||
|
||||
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();
|
||||
|
||||
int color = container.getAuraColor();
|
||||
GlStateManager.color((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
||||
|
||||
int x = res.getScaledWidth() / 2 - 50;
|
||||
int y = res.getScaledHeight() / 2 + 25;
|
||||
int width = MathHelper.ceil(container.getStoredAura() / (float) container.getMaxAura() * 100F);
|
||||
|
||||
if (width < 100)
|
||||
Gui.drawModalRectWithCustomSizedTexture(x + width, y, width, 0, 100 - width, 6, 256, 256);
|
||||
if (width > 0)
|
||||
Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 6, width, 6, 256, 256);
|
||||
if (tile != null && tile.hasCapability(Capabilities.auraContainer, null)) {
|
||||
IAuraContainer container = tile.getCapability(Capabilities.auraContainer, null);
|
||||
|
||||
IBlockState state = mc.world.getBlockState(pos);
|
||||
ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.world, pos, mc.player);
|
||||
String s = blockStack.getDisplayName();
|
||||
mc.fontRenderer.drawString(s, x + 50 - mc.fontRenderer.getStringWidth(s) / 2F, y - 9, color, true);
|
||||
this.drawContainerInfo(container, mc, res, 25, blockStack.getDisplayName());
|
||||
|
||||
if (tile instanceof TileEntityNatureAltar) {
|
||||
ItemStack tileStack = ((TileEntityNatureAltar) tile).getItemHandler(null).getStackInSlot(0);
|
||||
if (!tileStack.isEmpty() && tileStack.hasCapability(Capabilities.auraContainer, null)) {
|
||||
IAuraContainer stackContainer = tileStack.getCapability(Capabilities.auraContainer, null);
|
||||
this.drawContainerInfo(stackContainer, mc, res, 45, tileStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,6 +145,51 @@ public class ClientEvents {
|
|||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < mc.player.inventory.getSizeInventory(); i++) {
|
||||
ItemStack slot = mc.player.inventory.getStackInSlot(i);
|
||||
if (!slot.isEmpty() && slot.getItem() == ModItems.AURA_CACHE) {
|
||||
IAuraContainer container = slot.getCapability(Capabilities.auraContainer, null);
|
||||
int width = MathHelper.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
|
||||
int x = res.getScaledWidth() / 2 - 173;
|
||||
int y = res.getScaledHeight() - 8;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
int color = container.getAuraColor();
|
||||
GlStateManager.color((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
||||
if (width < 80)
|
||||
Gui.drawModalRectWithCustomSizedTexture(x + width, y, width, 0, 80 - width, 6, 256, 256);
|
||||
if (width > 0)
|
||||
Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 6, width, 6, 256, 256);
|
||||
|
||||
float scale = 0.75F;
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
String s = slot.getDisplayName();
|
||||
mc.fontRenderer.drawString(s, (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color, true);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawContainerInfo(IAuraContainer container, Minecraft mc, ScaledResolution res, int yOffset, String name) {
|
||||
int color = container.getAuraColor();
|
||||
GlStateManager.color((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
||||
|
||||
int x = res.getScaledWidth() / 2 - 40;
|
||||
int y = res.getScaledHeight() / 2 + yOffset;
|
||||
int width = MathHelper.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
|
||||
|
||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
||||
if (width < 80)
|
||||
Gui.drawModalRectWithCustomSizedTexture(x + width, y, width, 0, 80 - width, 6, 256, 256);
|
||||
if (width > 0)
|
||||
Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 6, width, 6, 256, 256);
|
||||
|
||||
mc.fontRenderer.drawString(name, x + 40 - mc.fontRenderer.getStringWidth(name) / 2F, y - 9, color, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
package de.ellpeck.naturesaura.items;
|
||||
|
||||
import de.ellpeck.naturesaura.aura.Capabilities;
|
||||
import de.ellpeck.naturesaura.aura.IAuraContainer;
|
||||
import de.ellpeck.naturesaura.aura.ItemAuraContainer;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemAuraCache extends ItemImpl {
|
||||
|
||||
public ItemAuraCache() {
|
||||
super("aura_cache");
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stackIn, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
|
||||
if (!worldIn.isRemote && entityIn instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entityIn;
|
||||
if (player.isSneaking()) {
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (stack.hasCapability(Capabilities.auraRecharge, null)) {
|
||||
IAuraContainer container = stackIn.getCapability(Capabilities.auraContainer, null);
|
||||
if (container.getStoredAura() >= 3 && stack.getCapability(Capabilities.auraRecharge, null).recharge()) {
|
||||
container.drainAura(4, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
|
||||
if (this.isInCreativeTab(tab)) {
|
||||
items.add(new ItemStack(this));
|
||||
|
||||
ItemStack stack = new ItemStack(this);
|
||||
IAuraContainer container = stack.getCapability(Capabilities.auraContainer, null);
|
||||
container.storeAura(container.getMaxAura(), false);
|
||||
items.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
if (stack.hasCapability(Capabilities.auraContainer, null)) {
|
||||
IAuraContainer container = stack.getCapability(Capabilities.auraContainer, null);
|
||||
return 1 - container.getStoredAura() / (double) container.getMaxAura();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
|
||||
return new ICapabilityProvider() {
|
||||
private final ItemAuraContainer container = new ItemAuraContainer(stack, 4000, true);
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == Capabilities.auraContainer;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == Capabilities.auraContainer) {
|
||||
return (T) this.container;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -4,5 +4,6 @@ public class ItemEye extends ItemImpl {
|
|||
|
||||
public ItemEye() {
|
||||
super("eye");
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,4 +22,5 @@ public final class ModItems {
|
|||
public static final Item INFUSED_SHOVEL = new ItemShovelNA("infused_iron_shovel", TOOL_MATERIAL_INFUSED_IRON);
|
||||
public static final Item INFUSED_HOE = new ItemHoeNA("infused_iron_hoe", TOOL_MATERIAL_INFUSED_IRON);
|
||||
public static final Item INFUSED_SWORD = new ItemSwordNA("infused_iron_sword", TOOL_MATERIAL_INFUSED_IRON);
|
||||
public static final Item AURA_CACHE = new ItemAuraCache();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.items.tools;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||
|
@ -8,10 +9,14 @@ import net.minecraft.block.material.Material;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemAxeNA extends ItemAxe implements IModItem, IModelProvider {
|
||||
private final String baseName;
|
||||
|
||||
|
@ -53,4 +58,12 @@ public class ItemAxeNA extends ItemAxe implements IModItem, IModelProvider {
|
|||
return super.getDestroySpeed(stack, state);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
|
||||
if (this == ModItems.INFUSED_AXE)
|
||||
return Helper.makeRechargeProvider(stack);
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.items.tools;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||
|
@ -9,16 +10,20 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
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 net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemHoeNA extends ItemHoe implements IModItem, IModelProvider {
|
||||
|
||||
private final String baseName;
|
||||
|
@ -80,4 +85,12 @@ public class ItemHoeNA extends ItemHoe implements IModItem, IModelProvider {
|
|||
public void onPostInit(FMLPostInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
|
||||
if (this == ModItems.INFUSED_HOE)
|
||||
return Helper.makeRechargeProvider(stack);
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,20 @@
|
|||
package de.ellpeck.naturesaura.items.tools;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemPickaxeNA extends ItemPickaxe implements IModItem, IModelProvider {
|
||||
private final String baseName;
|
||||
|
||||
|
@ -40,4 +47,12 @@ public class ItemPickaxeNA extends ItemPickaxe implements IModItem, IModelProvid
|
|||
@Override
|
||||
public void onPostInit(FMLPostInitializationEvent event) {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
|
||||
if (this == ModItems.INFUSED_PICKAXE)
|
||||
return Helper.makeRechargeProvider(stack);
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.items.tools;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||
|
@ -10,16 +11,20 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemSpade;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemShovelNA extends ItemSpade implements IModItem, IModelProvider {
|
||||
private final String baseName;
|
||||
|
||||
|
@ -82,4 +87,12 @@ public class ItemShovelNA extends ItemSpade implements IModItem, IModelProvider
|
|||
@Override
|
||||
public void onPostInit(FMLPostInitializationEvent event) {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
|
||||
if (this == ModItems.INFUSED_SHOVEL)
|
||||
return Helper.makeRechargeProvider(stack);
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,20 @@
|
|||
package de.ellpeck.naturesaura.items.tools;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemSwordNA extends ItemSword implements IModItem, IModelProvider {
|
||||
private final String baseName;
|
||||
|
||||
|
@ -41,4 +48,12 @@ public class ItemSwordNA extends ItemSword implements IModItem, IModelProvider {
|
|||
public void onPostInit(FMLPostInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
|
||||
if (this == ModItems.INFUSED_SWORD)
|
||||
return Helper.makeRechargeProvider(stack);
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ public final class ModRecipes {
|
|||
new ItemStack(Items.REEDS),
|
||||
new ItemStack(ModItems.GOLD_LEAF)).add();
|
||||
|
||||
new AltarRecipe(new ItemStack(Items.IRON_INGOT), new ItemStack(ModItems.INFUSED_IRON), 200, 30).add();
|
||||
new AltarRecipe(new ItemStack(Items.IRON_INGOT), new ItemStack(ModItems.INFUSED_IRON), 300, 80).add();
|
||||
new AltarRecipe(new ItemStack(Blocks.STONE), new ItemStack(ModBlocks.INFUSED_STONE), 150, 40).add();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "minecraft:cube_all",
|
||||
"textures": {
|
||||
"all": "naturesaura:blocks/infused_stone"
|
||||
},
|
||||
"transform": "forge:default-block"
|
||||
},
|
||||
"variants": {
|
||||
"normal": [{}],
|
||||
"inventory": [{}]
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ tile.naturesaura.golden_leaves.name=Golden Leaves
|
|||
tile.naturesaura.gold_powder.name=Gold Powder
|
||||
tile.naturesaura.wood_stand.name=Wooden Stand
|
||||
tile.naturesaura.ancient_planks.name=Ancient Planks
|
||||
tile.naturesaura.infused_stone.name=Infused Rock
|
||||
|
||||
item.naturesaura.eye.name=Environmental Eye
|
||||
item.naturesaura.gold_fiber.name=Brilliant Fiber
|
||||
|
@ -21,6 +22,7 @@ item.naturesaura.infused_iron_shovel.name=Botanist's Shovel
|
|||
item.naturesaura.infused_iron_sword.name=Botanist's Blade
|
||||
item.naturesaura.infused_iron_hoe.name=Botanist's Hoe
|
||||
item.naturesaura.ancient_stick.name=Ancient Wood Rod
|
||||
item.naturesaura.aura_cache.name=Aura Cache
|
||||
|
||||
container.naturesaura.tree_ritual.name=Tree Infusion
|
||||
container.naturesaura.altar.name=Natural Altar
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "naturesaura:items/aura_cache"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"type": "forge:ore_shaped",
|
||||
"pattern": [
|
||||
"SIS",
|
||||
"IBI",
|
||||
"SIS"
|
||||
],
|
||||
"key": {
|
||||
"S": {
|
||||
"item": "naturesaura:infused_stone"
|
||||
},
|
||||
"I": {
|
||||
"item": "naturesaura:infused_iron"
|
||||
},
|
||||
"B": {
|
||||
"item": "minecraft:bucket"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "naturesaura:aura_cache"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 314 B |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 756 B |
Loading…
Reference in a new issue