From a32cbe15a30f770ef87b934248b0db6e66e6ba56 Mon Sep 17 00:00:00 2001 From: _0Steven <42909981+SuicidalSteve@users.noreply.github.com> Date: Sat, 20 Feb 2021 15:08:58 +0100 Subject: [PATCH 1/2] Consistently Crushing Entities - Fix known issue with omnidirectional crushing wheels inconsistently moving crushed mob drops to the output location. --- .../CrushingWheelControllerTileEntity.java | 22 +++++++++++++++---- .../crusher/CrushingWheelTileEntity.java | 10 +-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java index 2fb13c6c0..858e8f5ce 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java @@ -20,6 +20,7 @@ import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; @@ -199,12 +200,25 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { return; if (!(processingEntity instanceof ItemEntity)) { + Vec3d entityOutPos = outPos.add(facing.getAxis() == Axis.X ? .5f * offset : 0f + , facing.getAxis() == Axis.Y ? .5f * offset : 0f + , facing.getAxis() == Axis.Z ? .5f * offset : 0f); + int crusherDamage = AllConfigs.SERVER.kinetics.crushingDamage.get(); + + if (processingEntity instanceof LivingEntity) { + if ((((LivingEntity) processingEntity).getHealth() - crusherDamage <= 0) //Takes LivingEntity instances as exception, so it can move them before it would kill them. + && (((LivingEntity) processingEntity).hurtTime <= 0)) { //This way it can actually output the items to the right spot. + processingEntity.setPosition(entityOutPos.x + , entityOutPos.y + , entityOutPos.z); + } + } processingEntity.attackEntityFrom(CrushingWheelTileEntity.damageSource, - AllConfigs.SERVER.kinetics.crushingDamage.get()); + crusherDamage); if (!processingEntity.isAlive()) { - processingEntity.setPosition(outPos.x + (facing.getAxis() == Axis.X ? .75f * offset : 0f) //This is supposed to move the mobs to the output location - , outPos.y + (facing.getAxis() == Axis.Y ? .75f * offset : 0f) //So the item drops end up on the other end - , outPos.z + (facing.getAxis() == Axis.Z ? .75f * offset : 0f)); //This, however, does not currently work consistently for non-downwards crushers. + processingEntity.setPosition(entityOutPos.x + , entityOutPos.y + , entityOutPos.z); } return; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java index 8d94992d5..63aced587 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java @@ -7,7 +7,6 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.DamageSource; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; -import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LootingLevelEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @@ -50,14 +49,7 @@ public class CrushingWheelTileEntity extends KineticTileEntity { public static void crushingIsFortunate(LootingLevelEvent event) { if (event.getDamageSource() != damageSource) return; - event.setLootingLevel(2); - } - - @SubscribeEvent - public static void crushingTeleportsEntities(LivingDeathEvent event) { - if (event.getSource() != damageSource) - return; - event.getEntity().setPos(event.getEntity().getX(), Math.floor(event.getEntity().getY()) - .5f, event.getEntity().getZ()); + event.setLootingLevel(2); //This does not currently increase mob drops. It seems like this only works for damage done by an entity. } } From 41cb2ad9374f55d22dbccc491147ec21b268ed8b Mon Sep 17 00:00:00 2001 From: _0Steven <42909981+SuicidalSteve@users.noreply.github.com> Date: Sat, 20 Feb 2021 18:50:40 +0100 Subject: [PATCH 2/2] Stop explody crusher drops - Remove the velocity of item entities dropped by crushed mobs so they fall neatly onto belts rather than exploding everywhere. --- .../components/crusher/CrushingWheelTileEntity.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java index 63aced587..fb6117988 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelTileEntity.java @@ -3,10 +3,13 @@ package com.simibubi.create.content.contraptions.components.crusher; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.utility.Iterate; +import net.minecraft.entity.item.ItemEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.DamageSource; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.Vec3d; +import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.living.LootingLevelEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @@ -52,4 +55,14 @@ public class CrushingWheelTileEntity extends KineticTileEntity { event.setLootingLevel(2); //This does not currently increase mob drops. It seems like this only works for damage done by an entity. } + @SubscribeEvent + public static void handleCrushedMobDrops(LivingDropsEvent event) { + if (event.getSource() != CrushingWheelTileEntity.damageSource) + return; + Vec3d outSpeed = Vec3d.ZERO; + for (ItemEntity outputItem : event.getDrops()) { + outputItem.setMotion(outSpeed); + } + } + }