mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 16:06:48 +01:00
Helper swap
- Replaced temporary AllItems#typeOf with ItemEntry's non-static isIn
This commit is contained in:
parent
36ab939126
commit
77835c3a65
27 changed files with 34 additions and 49 deletions
|
@ -38,7 +38,6 @@ import com.simibubi.create.foundation.data.CreateRegistrate;
|
|||
import com.tterrag.registrate.util.entry.ItemEntry;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.tags.Tag;
|
||||
|
||||
|
@ -229,12 +228,6 @@ public class AllItems {
|
|||
.register();
|
||||
}
|
||||
|
||||
// Helper
|
||||
|
||||
public static boolean typeOf(ItemEntry<?> entry, ItemStack stack) {
|
||||
return stack != null && stack.getItem() == entry.get();
|
||||
}
|
||||
|
||||
// Load this class
|
||||
|
||||
public static void register() {}
|
||||
|
|
|
@ -173,7 +173,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
|
|||
if (!(te instanceof MechanicalCrafterTileEntity))
|
||||
return ActionResultType.PASS;
|
||||
MechanicalCrafterTileEntity crafter = (MechanicalCrafterTileEntity) te;
|
||||
boolean wrenched = AllItems.typeOf(AllItems.WRENCH, heldItem);
|
||||
boolean wrenched = AllItems.WRENCH.isIn(heldItem);
|
||||
|
||||
if (hit.getFace() == state.get(HORIZONTAL_FACING)) {
|
||||
|
||||
|
@ -186,7 +186,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
|
|||
if (worldIn.isRemote)
|
||||
return ActionResultType.SUCCESS;
|
||||
|
||||
if (AllItems.typeOf(AllItems.CRAFTER_SLOT_COVER, heldItem)) {
|
||||
if (AllItems.CRAFTER_SLOT_COVER.isIn(heldItem)) {
|
||||
if (crafter.covered)
|
||||
return ActionResultType.PASS;
|
||||
crafter.covered = true;
|
||||
|
|
|
@ -85,7 +85,7 @@ public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE<De
|
|||
BlockRayTraceResult hit) {
|
||||
ItemStack heldByPlayer = player.getHeldItem(handIn)
|
||||
.copy();
|
||||
if (AllItems.typeOf(AllItems.WRENCH, heldByPlayer))
|
||||
if (AllItems.WRENCH.isIn(heldByPlayer))
|
||||
return ActionResultType.PASS;
|
||||
|
||||
if (hit.getFace() != state.get(FACING))
|
||||
|
|
|
@ -90,7 +90,7 @@ public class ChassisRangeDisplay {
|
|||
public static void tick() {
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
World world = Minecraft.getInstance().world;
|
||||
boolean hasWrench = AllItems.typeOf(AllItems.WRENCH, player.getHeldItemMainhand());
|
||||
boolean hasWrench = AllItems.WRENCH.isIn(player.getHeldItemMainhand());
|
||||
|
||||
for (Iterator<BlockPos> iterator = entries.keySet()
|
||||
.iterator(); iterator.hasNext();) {
|
||||
|
|
|
@ -49,7 +49,7 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements
|
|||
|
||||
ItemStack heldItem = player.getHeldItem(handIn);
|
||||
boolean isSlimeBall = heldItem.getItem()
|
||||
.isIn(Tags.Items.SLIMEBALLS) || AllItems.typeOf(AllItems.SUPER_GLUE, heldItem);
|
||||
.isIn(Tags.Items.SLIMEBALLS) || AllItems.SUPER_GLUE.isIn(heldItem);
|
||||
|
||||
BooleanProperty affectedSide = getGlueableSide(state, hit.getFace());
|
||||
if (affectedSide == null)
|
||||
|
|
|
@ -63,7 +63,7 @@ public class SuperGlueHandler {
|
|||
|
||||
public static void glueInOffHandAppliesOnBlockPlace(EntityPlaceEvent event, BlockPos pos, PlayerEntity placer) {
|
||||
ItemStack itemstack = placer.getHeldItemOffhand();
|
||||
if (!AllItems.typeOf(AllItems.SUPER_GLUE, itemstack))
|
||||
if (!AllItems.SUPER_GLUE.isIn(itemstack))
|
||||
return;
|
||||
|
||||
double distance = placer.getAttribute(PlayerEntity.REACH_DISTANCE)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.simibubi.create.content.contraptions.components.structureMovement.glue;
|
||||
|
||||
import static com.simibubi.create.AllItems.typeOf;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack.Entry;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
@ -54,8 +52,8 @@ public class SuperGlueRenderer extends EntityRenderer<SuperGlueEntity> {
|
|||
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
boolean visible = isVisible(entity);
|
||||
boolean holdingGlue = typeOf(AllItems.SUPER_GLUE, player.getHeldItemMainhand())
|
||||
|| typeOf(AllItems.SUPER_GLUE, player.getHeldItemOffhand());
|
||||
boolean holdingGlue = AllItems.SUPER_GLUE.isIn(player.getHeldItemMainhand())
|
||||
|| AllItems.SUPER_GLUE.isIn(player.getHeldItemOffhand());
|
||||
|
||||
if (!visible && !holdingGlue)
|
||||
return;
|
||||
|
|
|
@ -185,7 +185,7 @@ public class MinecartContraptionItem extends Item {
|
|||
return;
|
||||
|
||||
ItemStack wrench = player.getHeldItem(event.getHand());
|
||||
if (!AllItems.typeOf(AllItems.WRENCH, wrench))
|
||||
if (!AllItems.WRENCH.isIn(wrench))
|
||||
return;
|
||||
if (entity instanceof ContraptionEntity)
|
||||
entity = entity.getRidingEntity();
|
||||
|
|
|
@ -51,7 +51,7 @@ public class GoggleOverlayRenderer {
|
|||
|
||||
List<String> tooltip = new ArrayList<>();
|
||||
|
||||
if (goggleInformation && AllItems.typeOf(AllItems.GOGGLES, goggles)) {
|
||||
if (goggleInformation && AllItems.GOGGLES.isIn(goggles)) {
|
||||
IHaveGoggleInformation gte = (IHaveGoggleInformation) te;
|
||||
if (!gte.addToGoggleTooltip(tooltip, mc.player.isSneaking()))
|
||||
goggleInformation = false;
|
||||
|
|
|
@ -41,7 +41,7 @@ public class GogglesItem extends Item {
|
|||
|
||||
public static boolean canSeeParticles(PlayerEntity player) {
|
||||
for (ItemStack itemStack : player.getArmorInventoryList())
|
||||
if (AllItems.typeOf(AllItems.GOGGLES, itemStack))
|
||||
if (AllItems.GOGGLES.isIn(itemStack))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen
|
|||
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||
BlockRayTraceResult hit) {
|
||||
ItemStack held = player.getHeldItemMainhand();
|
||||
if (AllItems.typeOf(AllItems.WRENCH, held))
|
||||
if (AllItems.WRENCH.isIn(held))
|
||||
return ActionResultType.PASS;
|
||||
if (held.getItem() instanceof BlockItem) {
|
||||
BlockItem blockItem = (BlockItem) held.getItem();
|
||||
|
|
|
@ -39,7 +39,7 @@ public class BeltConnectorHandler {
|
|||
for (Hand hand : Hand.values()) {
|
||||
ItemStack heldItem = player.getHeldItem(hand);
|
||||
|
||||
if (!AllItems.typeOf(AllItems.BELT_CONNECTOR, heldItem))
|
||||
if (!AllItems.BELT_CONNECTOR.isIn(heldItem))
|
||||
continue;
|
||||
if (!heldItem.hasTag())
|
||||
continue;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.simibubi.create.content.curiosities.symmetry;
|
||||
|
||||
import static com.simibubi.create.AllItems.typeOf;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
@ -77,7 +75,7 @@ public class SymmetryHandler {
|
|||
PlayerInventory inv = player.inventory;
|
||||
for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) {
|
||||
if (!inv.getStackInSlot(i)
|
||||
.isEmpty() && typeOf(AllItems.WAND_OF_SYMMETRY, inv.getStackInSlot(i))) {
|
||||
.isEmpty() && AllItems.WAND_OF_SYMMETRY.isIn(inv.getStackInSlot(i))) {
|
||||
SymmetryWandItem.remove(player.world, inv.getStackInSlot(i), player, event.getPos());
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +89,7 @@ public class SymmetryHandler {
|
|||
|
||||
for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) {
|
||||
ItemStack stackInSlot = player.inventory.getStackInSlot(i);
|
||||
if (!typeOf(AllItems.WAND_OF_SYMMETRY, stackInSlot))
|
||||
if (!AllItems.WAND_OF_SYMMETRY.isIn(stackInSlot))
|
||||
continue;
|
||||
if (!SymmetryWandItem.isEnabled(stackInSlot))
|
||||
continue;
|
||||
|
@ -155,7 +153,7 @@ public class SymmetryHandler {
|
|||
for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) {
|
||||
ItemStack stackInSlot = player.inventory.getStackInSlot(i);
|
||||
|
||||
if (stackInSlot != null && typeOf(AllItems.WAND_OF_SYMMETRY, stackInSlot)
|
||||
if (stackInSlot != null && AllItems.WAND_OF_SYMMETRY.isIn(stackInSlot)
|
||||
&& SymmetryWandItem.isEnabled(stackInSlot)) {
|
||||
|
||||
SymmetryMirror mirror = SymmetryWandItem.getMirror(stackInSlot);
|
||||
|
|
|
@ -60,7 +60,7 @@ public class DeforesterItem extends AxeItem {
|
|||
@SubscribeEvent
|
||||
public static void onBlockDestroyed(BlockEvent.BreakEvent event) {
|
||||
ItemStack heldItemMainhand = event.getPlayer().getHeldItemMainhand();
|
||||
if (!AllItems.typeOf(AllItems.DEFORESTER, heldItemMainhand))
|
||||
if (!AllItems.DEFORESTER.isIn(heldItemMainhand))
|
||||
return;
|
||||
destroyTree(heldItemMainhand, event.getWorld(), event.getState(), event.getPos(), event.getPlayer());
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ public class BlockzapperItem extends ZapperItem {
|
|||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
|
||||
if (AllItems.typeOf(AllItems.BLOCKZAPPER, stack)) {
|
||||
if (AllItems.BLOCKZAPPER.isIn(stack)) {
|
||||
CompoundNBT nbt = stack.getOrCreateTag();
|
||||
if (!nbt.contains("Replace"))
|
||||
nbt.putBoolean("Replace", false);
|
||||
|
|
|
@ -33,8 +33,8 @@ public class BlockzapperRenderHandler {
|
|||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
ItemStack heldMain = player.getHeldItemMainhand();
|
||||
ItemStack heldOff = player.getHeldItemOffhand();
|
||||
boolean zapperInMain = AllItems.typeOf(AllItems.BLOCKZAPPER, heldMain);
|
||||
boolean zapperInOff = AllItems.typeOf(AllItems.BLOCKZAPPER, heldOff);
|
||||
boolean zapperInMain = AllItems.BLOCKZAPPER.isIn(heldMain);
|
||||
boolean zapperInOff = AllItems.BLOCKZAPPER.isIn(heldOff);
|
||||
|
||||
if (zapperInMain) {
|
||||
CompoundNBT tag = heldMain.getOrCreateTag();
|
||||
|
|
|
@ -45,7 +45,7 @@ public class BlockzapperUpgradeRecipe implements ICraftingRecipe {
|
|||
public ItemStack getCraftingResult(CraftingInventory inv) {
|
||||
for (int slot = 0; slot < inv.getSizeInventory(); slot++) {
|
||||
ItemStack handgun = inv.getStackInSlot(slot).copy();
|
||||
if (!AllItems.typeOf(AllItems.BLOCKZAPPER, handgun))
|
||||
if (!AllItems.BLOCKZAPPER.isIn(handgun))
|
||||
continue;
|
||||
BlockzapperItem.setTier(getUpgradedComponent(), getTier(), handgun);
|
||||
return handgun;
|
||||
|
|
|
@ -44,8 +44,8 @@ public class WorldshaperRenderHandler {
|
|||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
ItemStack heldMain = player.getHeldItemMainhand();
|
||||
ItemStack heldOff = player.getHeldItemOffhand();
|
||||
boolean zapperInMain = AllItems.typeOf(AllItems.WORLDSHAPER, heldMain);
|
||||
boolean zapperInOff = AllItems.typeOf(AllItems.WORLDSHAPER, heldOff);
|
||||
boolean zapperInMain = AllItems.WORLDSHAPER.isIn(heldMain);
|
||||
boolean zapperInOff = AllItems.WORLDSHAPER.isIn(heldOff);
|
||||
|
||||
if (zapperInMain) {
|
||||
CompoundNBT tag = heldMain.getOrCreateTag();
|
||||
|
|
|
@ -50,7 +50,7 @@ public class ToggleLatchBlock extends AbstractDiodeBlock {
|
|||
return ActionResultType.PASS;
|
||||
if (player.isSneaking())
|
||||
return ActionResultType.PASS;
|
||||
if (AllItems.typeOf(AllItems.WRENCH, player.getHeldItem(handIn)))
|
||||
if (AllItems.WRENCH.isIn(player.getHeldItem(handIn)))
|
||||
return ActionResultType.PASS;
|
||||
return activated(worldIn, pos, state);
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ public class StockpileSwitchBlock extends HorizontalBlock implements ITE<Stockpi
|
|||
@Override
|
||||
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||
BlockRayTraceResult hit) {
|
||||
if (player != null && AllItems.typeOf(AllItems.WRENCH, player.getHeldItem(handIn)))
|
||||
if (player != null && AllItems.WRENCH.isIn(player.getHeldItem(handIn)))
|
||||
return ActionResultType.PASS;
|
||||
DistExecutor.runWhenOn(Dist.CLIENT,
|
||||
() -> () -> withTileEntityDo(worldIn, pos, te -> this.displayScreen(te, player)));
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.simibubi.create.content.schematics.block;
|
||||
|
||||
import static com.simibubi.create.AllItems.typeOf;
|
||||
|
||||
import com.simibubi.create.AllContainerTypes;
|
||||
import com.simibubi.create.AllItems;
|
||||
|
||||
|
@ -46,9 +44,8 @@ public class SchematicTableContainer extends Container {
|
|||
inputSlot = new SlotItemHandler(te.inventory, 0, -9, 40) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return typeOf(AllItems.EMPTY_SCHEMATIC, stack)
|
||||
|| typeOf(AllItems.SCHEMATIC_AND_QUILL, stack)
|
||||
|| typeOf(AllItems.SCHEMATIC, stack);
|
||||
return AllItems.EMPTY_SCHEMATIC.isIn(stack) || AllItems.SCHEMATIC_AND_QUILL.isIn(stack)
|
||||
|| AllItems.SCHEMATIC.isIn(stack);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public class SchematicannonInventory extends ItemStackHandler {
|
|||
public boolean isItemValid(int slot, ItemStack stack) {
|
||||
switch (slot) {
|
||||
case 0: // Blueprint Slot
|
||||
return AllItems.typeOf(AllItems.SCHEMATIC, stack);
|
||||
return AllItems.SCHEMATIC.isIn(stack);
|
||||
case 1: // Blueprint output
|
||||
return false;
|
||||
case 2: // Book input
|
||||
|
|
|
@ -177,7 +177,7 @@ public class SchematicAndQuillHandler {
|
|||
outliner().chaseAABB(outlineSlot, currentSelectionBox)
|
||||
.colored(0x6886c5)
|
||||
.withFaceTextures(AllSpecialTextures.CHECKERED, AllSpecialTextures.HIGHLIGHT_CHECKERED)
|
||||
.lineWidth(1/16f)
|
||||
.lineWidth(1 / 16f)
|
||||
.highlightFace(selectedFace);
|
||||
}
|
||||
|
||||
|
@ -192,8 +192,7 @@ public class SchematicAndQuillHandler {
|
|||
}
|
||||
|
||||
private boolean isActive() {
|
||||
return isPresent() && AllItems.typeOf(AllItems.SCHEMATIC_AND_QUILL,
|
||||
Minecraft.getInstance().player.getHeldItemMainhand());
|
||||
return isPresent() && AllItems.SCHEMATIC_AND_QUILL.isIn(Minecraft.getInstance().player.getHeldItemMainhand());
|
||||
}
|
||||
|
||||
private boolean isPresent() {
|
||||
|
|
|
@ -234,7 +234,7 @@ public class SchematicHandler {
|
|||
|
||||
private ItemStack findBlueprintInHand(PlayerEntity player) {
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (!AllItems.typeOf(AllItems.SCHEMATIC, stack))
|
||||
if (!AllItems.SCHEMATIC.isIn(stack))
|
||||
return null;
|
||||
if (!stack.hasTag())
|
||||
return null;
|
||||
|
|
|
@ -97,7 +97,7 @@ public class TooltipHelper {
|
|||
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
boolean hasGlasses = player != null
|
||||
&& AllItems.typeOf(AllItems.GOGGLES, player.getItemStackFromSlot(EquipmentSlotType.HEAD));
|
||||
&& AllItems.GOGGLES.isIn(player.getItemStackFromSlot(EquipmentSlotType.HEAD));
|
||||
|
||||
if (hasGlasses != gogglesMode) {
|
||||
gogglesMode = hasGlasses;
|
||||
|
|
|
@ -36,7 +36,7 @@ public class ScrollValueHandler {
|
|||
return false;
|
||||
if (!mc.player.isAllowEdit())
|
||||
return false;
|
||||
if (scrolling.needsWrench && !AllItems.typeOf(AllItems.WRENCH, mc.player.getHeldItemMainhand()))
|
||||
if (scrolling.needsWrench && !AllItems.WRENCH.isIn(mc.player.getHeldItemMainhand()))
|
||||
return false;
|
||||
if (scrolling.slotPositioning instanceof Sided)
|
||||
((Sided) scrolling.slotPositioning).fromSide(result.getFace());
|
||||
|
|
|
@ -36,7 +36,7 @@ public class ScrollValueRenderer {
|
|||
if (behaviour == null)
|
||||
return;
|
||||
if (behaviour.needsWrench
|
||||
&& !AllItems.typeOf(AllItems.WRENCH, Minecraft.getInstance().player.getHeldItemMainhand()))
|
||||
&& !AllItems.WRENCH.isIn(Minecraft.getInstance().player.getHeldItemMainhand()))
|
||||
return;
|
||||
boolean highlight = behaviour.testHit(target.getHitVec());
|
||||
|
||||
|
|
Loading…
Reference in a new issue