mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-26 12:57:58 +01:00
Merge pull request #6812 from cakeGit/patch-3-Deployer-Interactions
Deployer interactions -> Fix to issue #3382
This commit is contained in:
commit
cda7402e1d
1 changed files with 13 additions and 4 deletions
|
@ -73,6 +73,7 @@ public class DeployerMovementBehaviour implements MovementBehaviour {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
activate(context, pos, player, mode);
|
activate(context, pos, player, mode);
|
||||||
|
checkForTrackPlacementAdvancement(context, player);
|
||||||
tryDisposeOfExcess(context);
|
tryDisposeOfExcess(context);
|
||||||
context.stall = player.blockBreakingProgress != null;
|
context.stall = player.blockBreakingProgress != null;
|
||||||
}
|
}
|
||||||
|
@ -80,9 +81,13 @@ public class DeployerMovementBehaviour implements MovementBehaviour {
|
||||||
public void activate(MovementContext context, BlockPos pos, DeployerFakePlayer player, Mode mode) {
|
public void activate(MovementContext context, BlockPos pos, DeployerFakePlayer player, Mode mode) {
|
||||||
Level world = context.world;
|
Level world = context.world;
|
||||||
|
|
||||||
|
player.placedTracks = false;
|
||||||
|
|
||||||
FilterItemStack filter = context.getFilterFromBE();
|
FilterItemStack filter = context.getFilterFromBE();
|
||||||
if (AllItems.SCHEMATIC.isIn(filter.item()))
|
if (AllItems.SCHEMATIC.isIn(filter.item())) {
|
||||||
activateAsSchematicPrinter(context, pos, player, world, filter.item());
|
activateAsSchematicPrinter(context, pos, player, world, filter.item());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Vec3 facingVec = Vec3.atLowerCornerOf(context.state.getValue(DeployerBlock.FACING)
|
Vec3 facingVec = Vec3.atLowerCornerOf(context.state.getValue(DeployerBlock.FACING)
|
||||||
.getNormal());
|
.getNormal());
|
||||||
|
@ -101,13 +106,14 @@ public class DeployerMovementBehaviour implements MovementBehaviour {
|
||||||
|
|
||||||
player.setYRot(AbstractContraptionEntity.yawFromVector(facingVec));
|
player.setYRot(AbstractContraptionEntity.yawFromVector(facingVec));
|
||||||
player.setXRot(xRot);
|
player.setXRot(xRot);
|
||||||
player.placedTracks = false;
|
|
||||||
|
|
||||||
DeployerHandler.activate(player, vec, pos, facingVec, mode);
|
DeployerHandler.activate(player, vec, pos, facingVec, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void checkForTrackPlacementAdvancement(MovementContext context, DeployerFakePlayer player) {
|
||||||
if ((context.contraption instanceof MountedContraption || context.contraption instanceof CarriageContraption)
|
if ((context.contraption instanceof MountedContraption || context.contraption instanceof CarriageContraption)
|
||||||
&& player.placedTracks && context.blockEntityData != null && context.blockEntityData.contains("Owner"))
|
&& player.placedTracks && context.blockEntityData != null && context.blockEntityData.contains("Owner"))
|
||||||
AllAdvancements.SELF_DEPLOYING.awardTo(world.getPlayerByUUID(context.blockEntityData.getUUID("Owner")));
|
AllAdvancements.SELF_DEPLOYING.awardTo(context.world.getPlayerByUUID(context.blockEntityData.getUUID("Owner")));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void activateAsSchematicPrinter(MovementContext context, BlockPos pos, DeployerFakePlayer player,
|
protected void activateAsSchematicPrinter(MovementContext context, BlockPos pos, DeployerFakePlayer player,
|
||||||
|
@ -141,7 +147,7 @@ public class DeployerMovementBehaviour implements MovementBehaviour {
|
||||||
if (!context.contraption.hasUniversalCreativeCrate) {
|
if (!context.contraption.hasUniversalCreativeCrate) {
|
||||||
IItemHandler itemHandler = context.contraption.getSharedInventory();
|
IItemHandler itemHandler = context.contraption.getSharedInventory();
|
||||||
for (ItemRequirement.StackRequirement required : requiredItems) {
|
for (ItemRequirement.StackRequirement required : requiredItems) {
|
||||||
ItemStack stack= ItemHelper
|
ItemStack stack = ItemHelper
|
||||||
.extract(itemHandler, required::matches, ExtractionCountMode.EXACTLY,
|
.extract(itemHandler, required::matches, ExtractionCountMode.EXACTLY,
|
||||||
required.stack.getCount(), true);
|
required.stack.getCount(), true);
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
|
@ -155,8 +161,11 @@ public class DeployerMovementBehaviour implements MovementBehaviour {
|
||||||
CompoundTag data = BlockHelper.prepareBlockEntityData(blockState, schematicWorld.getBlockEntity(pos));
|
CompoundTag data = BlockHelper.prepareBlockEntityData(blockState, schematicWorld.getBlockEntity(pos));
|
||||||
BlockSnapshot blocksnapshot = BlockSnapshot.create(world.dimension(), world, pos);
|
BlockSnapshot blocksnapshot = BlockSnapshot.create(world.dimension(), world, pos);
|
||||||
BlockHelper.placeSchematicBlock(world, blockState, pos, contextStack, data);
|
BlockHelper.placeSchematicBlock(world, blockState, pos, contextStack, data);
|
||||||
|
|
||||||
if (ForgeEventFactory.onBlockPlace(player, blocksnapshot, Direction.UP))
|
if (ForgeEventFactory.onBlockPlace(player, blocksnapshot, Direction.UP))
|
||||||
blocksnapshot.restore(true, false);
|
blocksnapshot.restore(true, false);
|
||||||
|
else if (AllBlocks.TRACK.has(blockState))
|
||||||
|
player.placedTracks = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue