all the bug fixes, refactoring, and feauture upgrades

This commit is contained in:
Mohammad-Ali Minaie
2017-06-11 17:42:50 -04:00
parent b7d2b6580a
commit 8ae050bddd
22 changed files with 514 additions and 321 deletions

View File

@@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx3G
mod_group=nmd.primal.forgecraft
mod_name=ForgeCraft
mod_version=1.2.23
mod_version=1.2.30
forge_version=13.20.0.2311
mcp_mappings=snapshot_20170121
mc_version=1.11.2

View File

@@ -16,7 +16,7 @@ public class ModInfo {
public static final String MOD_NAME = "Kitsu's ForgeCraft";
//public static final String MOD_PREFIX = MOD_ID + ":";
public static final String MOD_CHANNEL = MOD_ID;
public static final String MOD_VERSION = "1.2.23";
public static final String MOD_VERSION = "1.2.30";
public static final String MC_VERSIONS = "[1.11.0, 1.12.0)";
public static final String DEPENDENCIES = "required-after:forge@[13.20.0.2226,);" + "required-after:primal@[0.4,);";

View File

@@ -0,0 +1,147 @@
package nmd.primal.forgecraft.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
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.forgecraft.ModInfo;
import nmd.primal.forgecraft.tiles.TileAnvil;
import nmd.primal.forgecraft.util.AnvilHandler;
/**
* Created by mminaie on 6/11/17.
*/
public abstract class AnvilBase extends CustomContainerFacing implements AnvilHandler{
private boolean anvil;
public AnvilBase(Material material, String registryName, Float hardness, Boolean anvil) {
super(material);
setUnlocalizedName(registryName);
setRegistryName(registryName);
setCreativeTab(ModInfo.TAB_FORGECRAFT);
setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
setHardness(hardness);
this.setIsAnvil(anvil);
}
public boolean isAnvil() {
return anvil;
}
public void setIsAnvil(boolean anvil) {
anvil = anvil;
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
AnvilHandler.doDrops(world, pos);
super.breakBlock(world, pos, state);
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileAnvil();
}
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
//if(!worldIn.isRemote) {
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()), 2);
//}
}
@Override
public int getMetaFromState(IBlockState state) {
int i = 0;
if( state.getValue(FACING) == EnumFacing.EAST) {
i = 0;
return i;
}
if( state.getValue(FACING) == EnumFacing.WEST) {
i = 1;
return i;
}
if( state.getValue(FACING) == EnumFacing.SOUTH){
i = 2;
return i;
}
if( state.getValue(FACING) == EnumFacing.NORTH){
i = 3;
return i;
}
return i;
}
@Override
public IBlockState getStateFromMeta(int meta)
{
IBlockState iblockstate = this.getDefaultState();
if (meta == 0){
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST);
}
if (meta == 1) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST);
}
if (meta == 2) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH);
}
if (meta == 3) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH);
}
return iblockstate;
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[] {FACING});
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean isFullyOpaque(IBlockState state)
{
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
{
return true;
}
@Override
public EnumBlockRenderType getRenderType(IBlockState state)
{
return EnumBlockRenderType.MODEL;
}
}

View File

@@ -1,7 +1,78 @@
package nmd.primal.forgecraft.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
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.PrimalItems;
import nmd.primal.core.api.PrimalMaterials;
import nmd.primal.core.common.items.tools.WorkMallet;
import nmd.primal.forgecraft.CommonUtils;
import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.init.ModBlocks;
import nmd.primal.forgecraft.init.ModItems;
import nmd.primal.forgecraft.items.BaseMultiItem;
import nmd.primal.forgecraft.tiles.TileAnvil;
import nmd.primal.forgecraft.util.AnvilHandler;
/**
* Created by mminaie on 6/10/17.
*/
public class AnvilIron {
public class AnvilIron extends AnvilBase implements AnvilHandler {
public AnvilIron(Material material, String registryName, Float hardness, Boolean anvil) {
super(material, registryName, hardness, anvil);
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitx, float hity, float hitz) {
/******************************************************************************
Crafting AnvilStone Recipes
*****************************************************************************/
if (!world.isRemote) {
ItemStack pItem = player.inventory.getCurrentItem();
TileAnvil tile = (TileAnvil) world.getTileEntity(pos);
if (tile != null) {
if ((pItem.getItem() instanceof WorkMallet) || (pItem.getItem() == ModItems.forgehammer)) {
String[] tempArray = new String[25];
for (int i = 0; i < 25; i++) {
tempArray[i] = tile.getSlotStack(i).getItem().getRegistryName().toString();
}
/*for (int i = 0; i < 25; i++) {
if (tile.getSlotStack(i).getItem() instanceof BaseMultiItem) {
if (((BaseMultiItem) tile.getSlotStack(i).getItem()).getMaterial(tile.getSlotStack(i).getItem()) != PrimalMaterials.TOOL_BASIC_STEEL
|| ((BaseMultiItem) tile.getSlotStack(i).getItem()).getMaterial(tile.getSlotStack(i).getItem()) != PrimalMaterials.TOOL_CLEAN_IRON
|| ((BaseMultiItem) tile.getSlotStack(i).getItem()).getMaterial(tile.getSlotStack(i).getItem()) != PrimalMaterials.TOOL_WROUGHT_IRON
) {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
CommonUtils.spawnItemEntityFromWorld(world, pos, new ItemStack(PrimalItems.ROCK_STONE, 3));
CommonUtils.spawnItemEntityFromWorld(world, pos, new ItemStack(ModBlocks.ironball, 1));
this.breakBlock(world, pos, state);
}
}
}*/
doAnvilRecipe(pItem, tempArray, world, tile, pos, player);
return true;
}
doAnvilInventoryManager(pItem, world, tile, pos, hitx, hity, hitz, state, player);
return true;
}
}
return false;
}
}

View File

@@ -41,50 +41,15 @@ import java.util.concurrent.ThreadLocalRandom;
/**
* Created by mminaie on 3/4/17.
*/
public class AnvilStone extends CustomContainerFacing implements AnvilHandler {
public class AnvilStone extends AnvilBase {
/*
double[] normalMin = {0.0625, 0.25, 0.4375, 0.625, 0.8125};
public double getNormalMin(Integer x) {
return normalMin[x];
}
double[] normalMax = {0.1875, 0.375, 0.5625, 0.75, 0.9375};
public double getNormalMax(Integer x) {
return normalMax[x];
}
double[] reverseMin = {0.8125, 0.625, 0.4375, 0.25, 0.0625};
public double getReverseMin(Integer x) {
return reverseMin[x];
}
double[] reverseMax = {0.9375, 0.75, 0.5625, 0.375, 0.1875};
public double getReverseMax(Integer x) {
return reverseMax[x];
}
*/
public AnvilStone(Material material, String registryName, Float hardness) {
super(material);
setUnlocalizedName(registryName);
setRegistryName(registryName);
setCreativeTab(ModInfo.TAB_FORGECRAFT);
setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
setHardness(hardness);
public AnvilStone(Material material, String registryName, Float hardness, Boolean anvil) {
super(material, registryName, hardness, anvil);
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitx, float hity, float hitz) {
/*if (!player.isSwingInProgress) {
player.swingArm(hand);
}*/
/******************************************************************************
Crafting AnvilStone Recipes
*****************************************************************************/
@@ -116,124 +81,4 @@ public class AnvilStone extends CustomContainerFacing implements AnvilHandler {
}
return false;
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
if (!world.isRemote && world.getGameRules().getBoolean("doTileDrops"))
{
TileAnvil tile = (TileAnvil) world.getTileEntity(pos);
if (tile !=null)
{
for (ItemStack stack : tile.getSlotList())
{
if (stack != null) {
float offset = 0.7F;
double offsetX = world.rand.nextFloat() * offset + (1.0F - offset) * 0.5D;
double offsetY = world.rand.nextFloat() * offset + (1.0F - offset) * 0.5D;
double offsetZ = world.rand.nextFloat() * offset + (1.0F - offset) * 0.5D;
EntityItem item = new EntityItem(world, pos.getX() + offsetX, pos.getY() + offsetY, pos.getZ() + offsetZ, stack);
item.setDefaultPickupDelay();
world.spawnEntity(item);
}
}
}
}
super.breakBlock(world, pos, state);
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileAnvil();
}
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
//if(!worldIn.isRemote) {
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()), 2);
//}
}
@Override
public int getMetaFromState(IBlockState state) {
int i = 0;
if( state.getValue(FACING) == EnumFacing.EAST) {
i = 0;
return i;
}
if( state.getValue(FACING) == EnumFacing.WEST) {
i = 1;
return i;
}
if( state.getValue(FACING) == EnumFacing.SOUTH){
i = 2;
return i;
}
if( state.getValue(FACING) == EnumFacing.NORTH){
i = 3;
return i;
}
return i;
}
@Override
public IBlockState getStateFromMeta(int meta)
{
IBlockState iblockstate = this.getDefaultState();
if (meta == 0){
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST);
}
if (meta == 1) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST);
}
if (meta == 2) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH);
}
if (meta == 3) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH);
}
return iblockstate;
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[] {FACING});
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean isFullyOpaque(IBlockState state)
{
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
{
return true;
}
@Override
public EnumBlockRenderType getRenderType(IBlockState state)
{
return EnumBlockRenderType.MODEL;
}
}

