Fixed unported stuff, tree cutter now does sound effects at the right probability again

This commit is contained in:
grimmauld 2021-04-07 14:29:41 +02:00
parent 2613c5be89
commit ac8c1e1468
3 changed files with 14 additions and 13 deletions

View file

@ -1,15 +1,13 @@
package com.simibubi.create.content.contraptions.components.structureMovement.pulley; package com.simibubi.create.content.contraptions.components.structureMovement.pulley;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; 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 net.minecraft.world.LightType;
import java.util.Arrays; 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.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
import com.simibubi.create.foundation.render.backend.core.OrientedData; 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.GridAlignedBB;
import com.simibubi.create.foundation.render.backend.light.LightUpdateListener; import com.simibubi.create.foundation.render.backend.light.LightUpdateListener;
import com.simibubi.create.foundation.render.backend.light.LightUpdater; 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 { public abstract class AbstractPulleyInstance extends ShaftInstance implements IDynamicInstance, LightUpdateListener {
@ -175,7 +172,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
} }
@Override @Override
public boolean onLightUpdate(ILightReader world, LightType type, GridAlignedBB changed) { public boolean onLightUpdate(IBlockDisplayReader world, LightType type, GridAlignedBB changed) {
changed.intersectAssign(volume); changed.intersectAssign(volume);
initLight(world, changed); initLight(world, changed);
@ -183,7 +180,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
return false; return false;
} }
private void initLight(ILightReader world, GridAlignedBB changed) { private void initLight(IBlockDisplayReader world, GridAlignedBB changed) {
int top = this.pos.getY(); int top = this.pos.getY();
BlockPos.Mutable pos = new BlockPos.Mutable(); BlockPos.Mutable pos = new BlockPos.Mutable();
changed.forEachContained((x, y, z) -> { changed.forEachContained((x, y, z) -> {

View file

@ -1,10 +1,8 @@
package com.simibubi.create.content.contraptions.components.structureMovement.pulley; package com.simibubi.create.content.contraptions.components.structureMovement.pulley;
import net.minecraft.world.ILightReader;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; 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.core.OrientedData;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;

View file

@ -1,6 +1,5 @@
package com.simibubi.create.foundation.utility; package com.simibubi.create.foundation.utility;
import com.google.common.collect.Iterators;
import com.simibubi.create.AllTags; import com.simibubi.create.AllTags;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
@ -18,6 +17,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.*; import java.util.*;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
public class TreeCutter { public class TreeCutter {
@ -221,12 +221,18 @@ public class TreeCutter {
public void destroyBlocks(World world, @Nullable LivingEntity entity, BiConsumer<BlockPos, ItemStack> drop) { public void destroyBlocks(World world, @Nullable LivingEntity entity, BiConsumer<BlockPos, ItemStack> drop) {
PlayerEntity playerEntity = entity instanceof PlayerEntity ? ((PlayerEntity) entity) : null; PlayerEntity playerEntity = entity instanceof PlayerEntity ? ((PlayerEntity) entity) : null;
ItemStack toDamage = playerEntity != null && !playerEntity.isCreative() ? playerEntity.getHeldItemMainhand() : ItemStack.EMPTY; 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<BlockPos> makeCallbackFor(World world, float effectChance, ItemStack toDamage, @Nullable PlayerEntity playerEntity, BiConsumer<BlockPos, ItemStack> drop) {
return pos -> {
ItemStack usedTool = toDamage.copy(); 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()) if (toDamage.isEmpty() && !usedTool.isEmpty())
ForgeEventFactory.onPlayerDestroyItem(playerEntity, usedTool, Hand.MAIN_HAND); ForgeEventFactory.onPlayerDestroyItem(playerEntity, usedTool, Hand.MAIN_HAND);
}); };
} }
} }