mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
furnace heater thing!
This commit is contained in:
parent
6544505b11
commit
cd61b2a8f1
10 changed files with 237 additions and 2 deletions
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -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": [{}]
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 358 B |
Loading…
Reference in a new issue