View File

@@ -12,6 +12,7 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
@@ -23,6 +24,9 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import nmd.primal.core.api.PrimalItems;
import nmd.primal.core.api.PrimalStates;
import nmd.primal.core.common.crafting.FireSource;
import nmd.primal.core.common.helper.PlayerHelper;
import nmd.primal.forgecraft.CommonUtils;
import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.crafting.BloomeryCrafting;
@@ -38,7 +42,7 @@ import static nmd.primal.core.common.helper.FireHelper.makeSmoke;
*/
public class Bloomery extends CustomContainerFacing implements ITileEntityProvider {
public static final PropertyBool ACTIVE = PropertyBool.create("active");
//public static final PropertyBool PrimalStates.ACTIVE = PropertyBool.create("PrimalStates.ACTIVE");
public static final PropertyBool COVERED = PropertyBool.create("covered");
public Bloomery(Material material, String registryName) {
@@ -47,7 +51,7 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
setRegistryName(registryName);
//setRegistryName(ModInfo.ForgecraftBlocks.FIREBOX.getRegistryName());
setCreativeTab(ModInfo.TAB_FORGECRAFT);
setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, Boolean.valueOf(false)));
setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(false)));
setHardness(3.0f);
}
@@ -62,7 +66,7 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
{
this.updateTick(world, pos, state, random);
if(!world.isRemote){
if(state.getValue(ACTIVE) == true) {
if(state.getValue(PrimalStates.ACTIVE) == true) {
makeSmoke(world, pos);
}
}
@@ -79,18 +83,8 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
ItemStack tileItem1 = tile.getSlotStack(1);
if(pItem.isEmpty()) {
if (player.isSneaking()) {
if (!tileItem.isEmpty()) {
CommonUtils.spawnItemEntity(world, player, tile.getSlotStack(0));
tile.setSlotStack(0, ItemStack.EMPTY);
tile.markDirty();
tile.updateBlock();
return true;
}
}
if(!player.isSneaking()){
if(world.getBlockState(pos).getValue(ACTIVE) == true){
if(world.getBlockState(pos).getValue(PrimalStates.ACTIVE) == true){
Integer bloomeryHeat = tile.getHeat();
Integer idealTemp = null;
Integer cookCounter = tile.getCookCounter();
@@ -119,11 +113,8 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
}
}
if(tile.getSlotStack(0) != ItemStack.EMPTY) {
if((pItem.getItem() == Items.FLINT_AND_STEEL) ||
(pItem.getItem() == PrimalItems.FIRE_BOW) ||
pItem.getItem() == PrimalItems.TORCH_WOOD_LIT ||
pItem.getItem() == PrimalItems.TORCH_NETHER_LIT ) {
world.setBlockState(pos, state.withProperty(ACTIVE, true), 2);
if((FireSource.useSource(world, pos, player, pItem, hand, facing, hitX, hitY, hitZ))) {
world.setBlockState(pos, state.withProperty(PrimalStates.ACTIVE, true), 2);
tile.setHeat(100);
tile.markDirty();
tile.updateBlock();
@@ -169,6 +160,16 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
return true;
}
}
if (player.isSneaking()) {
if (!tile.getSlotStack(0).isEmpty()) {
if(player.inventory.getCurrentItem().getItem() instanceof ItemSpade) {
ItemStack returnStack = tile.getSlotStack(0).copy();
PlayerHelper.spawnItemOnPlayer(world, player, returnStack);
tile.clearSlot(0);
return true;
}
}
}
}
}
return false;
@@ -179,7 +180,7 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos)
{
int lightState =0;
if(state.getValue(ACTIVE) == true){
if(state.getValue(PrimalStates.ACTIVE) == true){
lightState = 10;
}
return lightState;
@@ -199,7 +200,7 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
public boolean isFireSource(World world, BlockPos pos, EnumFacing side)
{
if(!world.isRemote){
if(world.getBlockState(pos).getValue(ACTIVE)==true){
if(world.getBlockState(pos).getValue(PrimalStates.ACTIVE)==true){
return true;
}
}
@@ -210,7 +211,7 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity ent)
{
if(ent instanceof EntityPlayer){
if(state.getValue(ACTIVE) == true){
if(state.getValue(PrimalStates.ACTIVE) == true){
ent.setFire(1);
}
}
@@ -248,7 +249,7 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
if(!worldIn.isRemote){
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()).withProperty(ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(false)), 2);
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(false)), 2);
}
}
@@ -257,67 +258,67 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
public int getMetaFromState(IBlockState state) {
int i = 0;
if( state.getValue(FACING) == EnumFacing.EAST && state.getValue(ACTIVE) == false && state.getValue(COVERED) == false){
if( state.getValue(FACING) == EnumFacing.EAST && state.getValue(PrimalStates.ACTIVE) == false && state.getValue(COVERED) == false){
i = 0;
return i;
}
if( state.getValue(FACING) == EnumFacing.WEST && state.getValue(ACTIVE) == false && state.getValue(COVERED) == false){
if( state.getValue(FACING) == EnumFacing.WEST && state.getValue(PrimalStates.ACTIVE) == false && state.getValue(COVERED) == false){
i = 1;
return i;
}
if( state.getValue(FACING) == EnumFacing.SOUTH && state.getValue(ACTIVE) == false && state.getValue(COVERED) == false){
if( state.getValue(FACING) == EnumFacing.SOUTH && state.getValue(PrimalStates.ACTIVE) == false && state.getValue(COVERED) == false){
i = 2;
return i;
}
if( state.getValue(FACING) == EnumFacing.NORTH && state.getValue(ACTIVE) == false && state.getValue(COVERED) == false){
if( state.getValue(FACING) == EnumFacing.NORTH && state.getValue(PrimalStates.ACTIVE) == false && state.getValue(COVERED) == false){
i = 3;
return i;
}
if( state.getValue(FACING) == EnumFacing.EAST && state.getValue(ACTIVE) == true && state.getValue(COVERED) == false){
if( state.getValue(FACING) == EnumFacing.EAST && state.getValue(PrimalStates.ACTIVE) == true && state.getValue(COVERED) == false){
i = 4;
return i;
}
if( state.getValue(FACING) == EnumFacing.WEST && state.getValue(ACTIVE) == true && state.getValue(COVERED) == false){
if( state.getValue(FACING) == EnumFacing.WEST && state.getValue(PrimalStates.ACTIVE) == true && state.getValue(COVERED) == false){
i = 5;
return i;
}
if( state.getValue(FACING) == EnumFacing.SOUTH && state.getValue(ACTIVE) == true && state.getValue(COVERED) == false){
if( state.getValue(FACING) == EnumFacing.SOUTH && state.getValue(PrimalStates.ACTIVE) == true && state.getValue(COVERED) == false){
i = 6;
return i;
}
if( state.getValue(FACING) == EnumFacing.NORTH && state.getValue(ACTIVE) == true && state.getValue(COVERED) == false){
if( state.getValue(FACING) == EnumFacing.NORTH && state.getValue(PrimalStates.ACTIVE) == true && state.getValue(COVERED) == false){
i = 7;
return i;
}
if( state.getValue(FACING) == EnumFacing.EAST && state.getValue(ACTIVE) == true && state.getValue(COVERED) == true){
if( state.getValue(FACING) == EnumFacing.EAST && state.getValue(PrimalStates.ACTIVE) == true && state.getValue(COVERED) == true){
i = 8;
return i;
}
if( state.getValue(FACING) == EnumFacing.WEST && state.getValue(ACTIVE) == true && state.getValue(COVERED) == true){
if( state.getValue(FACING) == EnumFacing.WEST && state.getValue(PrimalStates.ACTIVE) == true && state.getValue(COVERED) == true){
i = 9;
return i;
}
if( state.getValue(FACING) == EnumFacing.SOUTH && state.getValue(ACTIVE) == true && state.getValue(COVERED) == true){
if( state.getValue(FACING) == EnumFacing.SOUTH && state.getValue(PrimalStates.ACTIVE) == true && state.getValue(COVERED) == true){
i = 10;
return i;
}
if( state.getValue(FACING) == EnumFacing.NORTH && state.getValue(ACTIVE) == true && state.getValue(COVERED) == true){
if( state.getValue(FACING) == EnumFacing.NORTH && state.getValue(PrimalStates.ACTIVE) == true && state.getValue(COVERED) == true){
i = 11;
return i;
}
if( state.getValue(FACING) == EnumFacing.EAST && state.getValue(ACTIVE) == false && state.getValue(COVERED) == true){
if( state.getValue(FACING) == EnumFacing.EAST && state.getValue(PrimalStates.ACTIVE) == false && state.getValue(COVERED) == true){
i = 12;
return i;
}
if( state.getValue(FACING) == EnumFacing.WEST && state.getValue(ACTIVE) == false && state.getValue(COVERED) == true){
if( state.getValue(FACING) == EnumFacing.WEST && state.getValue(PrimalStates.ACTIVE) == false && state.getValue(COVERED) == true){
i = 13;
return i;
}
if( state.getValue(FACING) == EnumFacing.SOUTH && state.getValue(ACTIVE) == false && state.getValue(COVERED) == true){
if( state.getValue(FACING) == EnumFacing.SOUTH && state.getValue(PrimalStates.ACTIVE) == false && state.getValue(COVERED) == true){
i = 14;
return i;
}
if( state.getValue(FACING) == EnumFacing.NORTH && state.getValue(ACTIVE) == false && state.getValue(COVERED) == true){
if( state.getValue(FACING) == EnumFacing.NORTH && state.getValue(PrimalStates.ACTIVE) == false && state.getValue(COVERED) == true){
i = 15;
return i;
}
@@ -330,59 +331,59 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
IBlockState iblockstate = this.getDefaultState();
if (meta == 0){
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST).withProperty(ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(false));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(false));
}
if (meta == 1) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST).withProperty(ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(false));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(false));
}
if (meta == 2) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH).withProperty(ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(false));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(false));
}
if (meta == 3) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(false));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(false));
}
if (meta == 4) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST).withProperty(ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(false));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(false));
}
if (meta == 5) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST).withProperty(ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(false));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(false));
}
if (meta == 6) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH).withProperty(ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(false));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(false));
}
if (meta == 7) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(false));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(false));
}
if (meta == 8) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST).withProperty(ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(true));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(true));
}
if (meta == 9) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST).withProperty(ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(true));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(true));
}
if (meta == 10) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH).withProperty(ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(true));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(true));
}
if (meta == 11) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(true));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(true)).withProperty(COVERED, Boolean.valueOf(true));
}
if (meta == 12) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST).withProperty(ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(true));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(true));
}
if (meta == 13) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST).withProperty(ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(true));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(true));
}
if (meta == 14) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH).withProperty(ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(true));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(true));
}
if (meta == 15) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(true));
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH).withProperty(PrimalStates.ACTIVE, Boolean.valueOf(false)).withProperty(COVERED, Boolean.valueOf(true));
}
return iblockstate;
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[] {FACING, ACTIVE, COVERED});
return new BlockStateContainer(this, new IProperty[] {FACING, PrimalStates.ACTIVE, COVERED});
}
@Override
@@ -420,7 +421,7 @@ public class Bloomery extends CustomContainerFacing implements ITileEntityProvid
@SuppressWarnings("incomplete-switch")
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand)
{
if(state.getValue(Forge.ACTIVE) == true)
if(state.getValue(PrimalStates.ACTIVE) == true)
{
double d0 = (double)pos.getX() + 0.5D;
double d1 = (double)pos.getY() + 0.2D;

View File

@@ -2,13 +2,11 @@ package nmd.primal.forgecraft.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
@@ -19,29 +17,23 @@ 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.PrimalItems;
import nmd.primal.core.common.helper.PlayerHelper;
import nmd.primal.core.api.PrimalStates;
import nmd.primal.core.common.items.tools.WorkMallet;
import nmd.primal.forgecraft.CommonUtils;
import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.tiles.TileBreaker;
import nmd.primal.forgecraft.util.BreakerHandler;
import java.util.concurrent.ThreadLocalRandom;
/**
* Created by mminaie on 4/9/17.
*/
public class Breaker extends CustomContainerFacing implements BreakerHandler {
public static final PropertyBool ACTIVE = PropertyBool.create("active");
public Breaker(Material material, String registryName, Float hardness) {
super(material);
setUnlocalizedName(registryName);
setRegistryName(registryName);
setCreativeTab(ModInfo.TAB_FORGECRAFT);
setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, false));
setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(PrimalStates.ACTIVE, false));
setHardness(hardness);
}
@@ -63,18 +55,18 @@ public class Breaker extends CustomContainerFacing implements BreakerHandler {
}
}*/
if(state.getValue(ACTIVE) == true && player.isSneaking() && pItem.isEmpty()){
world.setBlockState(pos, state.withProperty(FACING, state.getValue(FACING)).withProperty(ACTIVE, false));
if(state.getValue(PrimalStates.ACTIVE) == true && player.isSneaking() && pItem.isEmpty()){
world.setBlockState(pos, state.withProperty(FACING, state.getValue(FACING)).withProperty(PrimalStates.ACTIVE, false));
doBreaking(world, state, pos, tile);
tile.setCharge(0);
return true;
}
if(!player.isSneaking() && pItem.isEmpty()) {
if (!state.getValue(ACTIVE)) {
world.setBlockState(pos, state.withProperty(FACING, state.getValue(FACING)).withProperty(ACTIVE, true), 2);
if (!state.getValue(PrimalStates.ACTIVE)) {
world.setBlockState(pos, state.withProperty(FACING, state.getValue(FACING)).withProperty(PrimalStates.ACTIVE, true), 2);
return true;
}
if(state.getValue(ACTIVE)) {
if(state.getValue(PrimalStates.ACTIVE)) {
if (tile.getCharge() < 181) {
tile.setCharge(tile.getCharge() + 2.0f);
tile.updateBlock();
@@ -133,7 +125,7 @@ public class Breaker extends CustomContainerFacing implements BreakerHandler {
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
//if(!worldIn.isRemote) {
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()).withProperty(ACTIVE, false), 2);
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()).withProperty(PrimalStates.ACTIVE, false), 2);
//}
}
@@ -141,7 +133,7 @@ public class Breaker extends CustomContainerFacing implements BreakerHandler {
public int getMetaFromState(IBlockState state) {
int i = 0;
if(state.getValue(ACTIVE ) == false) {
if(state.getValue(PrimalStates.ACTIVE ) == false) {
if (state.getValue(FACING) == EnumFacing.EAST) {
i = 0;
return i;
@@ -160,7 +152,7 @@ public class Breaker extends CustomContainerFacing implements BreakerHandler {
}
}
if(state.getValue(ACTIVE)) {
if(state.getValue(PrimalStates.ACTIVE)) {
if (state.getValue(FACING) == EnumFacing.EAST) {
i = 4;
return i;
@@ -187,35 +179,35 @@ public class Breaker extends CustomContainerFacing implements BreakerHandler {
IBlockState iblockstate = this.getDefaultState();
if (meta == 0){
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST).withProperty(ACTIVE, false);
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST).withProperty(PrimalStates.ACTIVE, false);
}
if (meta == 1) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST).withProperty(ACTIVE, false);
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST).withProperty(PrimalStates.ACTIVE, false);
}
if (meta == 2) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH).withProperty(ACTIVE, false);
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH).withProperty(PrimalStates.ACTIVE, false);
}
if (meta == 3) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, false);
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH).withProperty(PrimalStates.ACTIVE, false);
}
if (meta == 4){
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST).withProperty(ACTIVE, true);
iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST).withProperty(PrimalStates.ACTIVE, true);
}
if (meta == 5) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST).withProperty(ACTIVE, true);
iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST).withProperty(PrimalStates.ACTIVE, true);
}
if (meta == 6) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH).withProperty(ACTIVE, true);
iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH).withProperty(PrimalStates.ACTIVE, true);
}
if (meta == 7) {
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, true);
iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH).withProperty(PrimalStates.ACTIVE, true);
}
return iblockstate;
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[] {ACTIVE, FACING});
return new BlockStateContainer(this, new IProperty[] {PrimalStates.ACTIVE, FACING});
}
@Override

View File

@@ -80,7 +80,8 @@ public class Crucible extends Block {
{
if(!world.isRemote){
spawnItemEntityFromWorld(world, pos, new ItemStack(ModBlocks.emptycrucible, 1));
if(this.getUnlocalizedName().equals("tile.emptycruciblecracked")){} else spawnItemEntityFromWorld(world, pos, new ItemStack(ModBlocks.emptycrucible, 1));
if(StringUtils.isEmpty(this.getUnlocalizedName()) == false) {
if(checkDrops(this.getUnlocalizedName()) != null) {
if (checkDrops(this.getUnlocalizedName()).equals(this.getUnlocalizedName())) {
@@ -118,6 +119,9 @@ public class Crucible extends Block {
if(name.equals("tile.rawwootzcrucible")){
string = this.getUnlocalizedName();
}
if(name.equals("tile.emptycruciblecracked")){
string = this.getUnlocalizedName();
}
return string;
}
@@ -139,6 +143,8 @@ public class Crucible extends Block {
return Item.getItemFromBlock(ModBlocks.wootzball);
} else if (name.equals("tile.rawcleanironcrucible")){
return PrimalItems.GOLDEN_STICK;
}else if (name.equals("tile.emptycruciblecracked")){
return Items.CLAY_BALL;
}
else return Items.AIR;
}

View File

@@ -13,6 +13,7 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
@@ -25,6 +26,8 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import nmd.primal.core.api.PrimalItems;
import nmd.primal.core.common.crafting.FireSource;
import nmd.primal.core.common.helper.PlayerHelper;
import nmd.primal.forgecraft.CommonUtils;
import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.items.parts.ToolPart;
@@ -91,19 +94,18 @@ public class Forge extends CustomContainerFacing implements ITileEntityProvider/
/***********************
FUEL SLOT CODE
***********************/
if(pItem.isEmpty()) {
if (player.isSneaking()) {
if (!fuelItem.isEmpty()) {
if(facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH || facing == EnumFacing.EAST || facing == EnumFacing.WEST ) {
//System.out.println();
CommonUtils.spawnItemEntity(world, player, tile.getSlotStack(0));
tile.setSlotStack(0, ItemStack.EMPTY);
tile.markDirty();
tile.updateBlock();
if (!tile.getSlotStack(0).isEmpty()) {
if(player.inventory.getCurrentItem().getItem() instanceof ItemSpade) {
ItemStack returnStack = tile.getSlotStack(0).copy();
PlayerHelper.spawnItemOnPlayer(world, player, returnStack);
tile.clearSlot(0);
return true;
}
}
}
if(pItem.isEmpty()) {
if(!player.isSneaking()){
if(world.getBlockState(pos).getValue(ACTIVE) == true){
Integer tempInt = tile.getHeat();
@@ -115,7 +117,7 @@ public class Forge extends CustomContainerFacing implements ITileEntityProvider/
}
}
}
if((pItem.getItem() == Items.FLINT_AND_STEEL) || (pItem.getItem() == PrimalItems.FIRE_BOW) || pItem.getItem() == PrimalItems.TORCH_WOOD_LIT || pItem.getItem() == PrimalItems.TORCH_NETHER_LIT ) {
if((FireSource.useSource(world, pos, player, pItem, hand, facing, hitX, hitY, hitZ))) {
world.setBlockState(pos, state.withProperty(ACTIVE, true), 2);
tile.setHeat(100);
tile.markDirty();

View File

@@ -1,5 +1,6 @@
package nmd.primal.forgecraft.blocks;
import net.minecraft.block.BlockDynamicLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
@@ -7,6 +8,7 @@ import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.SoundCategory;
@@ -14,6 +16,8 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import nmd.primal.core.api.PrimalStates;
import nmd.primal.core.common.helper.PlayerHelper;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
@@ -25,7 +29,7 @@ public class IngotBall extends BlockCustomBase {
protected static AxisAlignedBB boundBoxLarge = new AxisAlignedBB(6/16D, 0.0D, 6/16D, 10/16D, 4/16D, 10/16D);
protected static AxisAlignedBB boundBoxSmall = new AxisAlignedBB(7/16D, 0.0D, 7/16D, 9/16D, 2/16D, 9/16D);
public static final PropertyBool ACTIVE = PropertyBool.create("active");
//public static final PropertyBool ACTIVE = PropertyBool.create("active");
private String type;
public IngotBall(Material material, String registryName, Float hardness, String type){
@@ -49,19 +53,32 @@ public class IngotBall extends BlockCustomBase {
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
//System.out.println(stack.getItemDamage());
worldIn.setBlockState(pos, state.withProperty(ACTIVE, Boolean.valueOf(false)), 2);
worldIn.setBlockState(pos, state.withProperty(PrimalStates.ACTIVE, Boolean.valueOf(false)), 2);
//System.out.println(state.getValue(ACTIVE));
}
public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state)
{
if(!world.isRemote){
if(state.getValue(PrimalStates.ACTIVE)){
world.setBlockState(pos, Blocks.FLOWING_LAVA.getDefaultState().withProperty(BlockDynamicLiquid.LEVEL, 1), 3);
}
if(!state.getValue(PrimalStates.ACTIVE)){
PlayerHelper.spawnItemOnGround(world, pos, new ItemStack(this, 1));
}
}
}
@Override
public int getMetaFromState(IBlockState state) {
int i = 0;
if( state.getValue(ACTIVE) == false) {
if( state.getValue(PrimalStates.ACTIVE) == false) {
i = 0;
return i;
}
if( state.getValue(ACTIVE) == true) {
if( state.getValue(PrimalStates.ACTIVE) == true) {
i = 1;
return i;
}
@@ -74,17 +91,17 @@ public class IngotBall extends BlockCustomBase {
IBlockState iblockstate = this.getDefaultState();
if (meta == 0){
iblockstate = iblockstate.withProperty(ACTIVE, Boolean.valueOf(false));
iblockstate = iblockstate.withProperty(PrimalStates.ACTIVE, Boolean.valueOf(false));
}
if (meta == 1) {
iblockstate = iblockstate.withProperty(ACTIVE, Boolean.valueOf(true));
iblockstate = iblockstate.withProperty(PrimalStates.ACTIVE, Boolean.valueOf(true));
}
return iblockstate;
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[] {ACTIVE});
return new BlockStateContainer(this, new IProperty[] {PrimalStates.ACTIVE});
}
@Override
@@ -93,8 +110,8 @@ public class IngotBall extends BlockCustomBase {
this.updateTick(world, pos, state, random);
if(!world.isRemote){
if ( ThreadLocalRandom.current().nextInt(0,4) == 0) {
if(state.getValue(ACTIVE) == true) {
world.setBlockState(pos, state.withProperty(ACTIVE, Boolean.valueOf(false)), 2);
if(state.getValue(PrimalStates.ACTIVE) == true) {
world.setBlockState(pos, state.withProperty(PrimalStates.ACTIVE, Boolean.valueOf(false)), 2);
world.playSound((EntityPlayer) null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
}
}

View File

@@ -16,6 +16,7 @@ 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.PrimalStates;
import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.init.ModBlocks;
import nmd.primal.forgecraft.init.ModSounds;
@@ -94,7 +95,7 @@ public class PistonBellows extends CustomContainerFacing {
}
if (world.getBlockState(tempPos).getBlock() == ModBlocks.bloomery) {
TileBloomery tile = (TileBloomery) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Bloomery.ACTIVE) == true)
if ((world.getBlockState(tempPos).getValue(PrimalStates.ACTIVE) == true)
&& (world.getBlockState(tempPos).getValue(Bloomery.FACING) == EnumFacing.EAST)) {
if (tile != null) {
//System.out.println(world.getBlockState(tempPos).getValue(Forge.FACING));
@@ -125,7 +126,7 @@ public class PistonBellows extends CustomContainerFacing {
}
if (world.getBlockState(tempPos).getBlock() == ModBlocks.bloomery) {
TileBloomery tile = (TileBloomery) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Bloomery.ACTIVE) == true)
if ((world.getBlockState(tempPos).getValue(PrimalStates.ACTIVE) == true)
&& (world.getBlockState(tempPos).getValue(Bloomery.FACING) == EnumFacing.WEST)) {
if (tile != null) {
//System.out.println(world.getBlockState(tempPos).getValue(Forge.FACING));
@@ -156,7 +157,7 @@ public class PistonBellows extends CustomContainerFacing {
}
if (world.getBlockState(tempPos).getBlock() == ModBlocks.bloomery) {
TileBloomery tile = (TileBloomery) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Bloomery.ACTIVE) == true)
if ((world.getBlockState(tempPos).getValue(PrimalStates.ACTIVE) == true)
&& (world.getBlockState(tempPos).getValue(Bloomery.FACING) == EnumFacing.SOUTH)) {
if (tile != null) {
//System.out.println(world.getBlockState(tempPos).getValue(Forge.FACING));
@@ -187,7 +188,7 @@ public class PistonBellows extends CustomContainerFacing {
}
if (world.getBlockState(tempPos).getBlock() == ModBlocks.bloomery) {
TileBloomery tile = (TileBloomery) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Bloomery.ACTIVE) == true)
if ((world.getBlockState(tempPos).getValue(PrimalStates.ACTIVE) == true)
&& (world.getBlockState(tempPos).getValue(Bloomery.FACING) == EnumFacing.NORTH)) {
if (tile != null) {
//System.out.println(world.getBlockState(tempPos).getValue(Forge.FACING));
@@ -396,7 +397,7 @@ public class PistonBellows extends CustomContainerFacing {
}
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)) {
if ((world.getBlockState(tempPos).getValue(PrimalStates.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Bloomery.FACING) == EnumFacing.EAST)) {
makeEmbers(world, tempPos, world.rand);
}
}
@@ -413,7 +414,7 @@ public class PistonBellows extends CustomContainerFacing {
}
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)) {
if ((world.getBlockState(tempPos).getValue(PrimalStates.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Bloomery.FACING) == EnumFacing.WEST)) {
makeEmbers(world, tempPos, world.rand);
}
}
@@ -430,7 +431,7 @@ public class PistonBellows extends CustomContainerFacing {
}
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)) {
if ((world.getBlockState(tempPos).getValue(PrimalStates.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Bloomery.FACING) == EnumFacing.SOUTH)) {
makeEmbers(world, tempPos, world.rand);
}
}
@@ -447,7 +448,7 @@ public class PistonBellows extends CustomContainerFacing {
}
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)) {
if ((world.getBlockState(tempPos).getValue(PrimalStates.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Bloomery.FACING) == EnumFacing.NORTH)) {
makeEmbers(world, tempPos, world.rand);
}
}

View File

@@ -156,7 +156,7 @@ public class ModBlocks {
return true;
}*/
if (pItem instanceof WorkMallet || pItem.equals(ModItems.forgehammer)) {
if(world.getBlockState(belowPos).getBlock().equals(ModBlocks.stoneanvil)) {
if(world.getBlockState(belowPos).getBlock() instanceof AnvilBase) {
TileAnvil tile = (TileAnvil) world.getTileEntity(belowPos);
@@ -209,7 +209,7 @@ public class ModBlocks {
return true;
}
if (pItem instanceof WorkMallet || pItem.equals(ModItems.forgehammer)) {
if(world.getBlockState(belowPos).getBlock() instanceof AnvilStone) {
if(world.getBlockState(belowPos).getBlock() instanceof AnvilBase) {
TileAnvil tile = (TileAnvil) world.getTileEntity(belowPos);
@@ -261,7 +261,7 @@ public class ModBlocks {
return true;
}
if (pItem instanceof WorkMallet || pItem.equals(ModItems.forgehammer)) {
if(world.getBlockState(belowPos).getBlock() instanceof AnvilStone) {
if(world.getBlockState(belowPos).getBlock() instanceof AnvilBase) {
TileAnvil tile = (TileAnvil) world.getTileEntity(belowPos);
@@ -313,7 +313,7 @@ public class ModBlocks {
return true;
}
if (pItem instanceof WorkMallet || pItem.equals(ModItems.forgehammer)) {
if(world.getBlockState(belowPos).getBlock() instanceof AnvilStone) {
if(world.getBlockState(belowPos).getBlock() instanceof AnvilBase) {
TileAnvil tile = (TileAnvil) world.getTileEntity(belowPos);
@@ -354,8 +354,8 @@ public class ModBlocks {
steelchunk = new IngotBall(Material.IRON, "steelchunk", 6.0f, "chunk"); //steel_ingot steelchunk.json steelchunkhot.json - done
wootzchunk = new IngotBall(Material.IRON, "wootzchunk", 6.0f, "chunk"); //wootz_ingot wootzchunk.json wootzchunkhot.json - done
stoneanvil = new AnvilStone(Material.ANVIL, "stoneanvil", 5.0f);
ironanvil = new AnvilStone(Material.ANVIL, "ironanvil", 6.0f);
stoneanvil = new AnvilStone(Material.ANVIL, "stoneanvil", 5.0f, true);
ironanvil = new AnvilIron(Material.ANVIL, "ironanvil", 6.0f, true);
//ironballitemcool = new ItemBlockIngotBall(ironball);
//ironballitemhot = new ItemBlockIngotBall(ironball);

View File

@@ -167,14 +167,14 @@ public class ModItems {
/**********
INGOTS AND CHUNKS
**********/
ironingotballhot = new BaseMultiItem("ironingothot", PrimalMaterials.TOOL_WROUGHT_IRON);
ironchunkhot = new BaseMultiItem("ironchunkhot", PrimalMaterials.TOOL_WROUGHT_IRON);
ironcleaningotballhot= new BaseMultiItem("ironcleaningotballhot", PrimalMaterials.TOOL_CLEAN_IRON);
ironcleanchunkhot= new BaseMultiItem("ironcleanchunkhot", PrimalMaterials.TOOL_CLEAN_IRON);
steelingotballhot= new BaseMultiItem("steelingotballhot", PrimalMaterials.TOOL_BASIC_STEEL);
steelchunkhot= new BaseMultiItem("steelchunkhot", PrimalMaterials.TOOL_BASIC_STEEL);
wootzingotballhot= new BaseMultiItem("wootzingotballhot", PrimalMaterials.TOOL_WOOTZ_STEEL);
wootzchunkhot= new BaseMultiItem("wootzchunkhot", PrimalMaterials.TOOL_WOOTZ_STEEL);
ironingotballhot = new BaseMultiItem("ironingothot", PrimalMaterials.TOOL_WROUGHT_IRON, 6);
ironchunkhot = new BaseMultiItem("ironchunkhot", PrimalMaterials.TOOL_WROUGHT_IRON, 7);
ironcleaningotballhot= new BaseMultiItem("ironcleaningotballhot", PrimalMaterials.TOOL_CLEAN_IRON, 15);
ironcleanchunkhot= new BaseMultiItem("ironcleanchunkhot", PrimalMaterials.TOOL_CLEAN_IRON, 16);
steelingotballhot= new BaseMultiItem("steelingotballhot", PrimalMaterials.TOOL_BASIC_STEEL, 24);
steelchunkhot= new BaseMultiItem("steelchunkhot", PrimalMaterials.TOOL_BASIC_STEEL, 25);
wootzingotballhot= new BaseMultiItem("wootzingotballhot", PrimalMaterials.TOOL_WOOTZ_STEEL, 33);
wootzchunkhot= new BaseMultiItem("wootzchunkhot", PrimalMaterials.TOOL_WOOTZ_STEEL, 34);
//forgingmanual = new ItemForgingManual();
//test = new ItemTest("ironsword");

View File

@@ -8,15 +8,21 @@ import net.minecraft.item.Item;
public class BaseMultiItem extends BaseItem {
private Item.ToolMaterial mat;
private int ID;
public BaseMultiItem( String registryName, Item.ToolMaterial material) {
public BaseMultiItem( String registryName, Item.ToolMaterial material, Integer ID) {
setUnlocalizedName(registryName);
setRegistryName(registryName);
mat = material;
this.ID = ID;
}
public Item.ToolMaterial getMaterial(Item item){
return mat;
}
public int getID() {
return ID;
}
}

View File

@@ -14,6 +14,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import nmd.primal.core.api.PrimalStates;
import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.blocks.Crucible;
import nmd.primal.forgecraft.blocks.CrucibleHot;
@@ -110,6 +111,19 @@ public class ItemStoneTongs extends Item {
27 | Hot Steel Axe Head
28 | Hot Steel Shovel Head
29 | Hot Steel Hoe Head
================================
30 | Hot Wootz Crucible
31 | Hot Cooked Wootz Crucible
32 | Hot Failed Wootz Crucible
33 | Hot Wootz Ingot
34 | Hot Wootz Chunk
--------------------------------
35 | Hot Wootz Pickaxe Head
36 | Hot Wootz Axe Head
37 | Hot Wootz Shovel Head
38 | Hot Wootz Hoe Head
*/
if(!world.isRemote) {
@@ -122,7 +136,7 @@ public class ItemStoneTongs extends Item {
*****/
if (world.getBlockState(pos).getBlock() != ModBlocks.bloomery) {
if (world.getBlockState(pos).getBlock() instanceof IngotBall) {
if(world.getBlockState(pos).getValue(IngotBall.ACTIVE) == true) {
if(world.getBlockState(pos).getValue(PrimalStates.ACTIVE) == true) {
if (world.getBlockState(pos).getBlock() == ModBlocks.ironball) {
itemstack.getTagCompound().setInteger("type", 6);
world.setBlockToAir(pos);
@@ -296,11 +310,11 @@ public class ItemStoneTongs extends Item {
itemstack.getTagCompound().setInteger("type", 0);
return EnumActionResult.SUCCESS;
case 6:
world.setBlockState(tempPos, ModBlocks.ironball.getDefaultState().withProperty(IngotBall.ACTIVE, true), 3);
world.setBlockState(tempPos, ModBlocks.ironball.getDefaultState().withProperty(PrimalStates.ACTIVE, true), 3);
itemstack.getTagCompound().setInteger("type", 0);
return EnumActionResult.SUCCESS;
case 7:
world.setBlockState(tempPos, ModBlocks.ironchunk.getDefaultState().withProperty(IngotBall.ACTIVE, true), 3);
world.setBlockState(tempPos, ModBlocks.ironchunk.getDefaultState().withProperty(PrimalStates.ACTIVE, true), 3);
itemstack.getTagCompound().setInteger("type", 0);
return EnumActionResult.SUCCESS;
case 8:
@@ -333,11 +347,11 @@ public class ItemStoneTongs extends Item {
itemstack.getTagCompound().setInteger("type", 0);
return EnumActionResult.SUCCESS;
case 15:
world.setBlockState(tempPos, ModBlocks.ironcleanball.getDefaultState().withProperty(IngotBall.ACTIVE, true), 3);
world.setBlockState(tempPos, ModBlocks.ironcleanball.getDefaultState().withProperty(PrimalStates.ACTIVE, true), 3);
itemstack.getTagCompound().setInteger("type", 0);
return EnumActionResult.SUCCESS;
case 16:
world.setBlockState(tempPos, ModBlocks.ironcleanchunk.getDefaultState().withProperty(IngotBall.ACTIVE, true), 3);
world.setBlockState(tempPos, ModBlocks.ironcleanchunk.getDefaultState().withProperty(PrimalStates.ACTIVE, true), 3);
itemstack.getTagCompound().setInteger("type", 0);
return EnumActionResult.SUCCESS;
case 17:
@@ -370,11 +384,11 @@ public class ItemStoneTongs extends Item {
itemstack.getTagCompound().setInteger("type", 0);
return EnumActionResult.SUCCESS;
case 24:
world.setBlockState(tempPos, ModBlocks.steelball.getDefaultState().withProperty(IngotBall.ACTIVE, true), 3);
world.setBlockState(tempPos, ModBlocks.steelball.getDefaultState().withProperty(PrimalStates.ACTIVE, true), 3);
itemstack.getTagCompound().setInteger("type", 0);
return EnumActionResult.SUCCESS;
case 25:
world.setBlockState(tempPos, ModBlocks.steelchunk.getDefaultState().withProperty(IngotBall.ACTIVE, true), 3);
world.setBlockState(tempPos, ModBlocks.steelchunk.getDefaultState().withProperty(PrimalStates.ACTIVE, true), 3);
itemstack.getTagCompound().setInteger("type", 0);
return EnumActionResult.SUCCESS;
}

View File

@@ -262,6 +262,8 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
setRedstoneLevel(item, 0);
setLapisLevel(item, 0);
setModifiers(item, 0);
}
if( this.getMaxDamage(item) - this.getDamage(item) < 5 ){
}
}

View File

@@ -14,6 +14,7 @@ import net.minecraft.item.Item;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import nmd.primal.core.api.PrimalItems;
import nmd.primal.forgecraft.blocks.AnvilBase;
import nmd.primal.forgecraft.blocks.AnvilStone;
import nmd.primal.forgecraft.blocks.IngotBall;
import nmd.primal.forgecraft.init.ModItems;
@@ -40,7 +41,7 @@ public class TileAnvilRender extends TileEntitySpecialRenderer<TileAnvil>
BlockPos pos = tile.getPos();
IBlockState state = this.getWorld().getBlockState(pos);
if (state.getBlock() instanceof AnvilStone) {
if (state.getBlock() instanceof AnvilBase) {
GL11.glPushMatrix();
GL11.glTranslated(x, y + 1.5D, z);
@@ -87,7 +88,7 @@ public class TileAnvilRender extends TileEntitySpecialRenderer<TileAnvil>
*/
if (state.getValue(AnvilStone.FACING) == EnumFacing.NORTH) {
if (state.getValue(AnvilBase.FACING) == EnumFacing.NORTH) {
int counter = 0;
for (int i = 0; i < 5; i++) {
for (int a = 0; a < 5; a++) {

View File

@@ -74,8 +74,16 @@ public abstract class TileBaseSlot extends BaseTile {
public void clearSlots()
{
this.slotList.clear();
this.markDirty();
this.updateBlock();
}
public void clearSlot(int index) {
this.slotList.set(index, ItemStack.EMPTY);
this.markDirty();
this.updateBlock();
}
// ***************************************************************************** //
// NBT

View File

@@ -9,6 +9,7 @@ import net.minecraft.util.ITickable;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import nmd.primal.core.api.PrimalStates;
import nmd.primal.core.common.helper.CommonUtils;
import nmd.primal.core.common.helper.ParticleHelper;
import nmd.primal.forgecraft.blocks.Bloomery;
@@ -35,7 +36,7 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
World world = this.getWorld();
if(!world.isRemote){
IBlockState state = world.getBlockState(this.pos);
if(state.getValue(Bloomery.ACTIVE) == true){
if(state.getValue(PrimalStates.ACTIVE) == true){
if(this.getHeat() < 100){
this.setHeat(100);
}
@@ -46,7 +47,7 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
//IBlockState state = world.getBlockState(this.pos);
BlockPos abovePos = new BlockPos(this.getPos().getX(), this.getPos().getY()+1, this.getPos().getZ());
if (world.getBlockState(this.getPos()).getValue(Bloomery.ACTIVE)) {
if (world.getBlockState(this.getPos()).getValue(PrimalStates.ACTIVE)) {
if (this.getSlotStack(0) == ItemStack.EMPTY) {
world.setBlockState(this.getPos(), state.withProperty(Forge.ACTIVE, false), 2);
this.markDirty();
@@ -139,7 +140,7 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
}
private void heatManager(Integer h, IBlockState state, ItemStack stack, World world, BlockPos pos){
if(state.getValue(Bloomery.ACTIVE) == true){
if(state.getValue(PrimalStates.ACTIVE) == true){
if(!stack.isEmpty()) {
if(h > 0) {
this.setHeat(h - 25);
@@ -152,7 +153,7 @@ public class TileBloomery extends TileBaseSlot implements ITickable {
world.setBlockState(pos, state.withProperty(Forge.ACTIVE, false), 2);
}
}
if(state.getValue(Bloomery.ACTIVE) == false){
if(state.getValue(PrimalStates.ACTIVE) == false){
if(h > 50){
this.setHeat(h - 50);
}

View File

@@ -2,6 +2,7 @@ package nmd.primal.forgecraft.util;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.EnumDyeColor;
@@ -17,7 +18,9 @@ import nmd.primal.core.common.items.tools.WorkMallet;
import nmd.primal.forgecraft.CommonUtils;
import nmd.primal.forgecraft.blocks.IngotBall;
import nmd.primal.forgecraft.crafting.AnvilCrafting;
import nmd.primal.forgecraft.init.ModBlocks;
import nmd.primal.forgecraft.init.ModItems;
import nmd.primal.forgecraft.items.BaseMultiItem;
import nmd.primal.forgecraft.items.ForgeHammer;
import nmd.primal.forgecraft.items.parts.ToolPart;
import nmd.primal.forgecraft.tiles.TileAnvil;
@@ -721,4 +724,56 @@ public interface AnvilHandler {
return false;
}
static void doDrops(World world, BlockPos pos) {
if (!world.isRemote && world.getGameRules().getBoolean("doTileDrops")) {
TileAnvil tile = (TileAnvil) world.getTileEntity(pos);
if (tile != null) {
for (ItemStack stack : tile.getSlotList()) {
if (stack != null) {
float offset = 0.7F;
double offsetX = world.rand.nextFloat() * offset + (1.0F - offset) * 0.5D;
double offsetY = world.rand.nextFloat() * offset + (1.0F - offset) * 0.5D;
double offsetZ = world.rand.nextFloat() * offset + (1.0F - offset) * 0.5D;
ItemStack dropStack = null;
if (stack.getItem() instanceof BaseMultiItem) {
BaseMultiItem item = (BaseMultiItem) stack.getItem();
switch (item.getID()) {
case 6:
dropStack = new ItemStack(ModBlocks.ironball, 1);
break;
case 7:
dropStack = new ItemStack(ModBlocks.ironchunk, 1);
break;
case 15:
dropStack = new ItemStack(ModBlocks.ironcleanball, 1);
break;
case 16:
dropStack = new ItemStack(ModBlocks.ironcleanchunk, 1);
break;
case 24:
dropStack = new ItemStack(ModBlocks.steelball, 1);
break;
case 25:
dropStack = new ItemStack(ModBlocks.steelchunk, 1);
break;
case 33:
dropStack = new ItemStack(ModBlocks.wootzball, 1);
break;
case 34:
dropStack = new ItemStack(ModBlocks.wootzchunk, 1);
break;
}
} else {
dropStack = stack;
}
EntityItem itemDrop = new EntityItem(world, pos.getX() + offsetX, pos.getY() + offsetY, pos.getZ() + offsetZ, dropStack);
itemDrop.setDefaultPickupDelay();
world.spawnEntity(itemDrop);
}
}
}
}
}
}

View File

@@ -7,62 +7,86 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import nmd.primal.core.api.PrimalItems;
import nmd.primal.forgecraft.CommonUtils;
//import nmd.primal.forgecraft.CommonUtils;
import nmd.primal.core.common.helper.CommonUtils;
import nmd.primal.core.common.helper.PlayerHelper;
import nmd.primal.forgecraft.blocks.CustomContainerFacing;
import nmd.primal.forgecraft.tiles.TileBreaker;
import nmd.primal.forgecraft.blocks.CustomContainerFacing.*;
import java.util.concurrent.ThreadLocalRandom;
import static nmd.primal.core.common.helper.CommonUtils.randomCheck;
/**
* Created by mminaie on 6/11/17.
*/
public interface BreakerHandler {
default void doBreaking (World world, IBlockState state, BlockPos pos, TileBreaker tile){
if (state.getValue(CustomContainerFacing.FACING) == EnumFacing.EAST) {
if(tile.getCharge() > world.getBlockState(pos.east()).getBlockHardness(world, pos.east())) {
if(tile.getCharge() > getThreshold(world, pos.east())) {
if (world.getBlockState(pos.east()).getBlock() == Blocks.IRON_ORE) {
world.setBlockToAir(pos.east());
CommonUtils.spawnItemEntityFromWorld(world, pos.east(), new ItemStack(PrimalItems.IRON_DUST, ThreadLocalRandom.current().nextInt(1, 2)));
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()-1);
PlayerHelper.spawnItemOnGround(world, pos.east(), new ItemStack(PrimalItems.IRON_DUST, randomChanceReturn(9, 1, 2)));
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()+1);
}
} else {
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()-10);
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()+10);
}
}
if (state.getValue(CustomContainerFacing.FACING) == EnumFacing.WEST) {
if(tile.getCharge() > world.getBlockState(pos.west()).getBlockHardness(world, pos.west())) {
if(tile.getCharge() > getThreshold(world, pos.west())) {
if (world.getBlockState(pos.west()).getBlock() == Blocks.IRON_ORE) {
world.setBlockToAir(pos.west());
CommonUtils.spawnItemEntityFromWorld(world, pos.east(), new ItemStack(PrimalItems.IRON_DUST, ThreadLocalRandom.current().nextInt(1, 2)));
PlayerHelper.spawnItemOnGround(world, pos.east(), new ItemStack(PrimalItems.IRON_DUST, randomChanceReturn(9, 1, 2)));
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()+1);
}
} else {
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()-10);
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()+10);
}
}
if (state.getValue(CustomContainerFacing.FACING) == EnumFacing.SOUTH) {
if(tile.getCharge() > world.getBlockState(pos.south()).getBlockHardness(world, pos.south())) {
if(tile.getCharge() > getThreshold(world, pos.south())) {
if (world.getBlockState(pos.south()).getBlock() == Blocks.IRON_ORE) {
world.setBlockToAir(pos.south());
CommonUtils.spawnItemEntityFromWorld(world, pos.east(), new ItemStack(PrimalItems.IRON_DUST, ThreadLocalRandom.current().nextInt(1, 2)));
PlayerHelper.spawnItemOnGround(world, pos.east(), new ItemStack(PrimalItems.IRON_DUST, randomChanceReturn(9, 1, 2)));
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()+1);
}
} else {
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()-10);
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()+10);
}
}
if (state.getValue(CustomContainerFacing.FACING) == EnumFacing.NORTH) {
if(tile.getCharge() > world.getBlockState(pos.north()).getBlockHardness(world, pos.north())) {
if(tile.getCharge() > getThreshold(world, pos.north())) {
if (world.getBlockState(pos.north()).getBlock() == Blocks.IRON_ORE) {
world.setBlockToAir(pos.north());
CommonUtils.spawnItemEntityFromWorld(world, pos.east(), new ItemStack(PrimalItems.IRON_DUST, ThreadLocalRandom.current().nextInt(1, 2)));
PlayerHelper.spawnItemOnGround(world, pos.east(), new ItemStack(PrimalItems.IRON_DUST, randomChanceReturn(9, 1, 2)));
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()+1);
}
} else {
//tile.getSlotStack(0).damageItem(10, (EntityPlayer) null);
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()-10);
tile.getSlotStack(0).setItemDamage(tile.getSlotStack(0).getItemDamage()+10);
}
}
tile.setCharge(0.0f);
}
default float getThreshold(World world, BlockPos pos){
float threshold = world.getBlockState(pos).getBlockHardness(world, pos) * (world.getBlockState(pos).getBlock().getExplosionResistance(null)*5);
if(threshold > 179){
threshold = 178;
}
return threshold;
}
public static int randomChanceReturn(int bound, int output1, int output2)
{
return randomCheck(bound) ? output2 : output1;
}
}

View File

@@ -2,7 +2,7 @@
"modid": "forgecraft",
"name": "Kitsu's Forgecraft",
"description": "Forged with sweat and blood",
"version": "1.2.23",
"version": "1.2.30",
"mcversion": "1.11.2",
"url": "",
"updateUrl": "",