mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 05:08:34 +01:00
allow the extraneous firestarter to be placed on any side of a furnace
This commit is contained in:
parent
a9a7191ebf
commit
a10210888c
4 changed files with 101 additions and 15 deletions
|
@ -3,10 +3,14 @@ package de.ellpeck.naturesaura.blocks;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityFurnaceHeater;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityFurnaceHeater;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
import net.minecraft.block.state.BlockFaceShape;
|
import net.minecraft.block.state.BlockFaceShape;
|
||||||
|
import net.minecraft.block.state.BlockStateContainer;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
@ -17,8 +21,14 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class BlockFurnaceHeater extends BlockContainerImpl {
|
public class BlockFurnaceHeater extends BlockContainerImpl {
|
||||||
|
public static final PropertyDirection FACING = PropertyDirection.create("facing");
|
||||||
|
|
||||||
private static final AxisAlignedBB AABB = new AxisAlignedBB(2 / 16F, 0F, 2 / 16F, 14 / 16F, 4 / 16F, 14 / 16F);
|
private static final AxisAlignedBB AABB_UP = new AxisAlignedBB(2 / 16F, 0F, 2 / 16F, 14 / 16F, 4 / 16F, 14 / 16F);
|
||||||
|
private static final AxisAlignedBB AABB_DOWN = new AxisAlignedBB(2 / 16F, 12 / 16F, 2 / 16F, 14 / 16F, 1F, 14 / 16F);
|
||||||
|
private static final AxisAlignedBB AABB_NORTH = new AxisAlignedBB(2 / 16F, 2 / 16F, 12 / 16F, 14 / 16F, 14 / 16F, 1F);
|
||||||
|
private static final AxisAlignedBB AABB_EAST = new AxisAlignedBB(0F, 2 / 16F, 2 / 16F, 4 / 16F, 14 / 16F, 14 / 16F);
|
||||||
|
private static final AxisAlignedBB AABB_SOUTH = new AxisAlignedBB(2 / 16F, 2 / 16F, 0F, 14 / 16F, 14 / 16F, 4 / 16F);
|
||||||
|
private static final AxisAlignedBB AABB_WEST = new AxisAlignedBB(12 / 16F, 2 / 16F, 2 / 16F, 1F, 14 / 16F, 14 / 16F);
|
||||||
|
|
||||||
public BlockFurnaceHeater() {
|
public BlockFurnaceHeater() {
|
||||||
super(Material.ROCK, "furnace_heater", TileEntityFurnaceHeater.class, "furnace_heater");
|
super(Material.ROCK, "furnace_heater", TileEntityFurnaceHeater.class, "furnace_heater");
|
||||||
|
@ -31,18 +41,50 @@ public class BlockFurnaceHeater extends BlockContainerImpl {
|
||||||
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
|
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
|
||||||
TileEntity tile = worldIn.getTileEntity(pos);
|
TileEntity tile = worldIn.getTileEntity(pos);
|
||||||
if (tile instanceof TileEntityFurnaceHeater && ((TileEntityFurnaceHeater) tile).isActive) {
|
if (tile instanceof TileEntityFurnaceHeater && ((TileEntityFurnaceHeater) tile).isActive) {
|
||||||
|
EnumFacing facing = stateIn.getValue(FACING);
|
||||||
|
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
if (facing == EnumFacing.UP) {
|
||||||
|
x = 0.35F + rand.nextFloat() * 0.3F;
|
||||||
|
y = 0F;
|
||||||
|
z = 0.35F + rand.nextFloat() * 0.3F;
|
||||||
|
} else if (facing == EnumFacing.DOWN) {
|
||||||
|
x = 0.35F + rand.nextFloat() * 0.3F;
|
||||||
|
y = 1F;
|
||||||
|
z = 0.35F + rand.nextFloat() * 0.3F;
|
||||||
|
} else {
|
||||||
|
x = facing.getZOffset() != 0 ? (0.35F + rand.nextFloat() * 0.3F) : facing.getXOffset() < 0 ? 1 : 0;
|
||||||
|
y = 0.35F + rand.nextFloat() * 0.3F;
|
||||||
|
z = facing.getXOffset() != 0 ? (0.35F + rand.nextFloat() * 0.3F) : facing.getZOffset() < 0 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(worldIn,
|
NaturesAuraAPI.instance().spawnMagicParticle(worldIn,
|
||||||
pos.getX() + 0.35F + rand.nextFloat() * 0.3F,
|
pos.getX() + x, pos.getY() + y, pos.getZ() + z,
|
||||||
pos.getY() + 0.2F,
|
(rand.nextFloat() * 0.016F + 0.01F) * facing.getXOffset(),
|
||||||
pos.getZ() + 0.35F + rand.nextFloat() * 0.3F,
|
(rand.nextFloat() * 0.016F + 0.01F) * facing.getYOffset(),
|
||||||
0F, rand.nextFloat() * 0.016F + 0.01F, 0F,
|
(rand.nextFloat() * 0.016F + 0.01F) * facing.getZOffset(),
|
||||||
rand.nextBoolean() ? 0xf46e42 : 0xf49541, rand.nextFloat() + 0.5F, 50, 0F, true, true);
|
0xf46e42, rand.nextFloat() + 0.5F, 55, 0F, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
||||||
return AABB;
|
switch (state.getValue(FACING)) {
|
||||||
|
case DOWN:
|
||||||
|
return AABB_DOWN;
|
||||||
|
case NORTH:
|
||||||
|
return AABB_NORTH;
|
||||||
|
case EAST:
|
||||||
|
return AABB_EAST;
|
||||||
|
case SOUTH:
|
||||||
|
return AABB_SOUTH;
|
||||||
|
case WEST:
|
||||||
|
return AABB_WEST;
|
||||||
|
default:
|
||||||
|
return AABB_UP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,4 +111,24 @@ public class BlockFurnaceHeater extends BlockContainerImpl {
|
||||||
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
|
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
|
||||||
return BlockFaceShape.UNDEFINED;
|
return BlockFaceShape.UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlockStateContainer createBlockState() {
|
||||||
|
return new BlockStateContainer(this, FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetaFromState(IBlockState state) {
|
||||||
|
return state.getValue(FACING).getIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockState getStateFromMeta(int meta) {
|
||||||
|
return this.getDefaultState().withProperty(FACING, EnumFacing.byIndex(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
|
||||||
|
return this.getDefaultState().withProperty(FACING, facing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
|
import de.ellpeck.naturesaura.blocks.BlockFurnaceHeater;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
||||||
import net.minecraft.block.BlockFurnace;
|
import net.minecraft.block.BlockFurnace;
|
||||||
|
@ -11,6 +11,7 @@ import net.minecraft.item.crafting.FurnaceRecipes;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityFurnace;
|
import net.minecraft.tileentity.TileEntityFurnace;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.util.ITickable;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
@ -24,7 +25,9 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
|
||||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 5 == 0) {
|
if (!this.world.isRemote && this.world.getTotalWorldTime() % 5 == 0) {
|
||||||
boolean did = false;
|
boolean did = false;
|
||||||
|
|
||||||
TileEntity tile = this.world.getTileEntity(this.pos.down());
|
EnumFacing facing = this.world.getBlockState(this.pos).getValue(BlockFurnaceHeater.FACING);
|
||||||
|
BlockPos tilePos = this.pos.offset(facing.getOpposite());
|
||||||
|
TileEntity tile = this.world.getTileEntity(tilePos);
|
||||||
if (tile instanceof TileEntityFurnace) {
|
if (tile instanceof TileEntityFurnace) {
|
||||||
TileEntityFurnace furnace = (TileEntityFurnace) tile;
|
TileEntityFurnace furnace = (TileEntityFurnace) tile;
|
||||||
if (isReady(furnace)) {
|
if (isReady(furnace)) {
|
||||||
|
@ -40,16 +43,17 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
|
||||||
chunk.drainAura(spot, MathHelper.ceil((200 - time) / 4F));
|
chunk.drainAura(spot, MathHelper.ceil((200 - time) / 4F));
|
||||||
did = true;
|
did = true;
|
||||||
|
|
||||||
if (this.world.getTotalWorldTime() % 15 == 0)
|
if (this.world.getTotalWorldTime() % 15 == 0) {
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
|
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
|
||||||
this.pos.getX() + (float) this.world.rand.nextGaussian() * 5F,
|
this.pos.getX() + (float) this.world.rand.nextGaussian() * 5F,
|
||||||
this.pos.getY() + 1 + this.world.rand.nextFloat() * 5F,
|
this.pos.getY() + 1 + this.world.rand.nextFloat() * 5F,
|
||||||
this.pos.getZ() + (float) this.world.rand.nextGaussian() * 5F,
|
this.pos.getZ() + (float) this.world.rand.nextGaussian() * 5F,
|
||||||
this.pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F,
|
tilePos.getX() + this.world.rand.nextFloat(),
|
||||||
this.pos.getY() + 0.15F,
|
tilePos.getY() + this.world.rand.nextFloat(),
|
||||||
this.pos.getZ() + 0.25F + this.world.rand.nextFloat() * 0.5F,
|
tilePos.getZ() + this.world.rand.nextFloat(),
|
||||||
this.world.rand.nextFloat() * 0.07F + 0.07F, 0x89cc37, this.world.rand.nextFloat() + 0.5F
|
this.world.rand.nextFloat() * 0.07F + 0.07F, 0x89cc37, this.world.rand.nextFloat() + 0.5F
|
||||||
));
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,26 @@
|
||||||
},
|
},
|
||||||
"variants": {
|
"variants": {
|
||||||
"normal": [{}],
|
"normal": [{}],
|
||||||
"inventory": [{}]
|
"inventory": [{}],
|
||||||
|
"facing": {
|
||||||
|
"down": {
|
||||||
|
"x": 180
|
||||||
|
},
|
||||||
|
"up": {},
|
||||||
|
"north": {
|
||||||
|
"x": 90
|
||||||
|
},
|
||||||
|
"south": {
|
||||||
|
"x": 270
|
||||||
|
},
|
||||||
|
"west": {
|
||||||
|
"x": 90,
|
||||||
|
"y": 270
|
||||||
|
},
|
||||||
|
"east": {
|
||||||
|
"x": 270,
|
||||||
|
"y": 270
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
"pages": [
|
"pages": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"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 $(aura) for this, the natural levels might drop into the negatives, causing $(l:intro/aura)diminishing returns$()."
|
"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$() speeds up a $(item)Furnace$() it is placed on any side of, along with giving it the necessary heat to smelt any sort of material. Note that, while consuming the required $(aura) for this, the natural levels might drop into the negatives, causing $(l:intro/aura)diminishing returns$()."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "naturesaura:tree_ritual",
|
"type": "naturesaura:tree_ritual",
|
||||||
|
|
Loading…
Reference in a new issue