Fortuneful Crushers

- Fix Crushing Wheels not applying fortune like they should
- Remove extra FIXME
This commit is contained in:
IThundxr 2025-02-17 14:47:47 -05:00
parent b28427fe2d
commit 658225e318
Failed to generate hash of commit
6 changed files with 570 additions and 519 deletions

View file

@ -128,7 +128,8 @@ _Now using Flywheel 1.0_
- Fixed stations voiding schedules when disassembling the train - Fixed stations voiding schedules when disassembling the train
- Fixed lighting on signal block indicators - Fixed lighting on signal block indicators
- Fixed vaults and tanks rotated in place not updating their multiblock correctly - Fixed vaults and tanks rotated in place not updating their multiblock correctly
- Hose pulley now deletes lilypads and other surface foliage - Hose pulley now deletes lilypads and other surface foliage
- Fixed crushing wheels not applying looting to killed entities
#### API Changes #### API Changes

View file

@ -106,7 +106,7 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements Tran
return false; return false;
if (connection != null if (connection != null
&& (!(level.getBlockEntity(worldPosition.offset(connection)) instanceof ChainConveyorBlockEntity otherClbe) && (!(level.getBlockEntity(worldPosition.offset(connection)) instanceof ChainConveyorBlockEntity otherClbe)
|| !otherClbe.canAcceptMorePackages())) || !otherClbe.canAcceptMorePackages()))
return false; return false;
return true; return true;
} }
@ -174,7 +174,7 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements Tran
if (!(level.getBlockEntity(worldPosition.offset(offset)) instanceof ChainConveyorBlockEntity otherLift)) if (!(level.getBlockEntity(worldPosition.offset(offset)) instanceof ChainConveyorBlockEntity otherLift))
continue; continue;
for (Iterator<ChainConveyorPackage> iterator = entry.getValue() for (Iterator<ChainConveyorPackage> iterator = entry.getValue()
.iterator(); iterator.hasNext();) { .iterator(); iterator.hasNext(); ) {
ChainConveyorPackage box = iterator.next(); ChainConveyorPackage box = iterator.next();
if (box.justFlipped) if (box.justFlipped)
continue; continue;
@ -195,8 +195,9 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements Tran
if (stats == null) if (stats == null)
continue; continue;
Travelling: for (Iterator<ChainConveyorPackage> iterator = entry.getValue() Travelling:
.iterator(); iterator.hasNext();) { for (Iterator<ChainConveyorPackage> iterator = entry.getValue()
.iterator(); iterator.hasNext(); ) {
ChainConveyorPackage box = iterator.next(); ChainConveyorPackage box = iterator.next();
box.justFlipped = false; box.justFlipped = false;
@ -251,7 +252,8 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements Tran
} }
} }
Looping: for (Iterator<ChainConveyorPackage> iterator = loopingPackages.iterator(); iterator.hasNext();) { Looping:
for (Iterator<ChainConveyorPackage> iterator = loopingPackages.iterator(); iterator.hasNext(); ) {
ChainConveyorPackage box = iterator.next(); ChainConveyorPackage box = iterator.next();
box.justFlipped = false; box.justFlipped = false;
@ -313,7 +315,7 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements Tran
public void removeInvalidConnections() { public void removeInvalidConnections() {
boolean changed = false; boolean changed = false;
for (Iterator<BlockPos> iterator = connections.iterator(); iterator.hasNext();) { for (Iterator<BlockPos> iterator = connections.iterator(); iterator.hasNext(); ) {
BlockPos next = iterator.next(); BlockPos next = iterator.next();
BlockPos target = worldPosition.offset(next); BlockPos target = worldPosition.offset(next);
if (!level.isLoaded(target)) if (!level.isLoaded(target))
@ -584,7 +586,7 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements Tran
private void spawnDestroyParticles(BlockPos blockPos) { private void spawnDestroyParticles(BlockPos blockPos) {
forPointsAlongChains(blockPos, (int) Math.round(Vec3.atLowerCornerOf(blockPos) forPointsAlongChains(blockPos, (int) Math.round(Vec3.atLowerCornerOf(blockPos)
.length() * 8), .length() * 8),
vec -> level.addParticle(new BlockParticleOption(ParticleTypes.BLOCK, Blocks.CHAIN.defaultBlockState()), vec -> level.addParticle(new BlockParticleOption(ParticleTypes.BLOCK, Blocks.CHAIN.defaultBlockState()),
vec.x, vec.y, vec.z, 0, 0, 0)); vec.x, vec.y, vec.z, 0, 0, 0));
} }
@ -652,7 +654,7 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements Tran
@Override @Override
public float propagateRotationTo(KineticBlockEntity target, BlockState stateFrom, BlockState stateTo, BlockPos diff, public float propagateRotationTo(KineticBlockEntity target, BlockState stateFrom, BlockState stateTo, BlockPos diff,
boolean connectedViaAxes, boolean connectedViaCogs) { boolean connectedViaAxes, boolean connectedViaCogs) {
if (connections.contains(target.getBlockPos() if (connections.contains(target.getBlockPos()
.subtract(worldPosition))) { .subtract(worldPosition))) {
if (!(target instanceof ChainConveyorBlockEntity)) if (!(target instanceof ChainConveyorBlockEntity))
@ -774,7 +776,7 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements Tran
@Override @Override
public ItemRequirement getRequiredItems(BlockState state) { public ItemRequirement getRequiredItems(BlockState state) {
// Uncomment when Schematicannon is able to print these with chains // TODO: Uncomment when Schematicannon is able to print these with chains
// int totalCost = 0; // int totalCost = 0;
// for (BlockPos pos : connections) // for (BlockPos pos : connections)
// totalCost += getChainCost(pos); // totalCost += getChainCost(pos);

View file

@ -16,6 +16,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.LootingLevelEvent; import net.minecraftforge.event.entity.living.LootingLevelEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -43,7 +44,7 @@ public class CrushingWheelBlockEntity extends KineticBlockEntity {
public void fixControllers() { public void fixControllers() {
for (Direction d : Iterate.directions) for (Direction d : Iterate.directions)
((CrushingWheelBlock) getBlockState().getBlock()).updateControllers(getBlockState(), getLevel(), getBlockPos(), ((CrushingWheelBlock) getBlockState().getBlock()).updateControllers(getBlockState(), getLevel(), getBlockPos(),
d); d);
} }
@Override @Override
@ -57,12 +58,14 @@ public class CrushingWheelBlockEntity extends KineticBlockEntity {
fixControllers(); fixControllers();
} }
// This increases the drops when dropCustomDeathLoot is called, and LootingEnchantFunctionMixin increases the drops
// defined in the entity loot table
@SubscribeEvent @SubscribeEvent
public static void crushingIsFortunate(LootingLevelEvent event) { public static void crushingIsFortunate(LootingLevelEvent event) {
DamageSource damageSource = event.getDamageSource(); DamageSource damageSource = event.getDamageSource();
if (damageSource == null || !damageSource.is(AllDamageTypes.CRUSH)) if (damageSource == null || !damageSource.is(AllDamageTypes.CRUSH))
return; return;
event.setLootingLevel(2); //This does not currently increase mob drops. It seems like this only works for damage done by an entity. event.setLootingLevel(2);
} }
@SubscribeEvent @SubscribeEvent

View file

@ -0,0 +1,44 @@
package com.simibubi.create.foundation.mixin;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.simibubi.create.AllDamageTypes;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.functions.LootingEnchantFunction;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.level.storage.loot.providers.number.NumberProvider;
@Mixin(LootingEnchantFunction.class)
public abstract class LootingEnchantFunctionMixin {
@Shadow
@Final
NumberProvider value;
@Shadow
@Final
int limit;
@Shadow
abstract boolean hasLimit();
@Inject(method = "run", at = @At("TAIL"))
private void create$crushingWheelsHaveLooting(ItemStack stack, LootContext context, CallbackInfoReturnable<ItemStack> cir) {
DamageSource damageSource = context.getParamOrNull(LootContextParams.DAMAGE_SOURCE);
if (damageSource != null && damageSource.is(AllDamageTypes.CRUSH)) {
int lootingLevel = 2;
float f = (float) lootingLevel * this.value.getFloat(context);
stack.grow(Math.round(f));
if (this.hasLimit() && stack.getCount() > this.limit)
stack.setCount(this.limit);
}
}
}

View file

@ -13,6 +13,7 @@
"CustomItemUseEffectsMixin", "CustomItemUseEffectsMixin",
"EntityMixin", "EntityMixin",
"LavaSwimmingMixin", "LavaSwimmingMixin",
"LootingEnchantFunctionMixin",
"MapItemSavedDataMixin", "MapItemSavedDataMixin",
"ProjectileUtilMixin", "ProjectileUtilMixin",
"ShulkerBoxBlockMixin", "ShulkerBoxBlockMixin",