Helper swap

- Replaced temporary AllItems#typeOf with ItemEntry's non-static isIn
This commit is contained in:
simibubi 2020-06-03 22:17:11 +02:00
parent 36ab939126
commit 77835c3a65
27 changed files with 34 additions and 49 deletions

View file

@ -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() {}

View file

@ -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;

View file

@ -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))

View file

@ -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();) {

View file

@ -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)

View file

@ -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)

View file

@ -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;

View file

@ -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();

View file

@ -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;

View file

@ -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;
}

View file

@ -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();

View file

@ -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;

View file

@ -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);

View file

@ -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());
}

View file

@ -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);

View file

@ -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();

View file

@ -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;

View file

@ -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();

View file

@ -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);
}

View file

@ -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)));

View file

@ -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);
}
};

View file

@ -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

View file

@ -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() {

View file

@ -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;

View file

@ -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;

View file

@ -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());

View file

@ -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());