much closer to stable state
This commit is contained in:
@@ -3,10 +3,12 @@ package nmd.primal.forgecraft.blocks.Crucibles;
|
|||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
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.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
@@ -37,7 +39,7 @@ import java.util.Random;
|
|||||||
/**
|
/**
|
||||||
* Created by mminaie on 11/11/17.
|
* Created by mminaie on 11/11/17.
|
||||||
*/
|
*/
|
||||||
public class NBTCrucible extends BlockContainer implements ITileEntityProvider, IPickup {
|
public class NBTCrucible extends BlockContainer implements ITileEntityProvider {
|
||||||
|
|
||||||
protected static final AxisAlignedBB boundBox = new AxisAlignedBB(4/16D, 0.0D, 4/16D, 12/16D, 7/16D, 12/16D);
|
protected static final AxisAlignedBB boundBox = new AxisAlignedBB(4/16D, 0.0D, 4/16D, 12/16D, 7/16D, 12/16D);
|
||||||
|
|
||||||
@@ -49,7 +51,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider,
|
|||||||
setRegistryName(registryName);
|
setRegistryName(registryName);
|
||||||
setCreativeTab(ModInfo.TAB_FORGECRAFT);
|
setCreativeTab(ModInfo.TAB_FORGECRAFT);
|
||||||
setHardness(3.0f);
|
setHardness(3.0f);
|
||||||
//setDefaultState(this.blockState.getBaseState().withProperty(PrimalAPI.States.ACTIVE, Boolean.valueOf(false)));
|
setDefaultState(this.blockState.getBaseState().withProperty(PrimalAPI.States.ACTIVE, Boolean.valueOf(false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -59,30 +61,9 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider,
|
|||||||
TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos);
|
TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos);
|
||||||
ItemStack pItem = player.inventory.getCurrentItem();
|
ItemStack pItem = player.inventory.getCurrentItem();
|
||||||
ItemStack pItem1 = new ItemStack(pItem.getItem(), 1);
|
ItemStack pItem1 = new ItemStack(pItem.getItem(), 1);
|
||||||
/**CLEARS THE INVENTORY**/
|
|
||||||
if(player.isSneaking()){
|
|
||||||
for(int i=0; i<tile.ingList.size(); i++){
|
|
||||||
//if(!tile.ingList.get(i).isEmpty()) {
|
|
||||||
PlayerHelper.spawnItemOnPlayer(world, player, tile.ingList.get(i));
|
|
||||||
tile.ingList.set(i, ItemStack.EMPTY);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
tile.update();
|
|
||||||
tile.markDirty();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**PICKS UP THE CRUCIBLE**/
|
|
||||||
if(pItem.isEmpty()){
|
|
||||||
if(!player.isSneaking()) {
|
|
||||||
CrucibleCrafting recipe = CrucibleCrafting.getRecipe(tile.ingList.get(0), tile.ingList.get(1), tile.ingList.get(2), tile.ingList.get(3), tile.ingList.get(4));
|
|
||||||
if(recipe != null){
|
|
||||||
tile.setDrops(recipe.getDropsRaw());
|
|
||||||
}
|
|
||||||
return takeBlock(world, pos, state, face, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**SET INGREDIENT ARRAY FOR THE CRUCIBLE NOW**/
|
/**SET INGREDIENT ARRAY FOR THE CRUCIBLE NOW**/
|
||||||
if(!player.isSneaking()) {
|
if(player.isSneaking() == false) {
|
||||||
if(!pItem.isEmpty()) {
|
if(!pItem.isEmpty()) {
|
||||||
if(pItem.getItem() instanceof SlottedTongs) {
|
if(pItem.getItem() instanceof SlottedTongs) {
|
||||||
return false;
|
return false;
|
||||||
@@ -99,14 +80,46 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**CLEARS THE INVENTORY**/
|
||||||
|
if (player.isSneaking() == true) {
|
||||||
|
if(pItem.isEmpty()) {
|
||||||
|
for (int i = 0; i < tile.ingList.size(); i++) {
|
||||||
|
if (!tile.ingList.get(i).isEmpty()) {
|
||||||
|
PlayerHelper.spawnItemOnPlayer(world, player, tile.ingList.get(i));
|
||||||
|
tile.ingList.set(i, ItemStack.EMPTY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tile.update();
|
||||||
|
tile.markDirty();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**PICKS UP THE CRUCIBLE**/
|
||||||
|
if(player.isSneaking() == false) {
|
||||||
|
|
||||||
|
if(pItem.isEmpty()){
|
||||||
|
CrucibleCrafting recipe = CrucibleCrafting.getRecipe(tile.ingList.get(0), tile.ingList.get(1), tile.ingList.get(2), tile.ingList.get(3), tile.ingList.get(4));
|
||||||
|
if(recipe != null){
|
||||||
|
tile.setDrops(recipe.getDropsRaw());
|
||||||
|
}
|
||||||
|
PlayerHelper.playerTakeItem(world, pos, EnumFacing.DOWN, player, player.getActiveHand(), this.getItem(world, pos, state));
|
||||||
|
world.setBlockState(pos, this.getReplacementBlock(world, pos, state));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IBlockState getReplacementBlock(World world, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
return Blocks.AIR.getDefaultState();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest)
|
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest)
|
||||||
{
|
{
|
||||||
|
System.out.println("Removed by player");
|
||||||
this.onBlockHarvested(world, pos, state, player);
|
this.onBlockHarvested(world, pos, state, player);
|
||||||
return this.takeBlock(world, pos, state, EnumFacing.UP, player);
|
return this.takeBlock(world, pos, state, EnumFacing.UP, player);
|
||||||
}
|
}
|
||||||
@@ -119,18 +132,13 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider,
|
|||||||
|
|
||||||
public boolean takeBlock(World world, BlockPos pos, IBlockState state, EnumFacing face, EntityPlayer player)
|
public boolean takeBlock(World world, BlockPos pos, IBlockState state, EnumFacing face, EntityPlayer player)
|
||||||
{
|
{
|
||||||
if (world.isRemote)
|
if (!world.isRemote) {
|
||||||
return true;
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
|
if (tile instanceof TileNBTCrucible) {
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
PlayerHelper.playerTakeItem(world, pos, EnumFacing.DOWN, player, player.getActiveHand(), this.getItem(world, pos, state));
|
||||||
if (tile instanceof TileNBTCrucible) {
|
return world.setBlockState(pos, this.getReplacementBlock(world, pos, state));
|
||||||
//World world, BlockPos pos, EnumFacing face, EntityPlayer player, EnumHand hand, ItemStack stack
|
}
|
||||||
PlayerHelper.playerTakeItem(world, pos, EnumFacing.DOWN, player, player.getActiveHand(), this.getItem(world, pos, state));
|
|
||||||
|
|
||||||
//world.updateComparatorOutputLevel(pos, state.getBlock());
|
|
||||||
return world.setBlockState(pos, this.getReplacementBlock(world, pos, state));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,10 +149,8 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider,
|
|||||||
TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos);
|
TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos);
|
||||||
ItemStack pItem = player.inventory.getCurrentItem();
|
ItemStack pItem = player.inventory.getCurrentItem();
|
||||||
CrucibleCrafting recipe = CrucibleCrafting.getRecipe(tile.ingList.get(0), tile.ingList.get(1), tile.ingList.get(2), tile.ingList.get(3), tile.ingList.get(4));
|
CrucibleCrafting recipe = CrucibleCrafting.getRecipe(tile.ingList.get(0), tile.ingList.get(1), tile.ingList.get(2), tile.ingList.get(3), tile.ingList.get(4));
|
||||||
System.out.println("Harvested" + tile.getStatus() + " | " + tile.getHot());
|
|
||||||
if(recipe != null && tile.getStatus() && !tile.getHot()){
|
if(recipe != null && tile.getStatus() && !tile.getHot()){
|
||||||
PlayerHelper.spawnItemOnPlayer(world, player, tile.getDrops());
|
PlayerHelper.spawnItemOnPlayer(world, player, tile.getDrops());
|
||||||
System.out.println("Drop stuff");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,35 +166,54 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider,
|
|||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||||
{
|
{
|
||||||
TileEntity tileentity = world.getTileEntity(pos);
|
TileEntity tileentity = world.getTileEntity(pos);
|
||||||
if (tileentity instanceof TileNBTCrucible)
|
if (tileentity instanceof TileNBTCrucible) {
|
||||||
{
|
|
||||||
TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos);
|
TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos);
|
||||||
NBTTagCompound tag = stack.getSubCompound("BlockEntityTag").copy();
|
if(NBTHelper.hasNBT(stack)){
|
||||||
//tile.writeNBT(tag);
|
NBTTagCompound tag = stack.getSubCompound("BlockEntityTag").copy();
|
||||||
tile.setHot(tag.getBoolean("hot"));
|
if(tag.getBoolean("hot")){
|
||||||
tile.markDirty();
|
world.setBlockState(pos, state.withProperty(PrimalAPI.States.ACTIVE, true), 2);
|
||||||
tile.updateBlock();
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
|
public int getMetaFromState(IBlockState state) {
|
||||||
{
|
int i = 0;
|
||||||
TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos);
|
|
||||||
if (tile != null && tile instanceof TileNBTCrucible) {
|
if( state.getValue(PrimalAPI.States.ACTIVE) == false){
|
||||||
System.out.println("Hot:" + tile.getHot() + " Status: " + tile.getStatus());
|
i = 0;
|
||||||
if(tile.getHot()){
|
return i;
|
||||||
System.out.println("Should Be Red");
|
|
||||||
return state.withProperty(PrimalAPI.States.ACTIVE, true);
|
|
||||||
}
|
|
||||||
if(!tile.getHot()){
|
|
||||||
System.out.println("Should Be Brown");
|
|
||||||
return state.withProperty(PrimalAPI.States.ACTIVE, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return state;
|
|
||||||
|
if( state.getValue(PrimalAPI.States.ACTIVE) == true) {
|
||||||
|
i = 1;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockState getStateFromMeta(int meta) {
|
||||||
|
|
||||||
|
IBlockState iblockstate = this.getDefaultState();
|
||||||
|
|
||||||
|
if (meta == 0){
|
||||||
|
iblockstate = iblockstate.withProperty(PrimalAPI.States.ACTIVE, false);
|
||||||
|
}
|
||||||
|
if (meta == 1){
|
||||||
|
iblockstate = iblockstate.withProperty(PrimalAPI.States.ACTIVE, true);
|
||||||
|
}
|
||||||
|
return iblockstate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlockStateContainer createBlockState() {
|
||||||
|
return new BlockStateContainer(this, new IProperty[] {PrimalAPI.States.ACTIVE});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int quantityDropped(Random random)
|
public int quantityDropped(Random random)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.util.ITickable;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import nmd.primal.core.api.PrimalAPI;
|
||||||
import nmd.primal.forgecraft.crafting.CrucibleCrafting;
|
import nmd.primal.forgecraft.crafting.CrucibleCrafting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,22 +68,20 @@ public class TileNBTCrucible extends BaseTile implements ITickable {
|
|||||||
@Override
|
@Override
|
||||||
public void update () {
|
public void update () {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
//World world = this.getWorld();
|
World world = this.getWorld();
|
||||||
//IBlockState state = world.getBlockState(this.pos);
|
IBlockState state = world.getBlockState(this.pos);
|
||||||
|
|
||||||
coolManager();
|
coolManager(this.pos, world, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void coolManager() {
|
private void coolManager(BlockPos pos, World world, IBlockState state) {
|
||||||
System.out.println(this.getHeat() + " " + this.getHot() + " " + this.getDrops());
|
//System.out.println(this.getHeat() + " " + this.getHot() + " " + this.getDrops());
|
||||||
if(this.getHot()){
|
if(this.getHot()){
|
||||||
//System.out.println("Still Hot");
|
//System.out.println("Still Hot");
|
||||||
if(this.getHeat() > 0){
|
if(this.getHeat() > 0){
|
||||||
this.setHeat( this.getHeat() - 1);
|
this.setHeat( this.getHeat() - 1);
|
||||||
System.out.println(this.getHeat());
|
world.setBlockState(pos, state.withProperty(PrimalAPI.States.ACTIVE, true), 2);
|
||||||
//this.updateBlock();
|
|
||||||
//this.markDirty();
|
|
||||||
}
|
}
|
||||||
if(this.getHeat() == 0){
|
if(this.getHeat() == 0){
|
||||||
this.setHot(false);
|
this.setHot(false);
|
||||||
@@ -89,8 +89,10 @@ public class TileNBTCrucible extends BaseTile implements ITickable {
|
|||||||
this.setDrops(recipe.getDropsCooked());
|
this.setDrops(recipe.getDropsCooked());
|
||||||
this.setStatus(false);
|
this.setStatus(false);
|
||||||
System.out.println("Ready to harvest: " + this.getDrops());
|
System.out.println("Ready to harvest: " + this.getDrops());
|
||||||
|
world.setBlockState(pos, state.withProperty(PrimalAPI.States.ACTIVE, false), 2);
|
||||||
this.updateBlock();
|
this.updateBlock();
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
|
|
||||||
}
|
}
|
||||||
//CrucibleCrafting recipe = CrucibleCrafting.getRecipe(ingList.get(0), ingList.get(1), ingList.get(2), ingList.get(3), ingList.get(4));
|
//CrucibleCrafting recipe = CrucibleCrafting.getRecipe(ingList.get(0), ingList.get(1), ingList.get(2), ingList.get(3), ingList.get(4));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
{
|
{
|
||||||
"forge_marker":1,
|
"forge_marker":1,
|
||||||
"variants": {
|
"variants": {
|
||||||
"normal": {
|
"active": {
|
||||||
"active": {
|
"false": {
|
||||||
"true": {
|
"textures": {
|
||||||
"textures": {
|
"particle": "forgecraft:blocks/stone_slab",
|
||||||
"particle": "forgecraft:blocks/stone_slab_hot",
|
"texture": "forgecraft:blocks/stone_slab"
|
||||||
"texture": "forgecraft:blocks/stone_slab_hot"
|
|
||||||
},
|
|
||||||
"model": "forgecraft:crucibleshut"
|
|
||||||
},
|
},
|
||||||
"false": {
|
"model": "forgecraft:crucibleshut"
|
||||||
"textures": {
|
},
|
||||||
"particle": "forgecraft:blocks/stone_slab",
|
"true": {
|
||||||
"texture": "forgecraft:blocks/stone_slab"
|
"textures": {
|
||||||
},
|
"particle": "forgecraft:blocks/stone_slab_hot",
|
||||||
"model": "forgecraft:crucibleshut"
|
"texture": "forgecraft:blocks/stone_slab_hot"
|
||||||
}
|
},
|
||||||
|
"model": "forgecraft:crucibleshut"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user