logic for bloomery in tile doesnt work

This commit is contained in:
Mohammad-Ali Minaie
2017-01-26 17:21:15 -05:00
parent 0b03f84e5a
commit 6557b3df6f
5 changed files with 96 additions and 20 deletions

View File

@@ -33,6 +33,7 @@ import nmd.primal.forgecraft.tiles.TileBloomery;
import nmd.primal.forgecraft.tiles.TileFirebox;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
/**
* Created by mminaie on 1/21/17.
@@ -433,7 +434,8 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
double d1 = (double)pos.getY() + 0.2D;
double d2 = (double)pos.getZ() + 0.5D;
double d3 = 0.52D;
double d4 = rand.nextDouble() * 0.6D - 0.3D;
//double d4 = rand.nextDouble() * 0.6D - 0.3D;
double d4 = ThreadLocalRandom.current().nextDouble(0.15, 0.35);
if (rand.nextDouble() < 0.1D)
{

View File

@@ -1,5 +1,6 @@
package nmd.primal.forgecraft.blocks;
import javafx.scene.effect.Bloom;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
@@ -26,6 +27,7 @@ import nmd.primal.forgecraft.tiles.TileFirebox;
import nmd.primal.forgecraft.tiles.TilePistonBellows;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
/**
* Created by mminaie on 1/1/17.
@@ -389,8 +391,15 @@ public class PistonBellows extends CustomContainerFacing {
makeEmbers(world, tempPos, world.rand);
}
}
if (world.getBlockState(tempPos).getBlock() instanceof Bloomery) {
TileBloomery tile = (TileBloomery) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Bloomery.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Bloomery.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());
if (world.getBlockState(tempPos).getBlock() == ModBlocks.firebox) {
@@ -399,8 +408,15 @@ public class PistonBellows extends CustomContainerFacing {
makeEmbers(world, tempPos, world.rand);
}
}
if (world.getBlockState(tempPos).getBlock() instanceof Bloomery) {
TileBloomery tile = (TileBloomery) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Bloomery.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Bloomery.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);
if (world.getBlockState(tempPos).getBlock() == ModBlocks.firebox) {
@@ -409,8 +425,15 @@ public class PistonBellows extends CustomContainerFacing {
makeEmbers(world, tempPos, world.rand);
}
}
if (world.getBlockState(tempPos).getBlock() instanceof Bloomery) {
TileBloomery tile = (TileBloomery) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Bloomery.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Bloomery.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);
if (world.getBlockState(tempPos).getBlock() == ModBlocks.firebox) {
@@ -419,6 +442,12 @@ public class PistonBellows extends CustomContainerFacing {
makeEmbers(world, tempPos, world.rand);
}
}
if (world.getBlockState(tempPos).getBlock() instanceof Bloomery) {
TileBloomery tile = (TileBloomery) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Bloomery.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Bloomery.FACING) == EnumFacing.NORTH)) {
makeEmbers(world, tempPos, world.rand);
}
}
}
}
}
@@ -427,23 +456,24 @@ public class PistonBellows extends CustomContainerFacing {
double d1 = (double)pos.getY() + 0.96D;
double d2 = (double)pos.getZ() + 0.5D;
double d3 = 0.52D;
double d4 = rand.nextDouble() * 0.6D - 0.3D;
double d4 = ThreadLocalRandom.current().nextDouble(0.175, 0.35);
double ySpeed = 0.1D;
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]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, ySpeed, 0.0D, new int[0]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, ySpeed, 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]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2-d4, 0.0D, ySpeed, 0.0D, new int[0]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, ySpeed, 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]);
world.spawnParticle(EnumParticleTypes.FLAME, d0-d4, d1, d2+d4, 0.0D, ySpeed, 0.0D, new int[0]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, ySpeed, 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]);
world.spawnParticle(EnumParticleTypes.FLAME, d0-d4, d1, d2-d4, 0.0D, ySpeed, 0.0D, new int[0]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, ySpeed, 0.0D, new int[0]);
}
}

View File

@@ -95,9 +95,9 @@ public class BloomeryCrafting {
return this.ideal_time;
}
public float getHeat_variance(){return this.heat_variance; }
public float getHeatVariance(){return this.heat_variance; }
public float getTime_variance(){return this.time_variance; }
public float getTimeVariance(){return this.time_variance; }
///
// end

View File

@@ -2,6 +2,7 @@ package nmd.primal.forgecraft.init;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
import nmd.primal.forgecraft.blocks.Bloomery;
@@ -37,12 +38,12 @@ public class ModCrafting {
//DryingRecipe.addRecipe(new ItemStack(Items.FISH, 1, 0), new ItemStack(PrimalItems.FISH_COD_DRIED), new ItemStack(PrimalItems.FISH_COD_ROTTEN), 25, 0.006F);
BloomeryCrafting.addRecipe(
new ItemStack(ModItems.softcrucible, 1),
new ItemStack(ModBlocks.emptycrucible, 1),
new ItemStack(Item.getItemFromBlock(ModBlocks.emptycrucible), 1),
//new ItemStack(ModItems.crackedcrucible, 1),
new ItemStack(Items.STICK, 1),
2100,
2400,
0.25f,
500,
500,
1.25f,
1.0f);
}
}

View File

@@ -13,6 +13,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import nmd.primal.forgecraft.blocks.Bloomery;
import nmd.primal.forgecraft.blocks.Firebox;
import nmd.primal.forgecraft.crafting.BloomeryCrafting;
import nmd.primal.forgecraft.init.ModItems;
import static nmd.primal.forgecraft.CommonUtils.getVanillaItemBurnTime;
@@ -25,6 +26,7 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
private NonNullList<ItemStack> slotList = NonNullList.<ItemStack>withSize(3, ItemStack.EMPTY);
private int iteration = 0;
private int heat;
private int cookCounter;
@Override
public void update () {
@@ -46,10 +48,49 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
}
this.heatManager(this.getHeat(), state, this.getSlotStack(0));
}
slotOneManager();
}
}
//Insert Slot 1 manager for crafting
private void slotOneManager(){
BloomeryCrafting recipe = BloomeryCrafting.getRecipe(this.getSlotStack(1));
if(recipe != null){
System.out.println(recipe.getInput() + " : " + recipe.getOutput() + " : " + recipe.getIdealTime() + " : " + recipe.getHeatThreshold());
System.out.println(this.getSlotStack(1) + " : " + this.cookCounter + " : " + this.getHeat());
if(this.getHeat() >= recipe.getHeatThreshold()){
cookCounter++;
//System.out.println(cookCounter);
}
if(cookCounter >= recipe.getIdealTime()){
if(this.getSlotStack(1) == recipe.getInput()) {
this.setSlotStack(1, recipe.getOutput());
System.out.print(" :Success: " + this.getSlotStack(1));
this.updateBlock();
this.markDirty();
}
}
if( cookCounter > recipe.getIdealTime() + (recipe.getIdealTime() * recipe.getTimeVariance())){
if(this.getSlotStack(1) == recipe.getInput()) {
this.setSlotStack(1, recipe.getOutputFailed());
this.cookCounter = 0;
System.out.print(" :Failure Time: " + this.getSlotStack(1));
this.updateBlock();
this.markDirty();
}
}
if(this.getHeat() > recipe.getHeatThreshold() + (recipe.getHeatThreshold() * recipe.getHeatVariance())){
this.setSlotStack(1, recipe.getOutputFailed());
this.cookCounter = 0;
System.out.print(" :Failure Heat: " + this.getSlotStack(1));
this.updateBlock();
this.markDirty();
}
if (this.getSlotStack(1).isEmpty()){
this.cookCounter=0;
}
}
}
private void slotZeroManager(World world){
if(this.getSlotStack(0) != ItemStack.EMPTY) {
@@ -143,6 +184,7 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
{
super.readNBT(nbt);
this.heat = nbt.getInteger("heat");
this.cookCounter = nbt.getInteger("cook");
return nbt;
}
@@ -150,6 +192,7 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
public NBTTagCompound writeNBT(NBTTagCompound nbt)
{
nbt.setInteger("heat", this.heat);
nbt.setInteger("cook", this.cookCounter);
super.writeNBT(nbt);
return nbt;
}