diff --git a/src/main/java/de/ellpeck/naturesaura/ModConfig.java b/src/main/java/de/ellpeck/naturesaura/ModConfig.java index eaf9306b..25967db6 100644 --- a/src/main/java/de/ellpeck/naturesaura/ModConfig.java +++ b/src/main/java/de/ellpeck/naturesaura/ModConfig.java @@ -1,14 +1,9 @@ package de.ellpeck.naturesaura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; -import net.minecraft.block.Block; -import net.minecraft.block.BlockFlower; -import net.minecraft.block.BlockStoneBrick; -import net.minecraft.init.Blocks; import net.minecraftforge.common.config.Config; import net.minecraftforge.common.config.Config.Comment; import net.minecraftforge.common.config.Config.RangeDouble; -import net.minecraftforge.fml.common.registry.ForgeRegistries; @Config(modid = NaturesAura.MOD_ID, category = "") public final class ModConfig { @@ -40,6 +35,8 @@ public final class ModConfig { public boolean plantBoostEffect = true; @Comment("If the Aura Imbalance effect of explosions happening randomly if Aura levels are too low should occur") public boolean explosionEffect = true; + @Comment("If the Aura Imbalance effect of breathlessness if Aura levels are too low should occur") + public boolean breathlessEffect = true; } public static class Client { diff --git a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java index 18da320b..f7401491 100644 --- a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java +++ b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java @@ -12,6 +12,7 @@ import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.events.CommonEvents; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.packet.PacketHandler; +import de.ellpeck.naturesaura.potion.ModPotions; import de.ellpeck.naturesaura.proxy.IProxy; import de.ellpeck.naturesaura.recipes.ModRecipes; import de.ellpeck.naturesaura.reg.ModRegistry; @@ -59,6 +60,7 @@ public final class NaturesAura { new ModBlocks(); new ModItems(); + new ModPotions(); Compat.preInit(); PacketHandler.init(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java index c1784d88..784e6a91 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java @@ -32,11 +32,11 @@ import java.util.List; import java.util.Random; public class BlockAncientLeaves extends BlockLeaves implements - IModItem, IModelProvider, IColorProvidingBlock, IColorProvidingItem, ITileEntityProvider { + IModItem, ICreativeItem, IModelProvider, IColorProvidingBlock, IColorProvidingItem, ITileEntityProvider { public BlockAncientLeaves() { this.leavesFancy = true; - ModRegistry.addItemOrBlock(this); + ModRegistry.add(this); } @Override @@ -49,11 +49,6 @@ public class BlockAncientLeaves extends BlockLeaves implements return "ancient_leaves"; } - @Override - public boolean shouldAddCreative() { - return true; - } - @Override public void onPreInit(FMLPreInitializationEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLog.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLog.java index b5cd5201..0ff68de3 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLog.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLog.java @@ -1,25 +1,20 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.reg.ICreativeItem; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.block.BlockLog; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -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 BlockAncientLog extends BlockLog implements IModItem, IModelProvider { +public class BlockAncientLog extends BlockLog implements IModItem, ICreativeItem, IModelProvider { public BlockAncientLog() { - ModRegistry.addItemOrBlock(this); + ModRegistry.add(this); } @Override @@ -27,11 +22,6 @@ public class BlockAncientLog extends BlockLog implements IModItem, IModelProvide return "ancient_log"; } - @Override - public boolean shouldAddCreative() { - return true; - } - @Override public void onPreInit(FMLPreInitializationEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java index fb62a49c..71ff0ebd 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.gen.WorldGenAncientTree; +import de.ellpeck.naturesaura.reg.ICreativeItem; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.ModRegistry; @@ -11,8 +11,6 @@ import net.minecraft.block.IGrowable; import net.minecraft.block.SoundType; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -22,11 +20,9 @@ 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; import java.util.Random; -public class BlockAncientSapling extends BlockBush implements IGrowable, IModItem, IModelProvider { +public class BlockAncientSapling extends BlockBush implements IGrowable, IModItem, ICreativeItem, IModelProvider { private static final AxisAlignedBB AABB = new AxisAlignedBB( 0.09999999403953552D, 0.0D, 0.09999999403953552D, @@ -36,7 +32,7 @@ public class BlockAncientSapling extends BlockBush implements IGrowable, IModIte this.setHardness(0.0F); this.setSoundType(SoundType.PLANT); - ModRegistry.addItemOrBlock(this); + ModRegistry.add(this); } @Override @@ -60,11 +56,6 @@ public class BlockAncientSapling extends BlockBush implements IGrowable, IModIte return "ancient_sapling"; } - @Override - public boolean shouldAddCreative() { - return true; - } - @Override public void onPreInit(FMLPreInitializationEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java index 38700587..48e81135 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl; +import de.ellpeck.naturesaura.reg.ICreativeItem; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.ModRegistry; @@ -26,7 +27,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry; import javax.annotation.Nullable; -public class BlockContainerImpl extends BlockContainer implements IModItem, IModelProvider { +public class BlockContainerImpl extends BlockContainer implements IModItem, ICreativeItem, IModelProvider { private final String baseName; @@ -40,7 +41,7 @@ public class BlockContainerImpl extends BlockContainer implements IModItem, IMod this.tileClass = tileClass; this.tileRegName = tileReg; - ModRegistry.addItemOrBlock(this); + ModRegistry.add(this); } @Nullable @@ -58,11 +59,6 @@ public class BlockContainerImpl extends BlockContainer implements IModItem, IMod return this.baseName; } - @Override - public boolean shouldAddCreative() { - return true; - } - @Override public void onPreInit(FMLPreInitializationEvent event) { } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java index 94b2d8de..422d3f06 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java @@ -37,7 +37,7 @@ public class BlockGoldenLeaves extends BlockLeaves implements public BlockGoldenLeaves() { this.leavesFancy = true; - ModRegistry.addItemOrBlock(this); + ModRegistry.add(this); } @Override @@ -50,11 +50,6 @@ public class BlockGoldenLeaves extends BlockLeaves implements return "golden_leaves"; } - @Override - public boolean shouldAddCreative() { - return true; - } - @Override public void onPreInit(FMLPreInitializationEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockImpl.java index c61d766a..92553a8a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockImpl.java @@ -1,5 +1,6 @@ package de.ellpeck.naturesaura.blocks; +import de.ellpeck.naturesaura.reg.ICreativeItem; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.ModRegistry; @@ -10,14 +11,14 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -public class BlockImpl extends Block implements IModItem, IModelProvider { +public class BlockImpl extends Block implements IModItem, ICreativeItem, IModelProvider { private final String baseName; public BlockImpl(String baseName, Material material) { super(material); this.baseName = baseName; - ModRegistry.addItemOrBlock(this); + ModRegistry.add(this); } @Override @@ -25,11 +26,6 @@ public class BlockImpl extends Block implements IModItem, IModelProvider { return this.baseName; } - @Override - public boolean shouldAddCreative() { - return true; - } - @Override public void onPreInit(FMLPreInitializationEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSlabsNA.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSlabsNA.java index 1cab451e..01703b3f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSlabsNA.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSlabsNA.java @@ -9,6 +9,7 @@ import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockFaceShape; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; @@ -39,8 +40,8 @@ public abstract class BlockSlabsNA extends BlockImpl implements ICustomItemBlock } @Override - public boolean shouldAddCreative() { - return !this.isDouble(); + public CreativeTabs getTabToAdd() { + return this.isDouble() ? null : super.getTabToAdd(); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java index 4020b718..72cb4441 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java @@ -1,5 +1,6 @@ package de.ellpeck.naturesaura.blocks; +import de.ellpeck.naturesaura.reg.ICreativeItem; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.ModRegistry; @@ -11,14 +12,14 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -public class BlockStairsNA extends BlockStairs implements IModItem, IModelProvider { +public class BlockStairsNA extends BlockStairs implements IModItem, ICreativeItem, IModelProvider { private final String baseName; protected BlockStairsNA(String baseName, IBlockState modelState) { super(modelState); this.baseName = baseName; - ModRegistry.addItemOrBlock(this); + ModRegistry.add(this); this.fullBlock = false; this.lightOpacity = 0; } @@ -28,11 +29,6 @@ public class BlockStairsNA extends BlockStairs implements IModItem, IModelProvid return this.baseName; } - @Override - public boolean shouldAddCreative() { - return true; - } - @Override public void onPreInit(FMLPreInitializationEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/BreathlessEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/BreathlessEffect.java new file mode 100644 index 00000000..408c1bc2 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/BreathlessEffect.java @@ -0,0 +1,52 @@ +package de.ellpeck.naturesaura.chunk.effect; + +import de.ellpeck.naturesaura.ModConfig; +import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; +import de.ellpeck.naturesaura.api.aura.type.IAuraType; +import de.ellpeck.naturesaura.potion.ModPotions; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import org.apache.commons.lang3.mutable.MutableInt; + +import java.util.List; + +public class BreathlessEffect implements IDrainSpotEffect { + + public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "breathless"); + + @Override + public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, MutableInt spot) { + if (spot.intValue() >= 0 || world.getTotalWorldTime() % 100 != 0) + return; + int aura = IAuraChunk.getAuraInArea(world, pos, 50); + if (aura > 0) + return; + int dist = Math.min(Math.abs(aura) / 500, 75); + if (dist < 10) + return; + int amp = Math.min(MathHelper.floor(Math.abs(aura) / 25000F), 3); + + List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, + new AxisAlignedBB(pos).grow(dist)); + for (EntityLivingBase entity : entities) + entity.addPotionEffect(new PotionEffect(ModPotions.BREATHLESS, 300, amp)); + } + + @Override + public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) { + return ModConfig.enabledFeatures.breathlessEffect; + } + + @Override + public ResourceLocation getName() { + return NAME; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/DrainSpotEffects.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/DrainSpotEffects.java index 18db8816..d3870c11 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/DrainSpotEffects.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/DrainSpotEffects.java @@ -10,5 +10,6 @@ public final class DrainSpotEffects { NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(ReplenishingEffect.NAME, ReplenishingEffect::new); NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(BalanceEffect.NAME, BalanceEffect::new); NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(ExplosionEffect.NAME, ExplosionEffect::new); + NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(BreathlessEffect.NAME, BreathlessEffect::new); } } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java index 2715218d..708081ed 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java @@ -24,11 +24,11 @@ public class GrassDieEffect implements IDrainSpotEffect { @Override public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, MutableInt spot) { if (spot.intValue() < 0) { - int aura = IAuraChunk.getAuraInArea(world, pos, 25); + int aura = IAuraChunk.getAuraInArea(world, pos, 50); if (aura < 0) { int amount = Math.min(300, Math.abs(aura) / 1000); if (amount > 1) { - int dist = MathHelper.clamp(Math.abs(aura) / 750, 5, 45); + int dist = MathHelper.clamp(Math.abs(aura) / 750, 5, 75); for (int i = amount / 2 + world.rand.nextInt(amount / 2); i >= 0; i--) { BlockPos grassPos = new BlockPos( pos.getX() + world.rand.nextGaussian() * dist, diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java b/src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java index 2e068927..c5db00ab 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java @@ -1,26 +1,21 @@ package de.ellpeck.naturesaura.items; -import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.reg.ICreativeItem; 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 { +public class ItemImpl extends Item implements IModItem, ICreativeItem, IModelProvider { private final String baseName; public ItemImpl(String baseName) { this.baseName = baseName; - ModRegistry.addItemOrBlock(this); + ModRegistry.add(this); } @Override @@ -28,11 +23,6 @@ public class ItemImpl extends Item implements IModItem, IModelProvider { return this.baseName; } - @Override - public boolean shouldAddCreative() { - return true; - } - @Override public void onPreInit(FMLPreInitializationEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxeNA.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxeNA.java index 6e63f3d1..271fa393 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxeNA.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxeNA.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.items.tools; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.items.ModItems; +import de.ellpeck.naturesaura.reg.ICreativeItem; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.ModRegistry; @@ -17,13 +18,13 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import javax.annotation.Nullable; -public class ItemAxeNA extends ItemAxe implements IModItem, IModelProvider { +public class ItemAxeNA extends ItemAxe implements IModItem, ICreativeItem, IModelProvider { private final String baseName; public ItemAxeNA(String baseName, ToolMaterial material, float damage, float speed) { super(material, damage, speed); this.baseName = baseName; - ModRegistry.addItemOrBlock(this); + ModRegistry.add(this); } @Override @@ -31,11 +32,6 @@ public class ItemAxeNA extends ItemAxe implements IModItem, IModelProvider { return this.baseName; } - @Override - public boolean shouldAddCreative() { - return true; - } - @Override public void onPreInit(FMLPreInitializationEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoeNA.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoeNA.java index 79208a40..f3bea9a9 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoeNA.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoeNA.java @@ -1,7 +1,9 @@ package de.ellpeck.naturesaura.items.tools; +import crafttweaker.api.creativetabs.ICreativeTab; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.items.ModItems; +import de.ellpeck.naturesaura.reg.ICreativeItem; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.ModRegistry; @@ -24,14 +26,14 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import javax.annotation.Nullable; -public class ItemHoeNA extends ItemHoe implements IModItem, IModelProvider { +public class ItemHoeNA extends ItemHoe implements IModItem, ICreativeItem, IModelProvider { private final String baseName; public ItemHoeNA(String baseName, ToolMaterial material) { super(material); this.baseName = baseName; - ModRegistry.addItemOrBlock(this); + ModRegistry.add(this); } @Override @@ -66,11 +68,6 @@ public class ItemHoeNA extends ItemHoe implements IModItem, IModelProvider { return this.baseName; } - @Override - public boolean shouldAddCreative() { - return true; - } - @Override public void onPreInit(FMLPreInitializationEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxeNA.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxeNA.java index 87fcbcc3..f75eee45 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxeNA.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxeNA.java @@ -3,13 +3,12 @@ package de.ellpeck.naturesaura.items.tools; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.items.ModItems; +import de.ellpeck.naturesaura.reg.ICreativeItem; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.ModRegistry; -import net.minecraft.block.BlockStoneBrick; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; @@ -27,14 +26,14 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import javax.annotation.Nullable; -public class ItemPickaxeNA extends ItemPickaxe implements IModItem, IModelProvider { +public class ItemPickaxeNA extends ItemPickaxe implements IModItem, ICreativeItem, IModelProvider { private final String baseName; public ItemPickaxeNA(String baseName, ToolMaterial material) { super(material); this.baseName = baseName; - ModRegistry.addItemOrBlock(this); + ModRegistry.add(this); } @Override @@ -42,11 +41,6 @@ public class ItemPickaxeNA extends ItemPickaxe implements IModItem, IModelProvid return this.baseName; } - @Override - public boolean shouldAddCreative() { - return true; - } - @Override public void onPreInit(FMLPreInitializationEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovelNA.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovelNA.java index 9ad65338..9be063f4 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovelNA.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovelNA.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.items.tools; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.items.ModItems; +import de.ellpeck.naturesaura.reg.ICreativeItem; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.ModRegistry; @@ -27,13 +28,13 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import javax.annotation.Nullable; -public class ItemShovelNA extends ItemSpade implements IModItem, IModelProvider { +public class ItemShovelNA extends ItemSpade implements IModItem, ICreativeItem, IModelProvider { private final String baseName; public ItemShovelNA(String baseName, ToolMaterial material) { super(material); this.baseName = baseName; - ModRegistry.addItemOrBlock(this); + ModRegistry.add(this); } @Override @@ -81,11 +82,6 @@ public class ItemShovelNA extends ItemSpade implements IModItem, IModelProvider return this.baseName; } - @Override - public boolean shouldAddCreative() { - return true; - } - @Override public void onPreInit(FMLPreInitializationEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSwordNA.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSwordNA.java index c5559179..6a7d1c5b 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSwordNA.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSwordNA.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.items.tools; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.items.ModItems; +import de.ellpeck.naturesaura.reg.ICreativeItem; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.ModRegistry; @@ -18,13 +19,13 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import javax.annotation.Nullable; -public class ItemSwordNA extends ItemSword implements IModItem, IModelProvider { +public class ItemSwordNA extends ItemSword implements IModItem, ICreativeItem, IModelProvider { private final String baseName; public ItemSwordNA(String baseName, ToolMaterial material) { super(material); this.baseName = baseName; - ModRegistry.addItemOrBlock(this); + ModRegistry.add(this); } @Override @@ -32,11 +33,6 @@ public class ItemSwordNA extends ItemSword implements IModItem, IModelProvider { return this.baseName; } - @Override - public boolean shouldAddCreative() { - return true; - } - @Override public void onPreInit(FMLPreInitializationEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/potion/ModPotions.java b/src/main/java/de/ellpeck/naturesaura/potion/ModPotions.java new file mode 100644 index 00000000..3d6a18dc --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/potion/ModPotions.java @@ -0,0 +1,9 @@ +package de.ellpeck.naturesaura.potion; + +import net.minecraft.potion.Potion; + +public final class ModPotions { + + public static final Potion BREATHLESS = new PotionBreathless().setIconIndex(0, 0); + +} diff --git a/src/main/java/de/ellpeck/naturesaura/potion/PotionBreathless.java b/src/main/java/de/ellpeck/naturesaura/potion/PotionBreathless.java new file mode 100644 index 00000000..60a72949 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/potion/PotionBreathless.java @@ -0,0 +1,42 @@ +package de.ellpeck.naturesaura.potion; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingHealEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.Random; + +public class PotionBreathless extends PotionImpl { + + private final Random random = new Random(); + + protected PotionBreathless() { + super("breathless", true, 0); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onHeal(LivingHealEvent event) { + PotionEffect effect = event.getEntityLiving().getActivePotionEffect(this); + if (effect == null) + return; + float chance = (effect.getAmplifier() + 1) / 15F; + if (this.random.nextFloat() <= chance) { + event.setAmount(event.getAmount() / 4F); + } + } + + @Override + public boolean isReady(int duration, int amplifier) { + int mod = 200 >> amplifier; + return mod > 0 && duration % mod == 0 && this.random.nextBoolean(); + } + + @Override + public void performEffect(EntityLivingBase entity, int amplifier) { + entity.attackEntityFrom(DamageSource.MAGIC, 1F); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/potion/PotionImpl.java b/src/main/java/de/ellpeck/naturesaura/potion/PotionImpl.java new file mode 100644 index 00000000..1271741f --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/potion/PotionImpl.java @@ -0,0 +1,58 @@ +package de.ellpeck.naturesaura.potion; + +import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.reg.IModItem; +import de.ellpeck.naturesaura.reg.ModRegistry; +import net.minecraft.client.Minecraft; +import net.minecraft.potion.Potion; +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 net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class PotionImpl extends Potion implements IModItem { + + private static final ResourceLocation TEXTURE = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/potions.png"); + protected final String baseName; + + protected PotionImpl(String baseName, boolean isBadEffectIn, int liquidColorIn) { + super(isBadEffectIn, liquidColorIn); + this.baseName = baseName; + + ModRegistry.add(this); + } + + @Override + public Potion setIconIndex(int x, int y) { + return super.setIconIndex(x, y); + } + + @Override + @SideOnly(Side.CLIENT) + public int getStatusIconIndex() { + Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE); + return super.getStatusIconIndex(); + } + + @Override + public String getBaseName() { + return this.baseName; + } + + @Override + public void onPreInit(FMLPreInitializationEvent event) { + + } + + @Override + public void onInit(FMLInitializationEvent event) { + + } + + @Override + public void onPostInit(FMLPostInitializationEvent event) { + + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ICreativeItem.java b/src/main/java/de/ellpeck/naturesaura/reg/ICreativeItem.java new file mode 100644 index 00000000..c021ae81 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/reg/ICreativeItem.java @@ -0,0 +1,11 @@ +package de.ellpeck.naturesaura.reg; + +import de.ellpeck.naturesaura.NaturesAura; +import net.minecraft.creativetab.CreativeTabs; + +public interface ICreativeItem { + + default CreativeTabs getTabToAdd() { + return NaturesAura.CREATIVE_TAB; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/reg/IModItem.java b/src/main/java/de/ellpeck/naturesaura/reg/IModItem.java index 300ab36a..ca210c3f 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/IModItem.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/IModItem.java @@ -8,8 +8,6 @@ public interface IModItem { String getBaseName(); - boolean shouldAddCreative(); - void onPreInit(FMLPreInitializationEvent event); void onInit(FMLInitializationEvent event); diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index 2078f4b2..a25a05e1 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -3,9 +3,11 @@ package de.ellpeck.naturesaura.reg; import de.ellpeck.naturesaura.NaturesAura; import net.minecraft.block.Block; import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @@ -19,23 +21,27 @@ public final class ModRegistry { private static final List ALL_ITEMS = new ArrayList<>(); - public static void addItemOrBlock(IModItem item) { + public static void add(IModItem item) { ALL_ITEMS.add(item); } - private static void registerItem(Item item, String name, boolean addCreative) { + private static void registerPotion(Potion potion, String name) { + potion.setPotionName("potion." + NaturesAura.MOD_ID + "." + name + ".name"); + + potion.setRegistryName(NaturesAura.MOD_ID, name); + ForgeRegistries.POTIONS.register(potion); + } + + private static void registerItem(Item item, String name, CreativeTabs tab) { item.setTranslationKey(NaturesAura.MOD_ID + "." + name); item.setRegistryName(NaturesAura.MOD_ID, name); ForgeRegistries.ITEMS.register(item); - if (addCreative) - item.setCreativeTab(NaturesAura.CREATIVE_TAB); - else - item.setCreativeTab(null); + item.setCreativeTab(tab); } - private static void registerBlock(Block block, String name, ItemBlock item, boolean addCreative) { + private static void registerBlock(Block block, String name, ItemBlock item, CreativeTabs tab) { block.setTranslationKey(NaturesAura.MOD_ID + "." + name); block.setRegistryName(NaturesAura.MOD_ID, name); @@ -46,17 +52,20 @@ public final class ModRegistry { ForgeRegistries.ITEMS.register(item); } - if (addCreative) - block.setCreativeTab(NaturesAura.CREATIVE_TAB); - else - block.setCreativeTab(null); + item.setCreativeTab(tab); + } + + private static CreativeTabs getTab(IModItem item) { + if (item instanceof ICreativeItem) + return ((ICreativeItem) item).getTabToAdd(); + return null; } public static void preInit(FMLPreInitializationEvent event) { for (IModItem item : ALL_ITEMS) { - if (item instanceof Item) - registerItem((Item) item, item.getBaseName(), item.shouldAddCreative()); - else if (item instanceof Block) { + if (item instanceof Item) { + registerItem((Item) item, item.getBaseName(), getTab(item)); + } else if (item instanceof Block) { Block block = (Block) item; ItemBlock itemBlock; @@ -65,8 +74,9 @@ public final class ModRegistry { else itemBlock = new ItemBlock(block); - registerBlock(block, item.getBaseName(), itemBlock, item.shouldAddCreative()); - } + registerBlock(block, item.getBaseName(), itemBlock, getTab(item)); + } else if (item instanceof Potion) + registerPotion((Potion) item, item.getBaseName()); if (item instanceof IModelProvider) { Map models = ((IModelProvider) item).getModelLocations(); diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index 0dea0dc0..28e77510 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -108,4 +108,6 @@ advancement.naturesaura.offering.desc=Create an Offering Table for the Offering advancement.naturesaura.sky_ingot=Sturdy and light advancement.naturesaura.sky_ingot.desc=Create an Ingot of the Skies using the Offering to the Gods -command.naturesaura.aura.usage=/naaura \ No newline at end of file +command.naturesaura.aura.usage=/naaura + +potion.naturesaura.breathless.name=Breathless \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/breathlessness.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/breathlessness.json new file mode 100644 index 00000000..4e6f133f --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/breathlessness.json @@ -0,0 +1,12 @@ +{ + "name": "Breathlessness", + "icon": "minecraft:wool", + "category": "effects", + "advancement": "naturesaura:furnace_heater", + "pages": [ + { + "type": "text", + "text": "The removal of $(aura) from an area not only has an effect on plantlife around the effected area, but also on creatures that require $(item)oxygen$() to breathe. These creatures will quickly notice that, the more $(aura) is drained, the less easy it becomes to breathe: Their lungs will start producing an acute pain that stings in irregular intervals, and it becomes severely harder to regenerate health." + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/gui/potions.png b/src/main/resources/assets/naturesaura/textures/gui/potions.png new file mode 100644 index 00000000..5f96e82c Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/gui/potions.png differ