diff --git a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java index 7c0f33d2..8511ddf1 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java @@ -6,6 +6,7 @@ import net.minecraft.block.*; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; 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; @@ -17,8 +18,8 @@ public class GrassDieEffect implements IDrainSpotEffect { int aura = AuraChunk.getAuraInArea(world, pos, 25); if (aura < 0) { int amount = Math.min(300, Math.abs(aura) / 1000); - if (amount > 0) { - int dist = Math.min(45, Math.abs(aura) / 750); + if (amount > 1) { + int dist = MathHelper.clamp(Math.abs(aura) / 750, 5, 45); if (dist > 0) { for (int i = amount / 2 + world.rand.nextInt(amount / 2); i >= 0; i--) { BlockPos grassPos = new BlockPos( diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java new file mode 100644 index 00000000..06d20ea3 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java @@ -0,0 +1,60 @@ +package de.ellpeck.naturesaura.blocks; + +import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.blocks.tiles.TileEntityFurnaceHeater; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import java.util.Random; + +public class BlockFurnaceHeater extends BlockContainerImpl { + + private static final AxisAlignedBB AABB = new AxisAlignedBB(2 / 16F, 0F, 2 / 16F, 14 / 16F, 4 / 16F, 14 / 16F); + + public BlockFurnaceHeater() { + super(Material.ROCK, "furnace_heater", TileEntityFurnaceHeater.class, "furnace_heater"); + this.setHardness(3F); + this.setHarvestLevel("pickaxe", 1); + } + + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { + TileEntity tile = worldIn.getTileEntity(pos); + if (tile instanceof TileEntityFurnaceHeater && ((TileEntityFurnaceHeater) tile).isActive) { + NaturesAura.proxy.spawnMagicParticle(worldIn, + pos.getX() + 0.35F + rand.nextFloat() * 0.3F, + pos.getY() + 0.2F, + pos.getZ() + 0.35F + rand.nextFloat() * 0.3F, + 0F, rand.nextFloat() * 0.008F + 0.005F, 0F, + rand.nextBoolean() ? 0xf46e42 : 0xf49541, rand.nextFloat() + 0.5F, 100, 0F, true, true); + } + } + + @Override + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + return AABB; + } + + @Override + public boolean isFullCube(IBlockState state) { + return false; + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + return false; + } + + @Override + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { + return false; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index 22e3623b..b94321cc 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -17,4 +17,5 @@ public final class ModBlocks { 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); + public static final Block FURNACE_HEATER = new BlockFurnaceHeater(); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java new file mode 100644 index 00000000..a48957a8 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java @@ -0,0 +1,92 @@ +package de.ellpeck.naturesaura.blocks.tiles; + +import de.ellpeck.naturesaura.aura.chunk.AuraChunk; +import de.ellpeck.naturesaura.packet.PacketHandler; +import de.ellpeck.naturesaura.packet.PacketParticleStream; +import net.minecraft.block.BlockFurnace; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.ITickable; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; + +public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable { + + public boolean isActive; + + @Override + public void update() { + if (!this.world.isRemote && this.world.getTotalWorldTime() % 5 == 0) { + boolean did = false; + + TileEntity tile = this.world.getTileEntity(this.pos.down()); + if (tile instanceof TileEntityFurnace) { + TileEntityFurnace furnace = (TileEntityFurnace) tile; + if (isReady(furnace)) { + int time = furnace.getField(0); + if (time <= 0) + BlockFurnace.setState(true, this.world, furnace.getPos()); + furnace.setField(0, 200); + //if set higher than 199, it'll never finish because the furnace does ++ and then == + furnace.setField(2, Math.min(199, furnace.getField(2) + 5)); + + BlockPos spot = AuraChunk.getClosestSpot(this.world, this.pos, 15, this.pos); + AuraChunk chunk = AuraChunk.getAuraChunk(this.world, spot); + chunk.drainAura(spot, MathHelper.ceil((200 - time) / 4F)); + did = true; + + if (this.world.getTotalWorldTime() % 15 == 0) + PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream( + this.pos.getX() + (float) this.world.rand.nextGaussian() * 5F, + this.pos.getY() + 1 + this.world.rand.nextFloat() * 5F, + this.pos.getZ() + (float) this.world.rand.nextGaussian() * 5F, + this.pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F, + this.pos.getY() + 0.15F, + this.pos.getZ() + 0.25F + this.world.rand.nextFloat() * 0.5F, + this.world.rand.nextFloat() * 0.035F + 0.035F, 0x89cc37, this.world.rand.nextFloat() + 0.5F + )); + } + } + + if(did != this.isActive){ + this.isActive = did; + this.sendToClients(); + } + } + } + + private static boolean isReady(TileEntityFurnace furnace) { + if (!furnace.getStackInSlot(1).isEmpty()) + return false; + + ItemStack input = furnace.getStackInSlot(0); + if (!input.isEmpty()) { + ItemStack output = FurnaceRecipes.instance().getSmeltingResult(input); + if (output.isEmpty()) + return false; + + ItemStack currOutput = furnace.getStackInSlot(2); + return currOutput.isEmpty() || output.isItemEqual(currOutput) && currOutput.getCount() + output.getCount() <= output.getMaxStackSize(); + } else + return false; + } + + @Override + public void writeNBT(NBTTagCompound compound, boolean syncing) { + super.writeNBT(compound, syncing); + + if (syncing) + compound.setBoolean("active", this.isActive); + } + + @Override + public void readNBT(NBTTagCompound compound, boolean syncing) { + super.readNBT(compound, syncing); + + if (syncing) + this.isActive = compound.getBoolean("active"); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java index a5ea6337..7b108d67 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java @@ -32,6 +32,15 @@ public final class ModRecipes { new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.REEDS), new ItemStack(ModItems.GOLD_LEAF)).add(); + new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "furnace_heater"), + new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.FURNACE_HEATER), 600, + new ItemStack(ModBlocks.INFUSED_STONE), + new ItemStack(ModBlocks.INFUSED_STONE), + new ItemStack(ModItems.INFUSED_IRON), + new ItemStack(ModItems.INFUSED_IRON), + new ItemStack(Items.FIRE_CHARGE), + new ItemStack(Items.FLINT), + new ItemStack(Blocks.MAGMA)).add(); new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "infused_iron"), new ItemStack(Items.IRON_INGOT), new ItemStack(ModItems.INFUSED_IRON), 300, 80).add(); diff --git a/src/main/resources/assets/naturesaura/blockstates/furnace_heater.json b/src/main/resources/assets/naturesaura/blockstates/furnace_heater.json new file mode 100644 index 00000000..ae8a883c --- /dev/null +++ b/src/main/resources/assets/naturesaura/blockstates/furnace_heater.json @@ -0,0 +1,15 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "naturesaura:furnace_heater", + "textures": { + "texture": "naturesaura:blocks/furnace_heater", + "particle": "#texture" + }, + "transform": "forge:default-block" + }, + "variants": { + "normal": [{}], + "inventory": [{}] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index 31493d11..16be2978 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -11,6 +11,7 @@ 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 +tile.naturesaura.furnace_heater.name=Extraneous Firestarter item.naturesaura.eye.name=Environmental Eye item.naturesaura.gold_fiber.name=Brilliant Fiber diff --git a/src/main/resources/assets/naturesaura/models/block/furnace_heater.json b/src/main/resources/assets/naturesaura/models/block/furnace_heater.json new file mode 100644 index 00000000..554964d3 --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/block/furnace_heater.json @@ -0,0 +1,39 @@ +{ + "elements": [ + { + "from": [2, 0, 2], + "to": [14, 4, 14], + "faces": { + "down": { + "uv": [0, 4, 12, 16], + "texture": "#texture", + "cullface": "down" + }, + "up": { + "uv": [0, 4, 12, 16], + "texture": "#texture" + }, + "north": { + "uv": [0, 0, 12, 4], + "texture": "#texture", + "cullface": "north" + }, + "south": { + "uv": [0, 0, 12, 4], + "texture": "#texture", + "cullface": "south" + }, + "west": { + "uv": [0, 0, 12, 4], + "texture": "#texture", + "cullface": "west" + }, + "east": { + "uv": [0, 0, 12, 4], + "texture": "#texture", + "cullface": "east" + } + } + } + ] +} diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/furnace_heater.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/furnace_heater.json new file mode 100644 index 00000000..e580bab9 --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/furnace_heater.json @@ -0,0 +1,17 @@ +{ + "name": "Extraneous Firestarter", + "icon": "naturesaura:furnace_heater", + "category": "using", + "advancement": "naturesaura:infused_materials", + "pages": [ + { + "type": "text", + "text": "At some point, one realizes that a $(item)Furnace$() is just too slow and consuming of resources to use efficiently.$(br)The $(item)Extraneous Firestarter$() will speed up any $(item)Furnace$() it is placed on top of, along with giving it the necessary heat to smelt any sort of material. Note that, while consuming the required $(thing)Aura$() for this, the natural levels might drop into the negatives, causing $(l:intro/aura)diminishing returns$()." + }, + { + "type": "naturesaura:tree_ritual", + "text": "Creating the $(item)Extraneous Firestarter$() using the $(l:practices/tree_ritual)Ritual of the Forest$()", + "recipe": "naturesaura:furnace_heater" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/blocks/furnace_heater.png b/src/main/resources/assets/naturesaura/textures/blocks/furnace_heater.png new file mode 100644 index 00000000..c0136cc6 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/furnace_heater.png differ