@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + conduitType.hashCode(); result = prime * result + NullHelper.first(overrideName, "").hashCode(); return result; }
public Channel(@Nonnull String name, @Nonnull UserIdent user, @Nonnull ChannelType type) { this.name = NullHelper.first(name.trim(), ""); this.user = user; this.type = type; }
public static final @Nonnull String format(@Nonnull String format, Object... args) { try (Formatter f = new Formatter()) { return NullHelper.first(f.format(format, args).toString(), ""); } }
@Override @Nullable public TileEntity getParent(@Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IBlockState state) { return getTileEntity(world, NullHelper.first(state.getValue(BLOCK_TYPE).getLocationOfMaster(pos), pos)); }
@Override public void apply(@Nonnull ItemStack stack) { handleExtraItem(stack, NullHelper.first(pos, getLocation())); } });
public static @Nonnull String getUpgradesAsString(@Nonnull ItemStack stack) { String result = ""; for (IDarkSteelUpgrade upgrade : UpgradeRegistry.getUpgrades()) { if (upgrade.hasUpgrade(stack)) { result += "/" + upgrade.getUnlocalizedName(); } } return result.isEmpty() ? "" : NullHelper.first(result.substring(1), ""); }
@Override public void saveValue(@Nonnull ByteBuf buf, @Nonnull Things value) { NNList<String> nameList = value.getNameList(); if (nameList.size() > 0x7F) { throw new RuntimeException("Thing too big"); } buf.writeByte(nameList.size()); for (String string : nameList) { ByteBufAdapters.STRING127.saveValue(buf, NullHelper.first(string, "")); } }
private @Nonnull BlockPos getNextBoostCoord() { if (boostCoords.isEmpty()) { Iterators.addAll(boostCoords, new PlanarBlockIterator(getPos(), Orientation.HORIZONTAL, getFarmSize())); Collections.shuffle(boostCoords); } return boostCoords.isEmpty() ? pos : NullHelper.first(boostCoords.remove(boostCoords.size() - 1), pos); }
public static @Nonnull ConnectionMode getPrevious(@Nonnull ConnectionMode mode) { int ord = mode.ordinal() - 1; if (ord < 0) { ord = ConnectionMode.values().length - 1; } return NullHelper.first(ConnectionMode.values()[ord], NOT_SET); }
public EnchanterRecipe(@Nonnull Things input, int stackSizePerLevel, @Nonnull Enchantment enchantment, double costMultiplier) { this.input = input; this.stackSizePerLevel = stackSizePerLevel; this.enchantment = enchantment; this.costMultiplier = costMultiplier; this.uuid = NullHelper.first(input.getItemStacksRaw().get(0).toString(), "invalid Recipe"); }
public static @Nonnull ConnectionMode getNext(@Nonnull ConnectionMode mode) { int ord = mode.ordinal() + 1; if (ord >= ConnectionMode.values().length) { ord = 0; } return NullHelper.first(ConnectionMode.values()[ord], NOT_SET); }
@Nonnull Mode next() { int nextOrd = ordinal() + 1; if (nextOrd >= values().length) { nextOrd = 0; } return NullHelper.first(values()[nextOrd], ALL); }
@Nonnull Mode prev() { int nextOrd = ordinal() - 1; if (nextOrd < 0) { nextOrd = values().length - 1; } return NullHelper.first(values()[nextOrd], ALL); } }
@Override public void fromBytes(ByteBuf buf) { int size = buf.readInt(); for (int i = 0; i < size; i++) { String name = ByteBufUtils.readUTF8String(buf); int baseValue = buf.readInt(); String scaler = ByteBufUtils.readUTF8String(buf); ResourceLocation registryName = new ResourceLocation(NullHelper.first(name, "")); data.add(Triple.of(registryName, baseValue, scaler)); } }
public static @Nonnull DamageModeIconHolder getFromMode(DamageMode mode) { if (mode != null) { return NullHelper.first(values()[MathHelper.clamp(mode.ordinal(), 0, values().length - 1)], DISABLED); } return DISABLED; }
@Override public void fromBytes(ByteBuf buf) { super.fromBytes(buf); mode = NullHelper.first(VoidMode.values()[MathHelper.clamp(buf.readByte(), 0, VoidMode.values().length - 1)], mode); }
@Override @Nonnull public ItemStack getStackInSlot(int slot) { if (slot < 0 || slot >= inv.size()) { return Prep.getEmpty(); } return NullHelper.first(inv.get(slot), Prep.getEmpty()); }
private boolean isValidInputItem(@Nonnull ItemStack item, boolean isFilling) { NNList<MachineRecipeInput> list = new NNList<>(); list.add(new MachineRecipeInput(0, item)); list.add(new MachineRecipeInput(1, NullHelper.first(tank.getFluid(), TankMachineRecipe.NOTHING))); return getRecipe(isFilling, list) != null; }
private @Nonnull NNList<MachineRecipeInput> getRecipeInputs(boolean isFilling) { NNList<MachineRecipeInput> list = new NNList<>(); list.add(new MachineRecipeInput(0, getStackInSlot(isFilling ? 1 : 0))); list.add(new MachineRecipeInput(1, NullHelper.first(tank.getFluid(), TankMachineRecipe.NOTHING))); return list; }
@SubscribeEvent(priority = EventPriority.LOWEST) public static void onPlaySoundEvent(PlaySoundEvent event) { final EntityPlayerSP player = Minecraft.getMinecraft().player; if (NullHelper.untrust(player) != null && PaddingUpgrade.INSTANCE.hasUpgrade(player.getItemStackFromSlot(EntityEquipmentSlot.HEAD))) { event.setResultSound(make(NullHelper.first(event.getResultSound(), event.getSound()))); } }