Fix deployers getting stuck in water or bedrock as contraption
This commit is contained in:
parent
1fe647b16e
commit
ca4877430e
2 changed files with 24 additions and 12 deletions
|
@ -66,6 +66,7 @@ public class DeployerFakePlayer extends FakePlayer {
|
||||||
return new StringTextComponent(Lang.translate("block.deployer.damage_source_name"));
|
return new StringTextComponent(Lang.translate("block.deployer.damage_source_name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public float getEyeHeight(Pose poseIn) {
|
public float getEyeHeight(Pose poseIn) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.simibubi.create.modules.contraptions.components.deployer;
|
package com.simibubi.create.modules.contraptions.components.deployer;
|
||||||
|
|
||||||
import static net.minecraftforge.eventbus.api.Event.Result.DENY;
|
import static net.minecraftforge.eventbus.api.Event.Result.DENY;
|
||||||
|
import static net.minecraftforge.eventbus.api.Event.Result.DEFAULT;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -47,7 +48,7 @@ import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock;
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock;
|
||||||
import net.minecraftforge.eventbus.api.Event.Result;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
|
||||||
public class DeployerHandler {
|
public class DeployerHandler {
|
||||||
|
|
||||||
|
@ -164,18 +165,18 @@ public class DeployerHandler {
|
||||||
|
|
||||||
// Left click
|
// Left click
|
||||||
if (mode == Mode.PUNCH) {
|
if (mode == Mode.PUNCH) {
|
||||||
LeftClickBlock event = ForgeHooks.onLeftClickBlock(player, clickedPos, face);
|
|
||||||
if (event.isCanceled())
|
|
||||||
return;
|
|
||||||
if (!world.isBlockModifiable(player, clickedPos))
|
if (!world.isBlockModifiable(player, clickedPos))
|
||||||
return;
|
return;
|
||||||
if (world.extinguishFire(player, clickedPos, face))
|
if (clickedState.getRenderShape(world, clickedPos).isEmpty()) {
|
||||||
return;
|
|
||||||
if (clickedState.isAir(world, clickedPos)) {
|
|
||||||
player.blockBreakingProgress = null;
|
player.blockBreakingProgress = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getUseBlock() != Result.DENY)
|
LeftClickBlock event = ForgeHooks.onLeftClickBlock(player, clickedPos, face);
|
||||||
|
if (event.isCanceled())
|
||||||
|
return;
|
||||||
|
if (world.extinguishFire(player, clickedPos, face))
|
||||||
|
return;
|
||||||
|
if (event.getUseBlock() != DENY)
|
||||||
clickedState.onBlockClicked(world, clickedPos, player);
|
clickedState.onBlockClicked(world, clickedPos, player);
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -193,6 +194,10 @@ public class DeployerHandler {
|
||||||
player.blockBreakingProgress = null;
|
player.blockBreakingProgress = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (progress <= 0) {
|
||||||
|
player.blockBreakingProgress = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((int) (before * 10) != (int) (progress * 10))
|
if ((int) (before * 10) != (int) (progress * 10))
|
||||||
world.sendBlockBreakProgress(player.getEntityId(), clickedPos, (int) (progress * 10));
|
world.sendBlockBreakProgress(player.getEntityId(), clickedPos, (int) (progress * 10));
|
||||||
|
@ -202,10 +207,16 @@ public class DeployerHandler {
|
||||||
|
|
||||||
// Right click
|
// Right click
|
||||||
ItemUseContext itemusecontext = new ItemUseContext(player, hand, result);
|
ItemUseContext itemusecontext = new ItemUseContext(player, hand, result);
|
||||||
RightClickBlock event = ForgeHooks.onRightClickBlock(player, hand, clickedPos, face);
|
Event.Result useBlock = DENY;
|
||||||
|
Event.Result useItem = DEFAULT;
|
||||||
|
if (!clickedState.getRenderShape(world, clickedPos).isEmpty()) {
|
||||||
|
RightClickBlock event = ForgeHooks.onRightClickBlock(player, hand, clickedPos, face);
|
||||||
|
useBlock = event.getUseBlock();
|
||||||
|
useItem = event.getUseItem();
|
||||||
|
}
|
||||||
|
|
||||||
// Item has custom active use
|
// Item has custom active use
|
||||||
if (event.getUseItem() != DENY) {
|
if (useItem != DENY) {
|
||||||
ActionResultType actionresult = stack.onItemUseFirst(itemusecontext);
|
ActionResultType actionresult = stack.onItemUseFirst(itemusecontext);
|
||||||
if (actionresult != ActionResultType.PASS)
|
if (actionresult != ActionResultType.PASS)
|
||||||
return;
|
return;
|
||||||
|
@ -216,11 +227,11 @@ public class DeployerHandler {
|
||||||
!(player.isSneaking() && holdingSomething) || (stack.doesSneakBypassUse(world, clickedPos, player));
|
!(player.isSneaking() && holdingSomething) || (stack.doesSneakBypassUse(world, clickedPos, player));
|
||||||
|
|
||||||
// Use on block
|
// Use on block
|
||||||
if (event.getUseBlock() != DENY && flag1 && clickedState.onBlockActivated(world, player, hand, result))
|
if (useBlock != DENY && flag1 && clickedState.onBlockActivated(world, player, hand, result))
|
||||||
return;
|
return;
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (event.getUseItem() == DENY)
|
if (useItem == DENY)
|
||||||
return;
|
return;
|
||||||
if (item instanceof BlockItem && !clickedState.isReplaceable(new BlockItemUseContext(itemusecontext)))
|
if (item instanceof BlockItem && !clickedState.isReplaceable(new BlockItemUseContext(itemusecontext)))
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue