Skip to content

Commit

Permalink
Finally fix the vanilla dirt on decaying tree bug by adding an overri…
Browse files Browse the repository at this point in the history
…de to BlockBranch#getDecayBlockState.
  • Loading branch information
Gaelmare committed Jan 23, 2021
1 parent 0f12177 commit 55251a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.labellum.mc.dynamictreestfc;

import net.dries007.tfc.TerraFirmaCraft;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -23,6 +24,10 @@ public boolean doDecay(World world, BlockPos pos, IBlockState state, Species spe
{
world.setBlockState(pos, BlockRockVariant.get(chunkData.getRockHeight(pos), Rock.Type.DIRT).getDefaultState(), 3);
return true;
} else if (world.getWorldType() == TerraFirmaCraft.getWorldType() )
{ //failed to get chunkdata, but tfc worldtype still, apply a default rocktype
world.setBlockState(pos, BlockRockVariant.get(Rock.LIMESTONE, Rock.Type.DIRT).getDefaultState(), 3);
return true;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

import net.dries007.tfc.world.classic.chunkdata.ChunkDataProvider;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

import net.minecraftforge.common.property.IExtendedBlockState;

import com.ferreusveritas.dynamictrees.api.ICustomRootDecay;
import com.ferreusveritas.dynamictrees.blocks.BlockRootyDirt;
import com.ferreusveritas.dynamictrees.blocks.MimicProperty;
import net.dries007.tfc.api.types.Rock;
import net.dries007.tfc.objects.blocks.stone.BlockRockVariant;
import net.dries007.tfc.world.classic.chunkdata.ChunkDataTFC;
import org.labellum.mc.dynamictreestfc.TFCRootDecay;

@ParametersAreNonnullByDefault
public class BlockRootyDirtTFC extends BlockRootyDirt
Expand Down Expand Up @@ -62,12 +58,22 @@ public IBlockState getMimic(IBlockAccess access, BlockPos pos) // this IBlockAcc

@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
drops.clear();
drops.add(new ItemStack(getDecayBlockState(world, pos).getBlock()));
}

@Override
public IBlockState getDecayBlockState(IBlockAccess world, BlockPos pos)
{
if (world instanceof World) //lol
{
Rock rock = ChunkDataTFC.get((World) world, pos).getRockHeight(pos);
drops.clear();
drops.add(new ItemStack(BlockRockVariant.get(rock, Rock.Type.DIRT)));
ChunkDataTFC chunkData = ((World) world).getChunk(pos).getCapability(ChunkDataProvider.CHUNK_DATA_CAPABILITY, null);
if (chunkData != null) {
Rock rock = chunkData.getRockHeight(pos);
return BlockRockVariant.get(rock, Rock.Type.DIRT).getDefaultState();
}
}
return super.getDecayBlockState(world, pos);
}
}

0 comments on commit 55251a4

Please sign in to comment.