Skip to content

Commit 89678d3

Browse files
Fix falling tree entity crash for trees larger than 3x3.
1 parent eaecad4 commit 89678d3

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

src/main/java/com/ferreusveritas/dynamictrees/entity/FallingTreeEntity.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import com.ferreusveritas.dynamictrees.util.BlockBounds;
1616
import com.ferreusveritas.dynamictrees.util.BranchDestructionData;
1717
import com.ferreusveritas.dynamictrees.util.CoordUtils.Surround;
18+
import com.ferreusveritas.dynamictrees.block.branch.ThickBranchBlock;
19+
import com.ferreusveritas.dynamictrees.util.CoordUtils.ShellDirection;
1820
import com.google.common.collect.Iterables;
1921
import net.minecraft.client.Minecraft;
2022
import net.minecraft.core.BlockPos;
@@ -237,12 +239,16 @@ public void buildClient() {
237239
protected void cleanupShellBlocks(BranchDestructionData destroyData) {
238240
BlockPos cutPos = destroyData.cutPos;
239241
for (int i = 0; i < destroyData.getNumBranches(); i++) {
240-
if (destroyData.getBranchRadius(i) > 8) {
242+
int radius = destroyData.getBranchRadius(i);
243+
if (radius > ThickBranchBlock.RADIUS_TO_INNER_SHELL) {
241244
BlockPos pos = destroyData.getBranchRelPos(i).offset(cutPos);
242-
for (Surround dir : Surround.values()) {
243-
BlockPos dPos = pos.offset(dir.getOffset());
244-
if (level().getBlockState(dPos).getBlock() instanceof TrunkShellBlock) {
245-
level().removeBlock(dPos, false);
245+
for (ShellDirection dir : ShellDirection.values()) {
246+
// Only check shells that this radius actually needs
247+
if (dir.getShellLevel() == 1 || dir.getShellLevel() == 2 && radius > ThickBranchBlock.RADIUS_TO_OUTER_SHELL || dir.getShellLevel() == 3 && radius > ThickBranchBlock.RADIUS_TO_OUTERMOST_SHELL) {
248+
BlockPos dPos = pos.offset(dir.getOffset());
249+
if (level().getBlockState(dPos).getBlock() instanceof TrunkShellBlock) {
250+
level().removeBlock(dPos, false);
251+
}
246252
}
247253
}
248254
}
@@ -549,4 +555,4 @@ public static FallingTreeEntity dropTree(Level level, BranchDestructionData dest
549555
return null;
550556
}
551557

552-
}
558+
}

src/main/java/com/ferreusveritas/dynamictrees/models/baked/BasicBranchBlockBakedModel.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public class BasicBranchBlockBakedModel implements IDynamicBakedModel {
4848
protected final TextureAtlasSprite ringsTexture;
4949

5050

51-
protected final BakedModel[][] sleeves = new BakedModel[6][7];
52-
protected final BakedModel[][] cores = new BakedModel[3][8]; // 8 Cores for 3 axis with the bark texture all all 6 sides rotated appropriately.
53-
protected final BakedModel[] rings = new BakedModel[8]; // 8 Cores with the ring textures on all 6 sides.
51+
protected BakedModel[][] sleeves = new BakedModel[6][7];
52+
protected BakedModel[][] cores = new BakedModel[3][8]; // 8 Cores for 3 axis with the bark texture all all 6 sides rotated appropriately.
53+
protected BakedModel[] rings = new BakedModel[8]; // 8 Cores with the ring textures on all 6 sides.
5454

5555
public BasicBranchBlockBakedModel(IGeometryBakingContext customData, ResourceLocation modelLocation, ResourceLocation barkTextureLocation, ResourceLocation ringsTextureLocation,
5656
Function<Material, TextureAtlasSprite> spriteGetter) {
@@ -202,7 +202,7 @@ public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction
202202

203203
final int coreRadius = getRadius(state);
204204

205-
if (coreRadius > 8) {
205+
if (coreRadius > cores[0].length) {
206206
return Collections.emptyList();
207207
}
208208

0 commit comments

Comments
 (0)