piston bellows and firebox and working with each other
This commit is contained in:
@@ -105,6 +105,7 @@ public class Firebox extends CustomContainerFacing implements ITileEntityProvide
|
|||||||
String tempString = tempInt.toString();
|
String tempString = tempInt.toString();
|
||||||
ITextComponent itextcomponent = new TextComponentString(tempString);
|
ITextComponent itextcomponent = new TextComponentString(tempString);
|
||||||
player.sendStatusMessage(itextcomponent, true);
|
player.sendStatusMessage(itextcomponent, true);
|
||||||
|
//System.out.println(pos);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,10 @@ import net.minecraft.block.state.IBlockState;
|
|||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.SoundEvents;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumBlockRenderType;
|
import net.minecraft.util.*;
|
||||||
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.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
@@ -26,6 +25,7 @@ import nmd.primal.forgecraft.ModInfo;
|
|||||||
import nmd.primal.forgecraft.tiles.TileFirebox;
|
import nmd.primal.forgecraft.tiles.TileFirebox;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mminaie on 1/1/17.
|
* Created by mminaie on 1/1/17.
|
||||||
@@ -46,29 +46,16 @@ public class PistonBellows extends CustomFacing {
|
|||||||
setHardness(3.0f);
|
setHardness(3.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DOESNT SEEM LIKE I'M ADDING HEAT TO THE RIGHT TILE
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
System.out.println(facing);
|
//System.out.println(state.getValue(PistonBellows.FACING));
|
||||||
if(facing == EnumFacing.NORTH){
|
if(state.getValue(PistonBellows.FACING) == EnumFacing.NORTH){
|
||||||
BlockPos tempPos = new BlockPos(pos.getX()-1, pos.getY(), pos.getZ());
|
|
||||||
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
|
|
||||||
if(world.getBlockState(tempPos) == Firebox.ACTIVE){
|
|
||||||
if(tile != null){
|
|
||||||
tile.setHeat(tile.getHeat() + 25);
|
|
||||||
tile.updateBlock();
|
|
||||||
tile.markDirty();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(facing == EnumFacing.SOUTH){
|
|
||||||
BlockPos tempPos = new BlockPos(pos.getX()+1, pos.getY(), pos.getZ());
|
BlockPos tempPos = new BlockPos(pos.getX()+1, pos.getY(), pos.getZ());
|
||||||
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
|
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
|
||||||
if(world.getBlockState(tempPos) == Firebox.ACTIVE){
|
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.EAST)){
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
|
//System.out.println(world.getBlockState(tempPos).getValue(Firebox.FACING));
|
||||||
tile.setHeat(tile.getHeat() + 25);
|
tile.setHeat(tile.getHeat() + 25);
|
||||||
tile.updateBlock();
|
tile.updateBlock();
|
||||||
tile.markDirty();
|
tile.markDirty();
|
||||||
@@ -76,11 +63,12 @@ public class PistonBellows extends CustomFacing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(facing == EnumFacing.EAST){
|
if(state.getValue(PistonBellows.FACING) == EnumFacing.SOUTH){
|
||||||
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ()-1);
|
BlockPos tempPos = new BlockPos(pos.getX()-1, pos.getY(), pos.getZ());
|
||||||
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
|
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
|
||||||
if(world.getBlockState(tempPos) == Firebox.ACTIVE){
|
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.WEST)){
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
|
//System.out.println(world.getBlockState(tempPos).getValue(Firebox.FACING));
|
||||||
tile.setHeat(tile.getHeat() + 25);
|
tile.setHeat(tile.getHeat() + 25);
|
||||||
tile.updateBlock();
|
tile.updateBlock();
|
||||||
tile.markDirty();
|
tile.markDirty();
|
||||||
@@ -88,11 +76,25 @@ public class PistonBellows extends CustomFacing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(facing == EnumFacing.EAST){
|
if(state.getValue(PistonBellows.FACING) == EnumFacing.EAST){
|
||||||
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ()+1);
|
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ()+1);
|
||||||
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
|
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
|
||||||
if(world.getBlockState(tempPos) == Firebox.ACTIVE){
|
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.SOUTH)){
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
|
//System.out.println(world.getBlockState(tempPos).getValue(Firebox.FACING));
|
||||||
|
tile.setHeat(tile.getHeat() + 25);
|
||||||
|
tile.updateBlock();
|
||||||
|
tile.markDirty();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(state.getValue(PistonBellows.FACING) == EnumFacing.WEST){
|
||||||
|
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ()-1);
|
||||||
|
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
|
||||||
|
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.NORTH)){
|
||||||
|
if(tile != null){
|
||||||
|
//System.out.println(world.getBlockState(tempPos).getValue(Firebox.FACING));
|
||||||
tile.setHeat(tile.getHeat() + 25);
|
tile.setHeat(tile.getHeat() + 25);
|
||||||
tile.updateBlock();
|
tile.updateBlock();
|
||||||
tile.markDirty();
|
tile.markDirty();
|
||||||
@@ -101,9 +103,64 @@ public class PistonBellows extends CustomFacing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(world.isRemote){
|
||||||
|
if(state.getValue(PistonBellows.FACING) == EnumFacing.NORTH) {
|
||||||
|
BlockPos tempPos = new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ());
|
||||||
|
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
|
||||||
|
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.EAST)){
|
||||||
|
makeEmbers(world, tempPos, world.rand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(state.getValue(PistonBellows.FACING) == EnumFacing.SOUTH) {
|
||||||
|
BlockPos tempPos = new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ());
|
||||||
|
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
|
||||||
|
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.WEST)){
|
||||||
|
makeEmbers(world, tempPos, world.rand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(state.getValue(PistonBellows.FACING) == EnumFacing.EAST) {
|
||||||
|
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1);
|
||||||
|
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
|
||||||
|
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.SOUTH)){
|
||||||
|
makeEmbers(world, tempPos, world.rand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(state.getValue(PistonBellows.FACING) == EnumFacing.WEST) {
|
||||||
|
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1);
|
||||||
|
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
|
||||||
|
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.NORTH)){
|
||||||
|
makeEmbers(world, tempPos, world.rand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void makeEmbers(World world, BlockPos pos, Random rand){
|
||||||
|
double d0 = (double)pos.getX() + 0.5D;
|
||||||
|
double d1 = (double)pos.getY() + 0.65D;
|
||||||
|
double d2 = (double)pos.getZ() + 0.5D;
|
||||||
|
double d3 = 0.52D;
|
||||||
|
double d4 = rand.nextDouble() * 0.6D - 0.3D;
|
||||||
|
|
||||||
|
if(rand.nextInt(3) == 0){
|
||||||
|
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
|
||||||
|
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
if(rand.nextInt(3) == 1){
|
||||||
|
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2-d4, 0.0D, 0.1D, 0.0D, new int[0]);
|
||||||
|
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
if(rand.nextInt(3) == 2){
|
||||||
|
world.spawnParticle(EnumParticleTypes.FLAME, d0-d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
|
||||||
|
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
if(rand.nextInt(3) == 3){
|
||||||
|
world.spawnParticle(EnumParticleTypes.FLAME, d0-d4, d1, d2-d4, 0.0D, 0.1D, 0.0D, new int[0]);
|
||||||
|
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ public class TileFirebox extends TileBaseSlot implements ITickable {
|
|||||||
World world = this.getWorld();
|
World world = this.getWorld();
|
||||||
this.iteration ++;
|
this.iteration ++;
|
||||||
if(this.iteration == 200 ) {
|
if(this.iteration == 200 ) {
|
||||||
//System.out.println(iteration);
|
|
||||||
this.iteration = 0;
|
this.iteration = 0;
|
||||||
IBlockState state = world.getBlockState(this.pos);
|
IBlockState state = world.getBlockState(this.pos);
|
||||||
BlockPos abovePos = new BlockPos(this.getPos().getX(), this.getPos().getY()+1, this.getPos().getZ());
|
BlockPos abovePos = new BlockPos(this.getPos().getX(), this.getPos().getY()+1, this.getPos().getZ());
|
||||||
@@ -61,7 +60,6 @@ public class TileFirebox extends TileBaseSlot implements ITickable {
|
|||||||
if (world.getBlockState(this.getPos()).getValue(Firebox.ACTIVE)) {
|
if (world.getBlockState(this.getPos()).getValue(Firebox.ACTIVE)) {
|
||||||
if (this.getSlotStack(0) == ItemStack.EMPTY) {
|
if (this.getSlotStack(0) == ItemStack.EMPTY) {
|
||||||
world.setBlockState(this.getPos(), state.withProperty(Firebox.ACTIVE, false), 2);
|
world.setBlockState(this.getPos(), state.withProperty(Firebox.ACTIVE, false), 2);
|
||||||
|
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
world.notifyBlockUpdate(pos, state, state, 2);
|
world.notifyBlockUpdate(pos, state, state, 2);
|
||||||
}
|
}
|
||||||
@@ -156,4 +154,23 @@ public class TileFirebox extends TileBaseSlot implements ITickable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ***************************************************************************** //
|
||||||
|
// NBT
|
||||||
|
// ***************************************************************************** //
|
||||||
|
@Override
|
||||||
|
public NBTTagCompound readNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.readNBT(nbt);
|
||||||
|
this.heat = nbt.getInteger("heat");
|
||||||
|
return nbt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NBTTagCompound writeNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
nbt.setInteger("heat", this.heat);
|
||||||
|
super.writeNBT(nbt);
|
||||||
|
return nbt;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user