need to use state with executing state

This commit is contained in:
Mohammad-Ali Minaie
2018-03-10 22:09:34 -05:00
parent 4bb3b25286
commit adae8e3d82
8 changed files with 77 additions and 85 deletions

View File

@@ -3,6 +3,7 @@ package nmd.primal.forgecraft.blocks.Crucibles;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -18,7 +19,10 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import nmd.primal.core.api.PrimalAPI;
import nmd.primal.core.api.interfaces.IPickup;
import nmd.primal.core.api.interfaces.types.ITypeNBT;
import nmd.primal.core.api.interfaces.types.ITypeWood;
import nmd.primal.core.common.helper.NBTHelper;
import nmd.primal.core.common.helper.PlayerHelper;
import nmd.primal.forgecraft.ModInfo;
@@ -54,6 +58,18 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider,
TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos);
ItemStack pItem = player.inventory.getCurrentItem();
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()) {
@@ -82,18 +98,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider,
}
}
}
/**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;
}
}
return false;
}
@@ -152,57 +157,30 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider,
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
if (stack.hasDisplayName())
{
TileEntity tileentity = world.getTileEntity(pos);
//world.setBlockState(pos, state.withProperty(PrimalAPI.States.ACTIVE, Boolean.valueOf(false)), 2);
if (tileentity instanceof TileNBTCrucible)
{
//((TileStorageCrate)tileentity).setCustomName(stack.getDisplayName());
getActualState(state, world, pos);
}
}
}
/*@Override
public int getMetaFromState(IBlockState state) {
int i = 0;
if( (state.getValue(PrimalAPI.States.ACTIVE) == false)) {
i = 0;
return i;
}
if ( (state.getValue(PrimalAPI.States.ACTIVE) == true)) {
i = 14;
return i;
}
return i;
}
@Override
public IBlockState getStateFromMeta(int meta) {
EnumFacing enumfacing;
Boolean active;
switch (meta & 7)
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
{
case 0:
active = false;
break;
case 1:
active = true;
break;
default:
active = false;
TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos);
if (tile != null && tile instanceof TileNBTCrucible) {
System.out.println("Hot:" + tile.getHot() + " Status: " + tile.getStatus());
if(tile.getHot()){
return state.withProperty(PrimalAPI.States.ACTIVE, true);
}
return this.getDefaultState().withProperty(PrimalAPI.States.ACTIVE, Boolean.valueOf(active));
if(!tile.getHot()){
return state.withProperty(PrimalAPI.States.ACTIVE, true);
}
}
return state;
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[] {PrimalAPI.States.ACTIVE});
}*/
@Override
public int quantityDropped(Random random)

View File

@@ -32,8 +32,8 @@ public class ModCrafting{
new ItemStack(Blocks.IRON_ORE, 1),
new ItemStack(ModBlocks.ironball, 1),
100,
200,
100);
100,
1000);
/***CASTING BLOCK***/
RecipeHandler.addShapedOreRecipe(new ItemStack(ModBlocks.castingblock),

View File

@@ -37,23 +37,23 @@ public class ItemNBTCrucible extends ItemBlock {
{
//TODO get the item name
if (item.hasTagCompound()) {
if (getStatus(item)){
if (getHot(item)){
//System.out.println("Should be Red");
return 0.1f;
}
} else if (item.hasTagCompound()) {
if (!getStatus(item)){
}
if (item.hasTagCompound()) {
if (!getHot(item)){
//System.out.println("Should be Brown");
return 0.0f;
}
}
else {
return 0.0F;
}
return 0.0F;
}
});
}
public boolean getStatus(ItemStack stack) {
public boolean getHot(ItemStack stack) {
if(!stack.isEmpty()) {
if (stack.hasTagCompound()) {
return stack.getSubCompound("BlockEntityTag").getBoolean("hot");
@@ -71,11 +71,13 @@ public class ItemNBTCrucible extends ItemBlock {
NBTTagCompound tag = item.getSubCompound("BlockEntityTag");
//item.getTagCompound().setTag("BlockEntityTag", tags);
System.out.println(tag.getBoolean("hot"));
//System.out.println(tag.getBoolean("hot"));
}
}
}
}

View File

@@ -4,6 +4,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemBlock;
@@ -68,7 +69,8 @@ public class TileBloomeryRender extends TileEntitySpecialRenderer<TileBloomery>
if (!stack1.isEmpty()) {
GL11.glPushMatrix();
GL11.glTranslated(0, 0.50D, 0);
renderItem.renderItem(stack1, renderItem.getItemModelMesher().getItemModel(stack1));
//renderItem.renderItem(stack1, renderItem.getItemModelMesher().getItemModel(stack1));
renderItem.renderItem(stack1, ItemCameraTransforms.TransformType.FIXED);
GL11.glPopMatrix();
}

View File

@@ -93,11 +93,17 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
if (this.getHeat() >= recipe.getCookTemp() &&
!this.getSlotStack(1).getSubCompound("BlockEntityTag").getBoolean("status")) {
cookCounter++;
this.getSlotStack(1).getSubCompound("BlockEntityTag").setBoolean("hot", true);
//this.getSlotStack(1).getSubCompound("BlockEntityTag").setBoolean("hot", true);
System.out.println("Cooking");
this.updateBlock();
this.markDirty();
}
if (cookCounter >= (recipe.getCookTime()/4) && !this.getSlotStack(1).getSubCompound("BlockEntityTag").getBoolean("status")) {
this.getSlotStack(1).getSubCompound("BlockEntityTag").setBoolean("hot", true);
System.out.println("hot");
this.updateBlock();
this.markDirty();
}
if (cookCounter >= recipe.getCookTime() && !this.getSlotStack(1).getSubCompound("BlockEntityTag").getBoolean("status")) {
this.getSlotStack(1).getSubCompound("BlockEntityTag").setBoolean("status", true);
this.getSlotStack(1).getSubCompound("BlockEntityTag").setInteger("heat", this.getHeat());

View File

@@ -66,16 +66,17 @@ public class TileNBTCrucible extends BaseTile implements ITickable {
@Override
public void update () {
if (!world.isRemote) {
World world = this.getWorld();
IBlockState state = world.getBlockState(this.pos);
//World world = this.getWorld();
//IBlockState state = world.getBlockState(this.pos);
coolManager();
}
}
private void coolManager() {
System.out.println(this.getHeat() + " " + this.getStatus() + " " + this.getDrops());
System.out.println(this.getHeat() + " " + this.getHot() + " " + this.getDrops());
if(this.getHot()){
System.out.println("Still Hot");
//System.out.println("Still Hot");
if(this.getHeat() > 0){
this.setHeat( this.getHeat() - 1);
System.out.println(this.getHeat());

View File

@@ -1,12 +1,19 @@
{
"forge_marker":1,
"defaults": {
"variants": {
"normal": { "model": "forgecraft:crucibleshut" },
"active=false": {
"textures": {
"particle": "forgecraft:blocks/stone_slab",
"texture": "forgecraft:blocks/stone_slab"
}
},
"variants": {
"normal": { "model": "forgecraft:crucibleshut" }
"active=true": {
"textures": {
"particle": "forgecraft:blocks/stone_slab_hot",
"texture": "forgecraft:blocks/stone_slab_hot"
}
}
}
}

View File

@@ -2,11 +2,7 @@
"modid": "forgecraft",
"name": "Kitsu's Forgecraft",
"description": "Forged with sweat and blood",
<<<<<<< HEAD
"version": "1.4.01",
=======
"version": "1.4.06",
>>>>>>> master-1.12
"mcversion": "1.12.2",
"url": "",
"updateUrl": "",