mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-02-14 22:35:07 +01:00
Mirror, Mirror on the Vault
- Vaults and tanks no longer multi-place when a symmetry wand is active
This commit is contained in:
parent
3c92ace8eb
commit
f0b8e49d1d
4 changed files with 21 additions and 14 deletions
|
@ -52,19 +52,13 @@ public class SymmetryHandler {
|
|||
if (event.getLevel()
|
||||
.isClientSide())
|
||||
return;
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
if (!(event.getEntity() instanceof Player player))
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
Inventory inv = player.getInventory();
|
||||
for (int i = 0; i < Inventory.getSelectionSize(); i++) {
|
||||
if (!inv.getItem(i)
|
||||
.isEmpty()
|
||||
&& inv.getItem(i)
|
||||
.getItem() == AllItems.WAND_OF_SYMMETRY.get()) {
|
||||
for (int i = 0; i < Inventory.getSelectionSize(); i++)
|
||||
if (AllItems.WAND_OF_SYMMETRY.isIn(inv.getItem(i)))
|
||||
SymmetryWandItem.apply(player.level(), inv.getItem(i), player, event.getPos(), event.getPlacedBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
|
@ -75,12 +69,9 @@ public class SymmetryHandler {
|
|||
|
||||
Player player = event.getPlayer();
|
||||
Inventory inv = player.getInventory();
|
||||
for (int i = 0; i < Inventory.getSelectionSize(); i++) {
|
||||
if (!inv.getItem(i)
|
||||
.isEmpty() && AllItems.WAND_OF_SYMMETRY.isIn(inv.getItem(i))) {
|
||||
for (int i = 0; i < Inventory.getSelectionSize(); i++)
|
||||
if (AllItems.WAND_OF_SYMMETRY.isIn(inv.getItem(i)))
|
||||
SymmetryWandItem.remove(player.level(), inv.getItem(i), player, event.getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.function.Consumer;
|
|||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.AllPackets;
|
||||
import com.simibubi.create.content.contraptions.mounted.CartAssemblerBlock;
|
||||
import com.simibubi.create.content.equipment.symmetryWand.mirror.CrossPlaneMirror;
|
||||
|
@ -27,6 +28,7 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
@ -328,5 +330,13 @@ public class SymmetryWandItem extends Item {
|
|||
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
|
||||
consumer.accept(SimpleCustomRenderer.create(this, new SymmetryWandItemRenderer()));
|
||||
}
|
||||
|
||||
public static boolean presentInHotbar(Player player) {
|
||||
Inventory inv = player.getInventory();
|
||||
for (int i = 0; i < Inventory.getSelectionSize(); i++)
|
||||
if (AllItems.WAND_OF_SYMMETRY.isIn(inv.getItem(i)))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.fluids.tank;
|
|||
import com.simibubi.create.AllBlockEntityTypes;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.api.connectivity.ConnectivityHandler;
|
||||
import com.simibubi.create.content.equipment.symmetryWand.SymmetryWandItem;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -75,6 +76,8 @@ public class FluidTankItem extends BlockItem {
|
|||
|
||||
if (!FluidTankBlock.isTank(placedOnState))
|
||||
return;
|
||||
if (SymmetryWandItem.presentInHotbar(player))
|
||||
return;
|
||||
boolean creative = getBlock().equals(AllBlocks.CREATIVE_FLUID_TANK.get());
|
||||
FluidTankBlockEntity tankAt = ConnectivityHandler.partAt(
|
||||
creative ? AllBlockEntityTypes.CREATIVE_FLUID_TANK.get() : AllBlockEntityTypes.FLUID_TANK.get(), world, placedOnPos
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.content.logistics.vault;
|
|||
|
||||
import com.simibubi.create.AllBlockEntityTypes;
|
||||
import com.simibubi.create.api.connectivity.ConnectivityHandler;
|
||||
import com.simibubi.create.content.equipment.symmetryWand.SymmetryWandItem;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -65,6 +66,8 @@ public class ItemVaultItem extends BlockItem {
|
|||
|
||||
if (!ItemVaultBlock.isVault(placedOnState))
|
||||
return;
|
||||
if (SymmetryWandItem.presentInHotbar(player))
|
||||
return;
|
||||
ItemVaultBlockEntity tankAt = ConnectivityHandler.partAt(AllBlockEntityTypes.ITEM_VAULT.get(), world, placedOnPos);
|
||||
if (tankAt == null)
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue