Skip to content

Commit

Permalink
Nerfed charcoal creation calculation so that a full log pile doesn't …
Browse files Browse the repository at this point in the history
…always produce max charcoal - the calculation is now the same as 1.7.10. Fixed charcoal piles causing logs to drop their contents, effectively duplicating the logs (fixes #385). Fixed NPE in BlockToolRack#getPickBlock with null ray trace. (Fixes #386). Added removal of standard torch recipe to recipe remove list.
  • Loading branch information
alcatrazEscapee committed Sep 5, 2019
1 parent 8d488de commit 33d49e4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -50,7 +50,7 @@ file "build.properties" withReader {
* The version number is a sacred tool that a computer must understand and be able to compare to see what's what.
* `-SNAPSHOT` or `.rc0v14s4dffds2` communicates nothing useful.
*/
version = "0.23.5" // To be clear, you can edit this if you are submitting a patch PR, or if you are merging a feature into master.
version = "0.23.6" // To be clear, you can edit this if you are submitting a patch PR, or if you are merging a feature into master.
if (System.getenv().BUILD_NUMBER != null) version += "." + System.getenv().BUILD_NUMBER

group = "net.dries007.tfc" // According to java standards, as I have control over this domain. If you fork this and release your own version, change this.
Expand Down
Expand Up @@ -35,6 +35,7 @@
import net.dries007.tfc.client.TFCGuiHandler;
import net.dries007.tfc.objects.blocks.BlocksTFC;
import net.dries007.tfc.objects.blocks.property.ILightableBlock;
import net.dries007.tfc.objects.te.TEInventory;
import net.dries007.tfc.objects.te.TELogPile;
import net.dries007.tfc.util.Helpers;

Expand Down Expand Up @@ -107,12 +108,12 @@ public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos,
}

@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack)
{
TELogPile te = Helpers.getTE(worldIn, pos, TELogPile.class);
if (te != null)
// This can't use breakBlock as it needs to not drop when broken in order to create a charcoal pile
if (!worldIn.isRemote && te instanceof TEInventory)
{
te.onBreakBlock(worldIn, pos);
((TEInventory) te).onBreakBlock(worldIn, pos);
}
super.breakBlock(worldIn, pos, state);
}
Expand Down
Expand Up @@ -18,7 +18,9 @@
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
Expand Down Expand Up @@ -73,13 +75,14 @@ public int getMetaFromState(IBlockState state)
}

@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
TETickCounter te = Helpers.getTE(worldIn, pos, TETickCounter.class);
if (te != null)
{
te.resetCounter();
}
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
}

@Override
Expand Down
Expand Up @@ -179,14 +179,22 @@ protected BlockStateContainer createBlockState()

@Override
@Nonnull
public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player)
{
Vec3d vec = target.hitVec.subtract(pos.getX(), pos.getY(), pos.getZ());
TEToolRack te = Helpers.getTE(world, pos, TEToolRack.class);
if (te == null) return new ItemStack(this);
ItemStack item = te.getItems().get(getSlotFromPos(state, (float) vec.x, (float) vec.y, (float) vec.z));
if (item.isEmpty()) return new ItemStack(this);
return item;
public ItemStack getPickBlock(@Nonnull IBlockState state, @Nullable RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player)
{
if (target != null)
{
Vec3d vec = target.hitVec.subtract(pos.getX(), pos.getY(), pos.getZ());
TEToolRack te = Helpers.getTE(world, pos, TEToolRack.class);
if (te != null)
{
ItemStack item = te.getItems().get(getSlotFromPos(state, (float) vec.x, (float) vec.y, (float) vec.z));
if (!item.isEmpty())
{
return item;
}
}
}
return super.getPickBlock(state, target, world, pos, player);
}

public int getSlotFromPos(IBlockState state, float x, float y, float z)
Expand Down
Expand Up @@ -70,6 +70,7 @@ public static void onRecipeRegister(RegistryEvent.Register<IRecipe> event)
modRegistry.remove(new ResourceLocation("minecraft:armor_stand"));
modRegistry.remove(new ResourceLocation("minecraft:anvil"));
modRegistry.remove(new ResourceLocation("minecraft:painting"));
modRegistry.remove(new ResourceLocation("minecraft:torch"));

//breakydowny, buildyupy things.
modRegistry.remove(new ResourceLocation("minecraft:wheat"));
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/net/dries007/tfc/objects/te/TELogPile.java
Expand Up @@ -216,9 +216,8 @@ private void createCharcoal()
}
} while (block == Blocks.AIR || block instanceof BlockCharcoalPile);

double logs = (double) countLogs();
double log2 = 0.008d * logs * (logs + 42.5d) - 0.75d + 1.5d * Constants.RNG.nextFloat();
int charcoal = (int) Math.min(8, Math.max(0, Math.round(log2)));
double logs = countLogs() * (0.25 + 0.25 * Constants.RNG.nextFloat());
int charcoal = (int) Math.min(8, Math.max(0, Math.round(logs)));
if (charcoal == 0)
{
world.setBlockState(pos, Blocks.AIR.getDefaultState());
Expand Down

0 comments on commit 33d49e4

Please sign in to comment.