From ac8c1e1468a100744a112483674a167c1454ddfd Mon Sep 17 00:00:00 2001 From: grimmauld Date: Wed, 7 Apr 2021 14:29:41 +0200 Subject: [PATCH] Fixed unported stuff, tree cutter now does sound effects at the right probability again --- .../pulley/AbstractPulleyInstance.java | 11 ++++------- .../pulley/RopePulleyInstance.java | 2 -- .../create/foundation/utility/TreeCutter.java | 14 ++++++++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java index ed449c4a7..cea43d167 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java @@ -1,15 +1,13 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pulley; -import net.minecraft.client.renderer.Vector3f; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.ILightReader; +import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.world.IBlockDisplayReader; import net.minecraft.world.LightType; import java.util.Arrays; -import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; import com.simibubi.create.foundation.render.backend.core.OrientedData; @@ -20,7 +18,6 @@ import com.simibubi.create.foundation.render.backend.instancing.util.SelectInsta import com.simibubi.create.foundation.render.backend.light.GridAlignedBB; import com.simibubi.create.foundation.render.backend.light.LightUpdateListener; import com.simibubi.create.foundation.render.backend.light.LightUpdater; -import com.simibubi.create.foundation.utility.AnimationTickHolder; public abstract class AbstractPulleyInstance extends ShaftInstance implements IDynamicInstance, LightUpdateListener { @@ -175,7 +172,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID } @Override - public boolean onLightUpdate(ILightReader world, LightType type, GridAlignedBB changed) { + public boolean onLightUpdate(IBlockDisplayReader world, LightType type, GridAlignedBB changed) { changed.intersectAssign(volume); initLight(world, changed); @@ -183,7 +180,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID return false; } - private void initLight(ILightReader world, GridAlignedBB changed) { + private void initLight(IBlockDisplayReader world, GridAlignedBB changed) { int top = this.pos.getY(); BlockPos.Mutable pos = new BlockPos.Mutable(); changed.forEachContained((x, y, z) -> { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/RopePulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/RopePulleyInstance.java index 9bceb011b..8eb8388e4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/RopePulleyInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/RopePulleyInstance.java @@ -1,10 +1,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pulley; -import net.minecraft.world.ILightReader; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; -import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.render.backend.core.OrientedData; import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; diff --git a/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java b/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java index 5e7ee1294..cd4b9db41 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java +++ b/src/main/java/com/simibubi/create/foundation/utility/TreeCutter.java @@ -1,6 +1,5 @@ package com.simibubi.create.foundation.utility; -import com.google.common.collect.Iterators; import com.simibubi.create.AllTags; import net.minecraft.block.*; import net.minecraft.entity.LivingEntity; @@ -18,6 +17,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.*; import java.util.function.BiConsumer; +import java.util.function.Consumer; import java.util.function.Predicate; public class TreeCutter { @@ -221,12 +221,18 @@ public class TreeCutter { public void destroyBlocks(World world, @Nullable LivingEntity entity, BiConsumer drop) { PlayerEntity playerEntity = entity instanceof PlayerEntity ? ((PlayerEntity) entity) : null; ItemStack toDamage = playerEntity != null && !playerEntity.isCreative() ? playerEntity.getHeldItemMainhand() : ItemStack.EMPTY; - Iterators.concat(logs.iterator(), leaves.iterator()).forEachRemaining(pos -> { + + logs.forEach(makeCallbackFor(world, 1/2f, toDamage, playerEntity, drop)); + leaves.forEach(makeCallbackFor(world, 1/8f, toDamage, playerEntity, drop)); + } + + private Consumer makeCallbackFor(World world, float effectChance, ItemStack toDamage, @Nullable PlayerEntity playerEntity, BiConsumer drop) { + return pos -> { ItemStack usedTool = toDamage.copy(); - BlockHelper.destroyBlockAs(world, pos, playerEntity, toDamage, 1 / 2f, stack -> drop.accept(pos, stack)); + BlockHelper.destroyBlockAs(world, pos, playerEntity, toDamage, effectChance, stack -> drop.accept(pos, stack)); if (toDamage.isEmpty() && !usedTool.isEmpty()) ForgeEventFactory.onPlayerDestroyItem(playerEntity, usedTool, Hand.MAIN_HAND); - }); + }; } }