Fix all (non-deprecation) compiler warnings (#3321)

* Fix all (non-deprecation) compiler warnings

* satisfy spotless

* use a method ref over a lambda
This commit is contained in:
Al Winfy authored and GitHub committed 2020-06-07 21:48:55 -05:00
1 parent a01f3fed15
commit cbc36366de
30 files changed
+55 -40

No files matched your search

@@ -32,7 +32,8 @@ public final class SparkHelper {
public static <T> List<T> getEntitiesAround(Class<? extends T> clazz, World world, double x, double y, double z) {
int r = SPARK_SCAN_RANGE;
List entities = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(x - r, y - r, z - r, x + r, y + r, z + r), Predicates.instanceOf(clazz));
@SuppressWarnings("unchecked")
List<T> entities = (List<T>) (List<?>) world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(x - r, y - r, z - r, x + r, y + r, z + r), Predicates.instanceOf(clazz));
return entities;
}
@@ -14,7 +14,7 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.inventory.EquipmentSlotType;
public class ModelArmor extends BipedModel {
public class ModelArmor extends BipedModel<LivingEntity> {
protected final EquipmentSlotType slot;
public ModelArmor(EquipmentSlotType slot) {
@@ -78,7 +78,7 @@ public class MultiCraftingProcessor implements IComponentProcessor {
List<Ingredient> ingredients = new ArrayList<>();
for (ICraftingRecipe recipe : recipes) {
if (recipe instanceof IShapedRecipe) {
IShapedRecipe shaped = (IShapedRecipe) recipe;
IShapedRecipe<?> shaped = (IShapedRecipe<?>) recipe;
if (shaped.getRecipeWidth() < shapedX + 1) {
ingredients.add(Ingredient.EMPTY);
} else {
@@ -95,7 +95,7 @@ public class MultiCraftingProcessor implements IComponentProcessor {
return PatchouliUtils.interweaveIngredients(ingredients, longestIngredientSize);
}
if (key.equals("output")) {
return recipes.stream().map(IRecipe::getRecipeOutput).map(PatchouliAPI.instance::serializeItemStack).collect(Collectors.joining(","));
return recipes.stream().map(ICraftingRecipe::getRecipeOutput).map(PatchouliAPI.instance::serializeItemStack).collect(Collectors.joining(","));
}
if (key.equals("shapeless")) {}
return null;
@@ -30,7 +30,7 @@ import javax.annotation.Nonnull;
import java.util.Random;
public class RenderTileFloatingFlower extends TileEntityRenderer {
public class RenderTileFloatingFlower extends TileEntityRenderer<TileEntity> {
public RenderTileFloatingFlower(TileEntityRendererDispatcher manager) {
super(manager);
@@ -102,8 +102,8 @@ public class SubTileDaffomill extends TileEntityFunctionalFlower {
break;
case EAST:
axis = new AxisAlignedBB(x + 1, y - h, z - w, x + l + 1, y + h, z + w + 1);
default:
break;
default:
}
return axis;
}
@@ -8,6 +8,7 @@
*/
package vazkii.botania.common.block.subtile.functional;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.ai.goal.AvoidEntityGoal;
import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
@@ -39,6 +40,7 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower {
}
@Override
@SuppressWarnings("deprecated")
public void tickFlower() {
super.tickFlower();
@@ -80,6 +82,8 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower {
}
}
// TODO replace this kludge
@SuppressWarnings({ "unchecked", "rawtypes" })
private boolean messWithRunAwayAI(AvoidEntityGoal aiEntry) {
if (aiEntry.classToAvoid == OcelotEntity.class) {
aiEntry.classToAvoid = PlayerEntity.class;
@@ -88,6 +92,7 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower {
return false;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private void messWithGetTargetAI(NearestAttackableTargetGoal aiEntry) {
if (aiEntry.targetClass == PlayerEntity.class) {
aiEntry.targetClass = EnderCrystalEntity.class; // Something random that won't be around
@@ -268,11 +268,12 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
}
}
@SuppressWarnings("unchecked")
public static Collection<IElvenTradeRecipe> elvenTradeRecipes(RecipeManager rm) {
// By virtue of IRecipeType's type parameter,
// we know all the recipes in the map must be AbstractElvenTradeRecipe.
// However, vanilla's signature on this method is dumb (should be Map<ResourceLocation, T>)
return (Collection) rm.getRecipes(ModRecipeTypes.ELVEN_TRADE_TYPE).values();
return (Collection<IElvenTradeRecipe>) (Collection<?>) rm.getRecipes(ModRecipeTypes.ELVEN_TRADE_TYPE).values();
}
private void resolveRecipes() {
@@ -65,7 +65,7 @@ public class TileSparkChanger extends TileSimpleInventory {
ItemStack sparkStack = ItemSparkUpgrade.getByType(upg);
SparkUpgradeType newUpg = changeStack.isEmpty() ? SparkUpgradeType.NONE : ((ItemSparkUpgrade) changeStack.getItem()).type;
spark.setUpgrade(newUpg);
Collection transfers = spark.getTransfers();
Collection<ISparkEntity> transfers = spark.getTransfers();
if (transfers != null) {
transfers.clear();
}
@@ -468,9 +468,9 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
@Override
public ISparkEntity getAttachedSpark() {
List sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.up(), pos.up().add(1, 1, 1)), Predicates.instanceOf(ISparkEntity.class));
List<Entity> sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.up(), pos.up().add(1, 1, 1)), Predicates.instanceOf(ISparkEntity.class));
if (sparks.size() == 1) {
Entity e = (Entity) sparks.get(0);
Entity e = sparks.get(0);
return (ISparkEntity) e;
}
@@ -217,10 +217,11 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
double y = lastPingbackY;
double z = lastPingbackZ;
AxisAlignedBB aabb = new AxisAlignedBB(x, y, z, x, y, z).grow(PINGBACK_EXPIRED_SEARCH_DISTANCE, PINGBACK_EXPIRED_SEARCH_DISTANCE, PINGBACK_EXPIRED_SEARCH_DISTANCE);
List bursts = world.getEntitiesWithinAABB(ThrowableEntity.class, aabb, Predicates.instanceOf(IManaBurst.class));
@SuppressWarnings("unchecked")
List<IManaBurst> bursts = (List<IManaBurst>) (List<?>) world.getEntitiesWithinAABB(ThrowableEntity.class, aabb, Predicates.instanceOf(IManaBurst.class));
IManaBurst found = null;
UUID identity = getIdentifier();
for (IManaBurst burst : (List<IManaBurst>) bursts) {
for (IManaBurst burst : bursts) {
if (burst != null && identity.equals(burst.getShooterUUID())) {
found = burst;
break;
@@ -709,7 +709,7 @@ public final class BotaniaCreativeTab extends ItemGroup {
private void addTag(ResourceLocation tagId) {
ItemTags.getCollection().getOrCreate(tagId).getAllElements().stream()
.sorted(Comparator.comparing(ForgeRegistryEntry::getRegistryName))
.sorted(Comparator.comparing(ForgeRegistryEntry<?>::getRegistryName))
.forEach(this::addItem);
}
@@ -51,7 +51,7 @@ public class ExoflameFurnaceHandler {
}
public static boolean canSmelt(AbstractFurnaceTileEntity furnace, IRecipe<?> recipe) throws Throwable {
return (boolean) CAN_SMELT.invokeExact((AbstractFurnaceTileEntity) furnace, recipe);
return (boolean) CAN_SMELT.invokeExact(furnace, recipe);
}
@SuppressWarnings("unchecked")
@@ -30,6 +30,7 @@ public final class IMCHandler {
}
private static Map<ResourceLocation, Integer> handleOreWeights(Stream<InterModComms.IMCMessage> msgs) {
@SuppressWarnings("unchecked")
Map<ResourceLocation, Integer> map = msgs
.filter(msg -> {
Object thing = msg.getMessageSupplier().get();
@@ -35,7 +35,7 @@ public class ExperienceHelper {
}
if (level > 0 && level < 17) {
return (int) (level * level + 6 * level);
return (level * level + 6 * level);
} else if (level > 16 && level < 32) {
return (int) (2.5 * level * level - 40.5 * level + 360);
} else {
@@ -52,7 +52,7 @@ public final class LootHandler {
.build();
}
private static LootEntry.Builder getInjectEntry(String name, int weight) {
private static LootEntry.Builder<?> getInjectEntry(String name, int weight) {
ResourceLocation table = new ResourceLocation(LibMisc.MOD_ID, "inject/" + name);
return TableLootEntry.builder(table)
.weight(weight);
@@ -510,7 +510,7 @@ public class EntityDoppleganger extends MobEntity implements IEntityAdditionalSp
private static int countGaiaGuardiansAround(World world, BlockPos source) {
float range = 15F;
List l = world.getEntitiesWithinAABB(EntityDoppleganger.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range));
List<EntityDoppleganger> l = world.getEntitiesWithinAABB(EntityDoppleganger.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range));
return l.size();
}
@@ -191,14 +191,14 @@ public class EntityMagicMissile extends ThrowableEntity {
double range = 12;
AxisAlignedBB bounds = new AxisAlignedBB(getPosX() - range, getPosY() - range, getPosZ() - range, getPosX() + range, getPosY() + range, getPosZ() + range);
List entities;
List<Entity> entities;
if (isEvil()) {
entities = world.getEntitiesWithinAABB(PlayerEntity.class, bounds);
} else {
entities = world.getEntitiesWithinAABB(Entity.class, bounds, Predicates.instanceOf(IMob.class));
}
while (entities.size() > 0) {
Entity e = (Entity) entities.get(world.rand.nextInt(entities.size()));
Entity e = entities.get(world.rand.nextInt(entities.size()));
if (!(e instanceof LivingEntity) || !e.isAlive()) { // Just in case...
entities.remove(e);
continue;
@@ -230,6 +230,7 @@ public class ItemTwigWand extends Item implements ICoordBoundItem {
private static BlockState rotate(BlockState old, Direction.Axis axis) {
for (IProperty<?> prop : old.getProperties()) {
if (prop.getName().equals("facing") && prop.getValueClass() == Direction.class) {
@SuppressWarnings("unchecked")
IProperty<Direction> facingProp = (IProperty<Direction>) prop;
Direction oldDir = old.get(facingProp);
@@ -184,10 +184,10 @@ public class ItemBrewBase extends Item implements IBrewItem {
}
if (d0 > 0.0D) {
lores.add((new TranslationTextComponent("attribute.modifier.plus." + attributemodifier2.getOperation().getId(), ItemStack.DECIMALFORMAT.format(d1), new TranslationTextComponent("attribute.name." + (String) tuple.getA()))).applyTextStyle(TextFormatting.BLUE));
lores.add((new TranslationTextComponent("attribute.modifier.plus." + attributemodifier2.getOperation().getId(), ItemStack.DECIMALFORMAT.format(d1), new TranslationTextComponent("attribute.name." + tuple.getA()))).applyTextStyle(TextFormatting.BLUE));
} else if (d0 < 0.0D) {
d1 = d1 * -1.0D;
lores.add((new TranslationTextComponent("attribute.modifier.take." + attributemodifier2.getOperation().getId(), ItemStack.DECIMALFORMAT.format(d1), new TranslationTextComponent("attribute.name." + (String) tuple.getA()))).applyTextStyle(TextFormatting.RED));
lores.add((new TranslationTextComponent("attribute.modifier.take." + attributemodifier2.getOperation().getId(), ItemStack.DECIMALFORMAT.format(d1), new TranslationTextComponent("attribute.name." + tuple.getA()))).applyTextStyle(TextFormatting.RED));
}
}
}
@@ -36,7 +36,7 @@ public abstract class ItemElementiumArmor extends ItemManasteelArmor {
@Override
@OnlyIn(Dist.CLIENT)
public BipedModel provideArmorModelForSlot(EquipmentSlotType slot) {
public BipedModel<?> provideArmorModelForSlot(EquipmentSlotType slot) {
return new ModelArmorElementium(slot);
}
@@ -51,7 +51,7 @@ public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPh
private static final String TAG_PHANTOM_INK = "phantomInk";
private final LazyValue<BipedModel> model;
private final LazyValue<BipedModel<?>> model;
public final EquipmentSlotType type;
public ItemManasteelArmor(EquipmentSlotType type, Properties props) {
@@ -96,16 +96,17 @@ public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPh
@Override
@OnlyIn(Dist.CLIENT)
public BipedModel getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType armorSlot, BipedModel original) {
@SuppressWarnings("unchecked")
public <A extends BipedModel<?>> A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType armorSlot, A original) {
if (ConfigHandler.CLIENT.enableArmorModels.get()) {
return model.getValue();
return (A) model.getValue();
}
return super.getArmorModel(entityLiving, itemStack, armorSlot, original);
}
@OnlyIn(Dist.CLIENT)
public BipedModel provideArmorModelForSlot(EquipmentSlotType slot) {
public BipedModel<?> provideArmorModelForSlot(EquipmentSlotType slot) {
return new ModelArmorManasteel(slot);
}
@@ -44,7 +44,7 @@ public class ItemManaweaveArmor extends ItemManasteelArmor {
@Override
@OnlyIn(Dist.CLIENT)
public BipedModel provideArmorModelForSlot(EquipmentSlotType slot) {
public BipedModel<?> provideArmorModelForSlot(EquipmentSlotType slot) {
return new ModelArmorManaweave(slot);
}
@@ -43,7 +43,7 @@ public class ItemTerrasteelArmor extends ItemManasteelArmor {
@Override
@OnlyIn(Dist.CLIENT)
public BipedModel provideArmorModelForSlot(EquipmentSlotType slot) {
public BipedModel<?> provideArmorModelForSlot(EquipmentSlotType slot) {
return new ModelArmorTerrasteel(slot);
}
@@ -69,9 +69,10 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem {
if (ManaItemHandler.instance().requestManaExact(amulet, player, cost, false)) {
final int range = 20;
List mobs = player.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(target.getPosX() - range, target.getPosY() - range, target.getPosZ() - range, target.getPosX() + range, target.getPosY() + range, target.getPosZ() + range), Predicates.instanceOf(IMob.class));
@SuppressWarnings("unchecked")
List<IMob> mobs = (List<IMob>) (List<?>) player.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(target.getPosX() - range, target.getPosY() - range, target.getPosZ() - range, target.getPosX() + range, target.getPosY() + range, target.getPosZ() + range), Predicates.instanceOf(IMob.class));
if (mobs.size() > 1) {
if (SubTileHeiseiDream.brainwashEntity(target, (List<IMob>) mobs)) {
if (SubTileHeiseiDream.brainwashEntity(target, mobs)) {
target.heal(target.getMaxHealth());
target.revive();
if (target instanceof CreeperEntity) {
@@ -31,7 +31,7 @@ import vazkii.botania.client.lib.LibResources;
public class ItemKnockbackBelt extends ItemBauble {
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_KNOCKBACK_BELT);
private static BipedModel model;
private static BipedModel<LivingEntity> model;
public ItemKnockbackBelt(Properties props) {
super(props);
@@ -53,7 +53,7 @@ public class ItemKnockbackBelt extends ItemBauble {
float s = 0.85F;
ms.scale(s, s, s);
if (model == null) {
model = new BipedModel(1.0F);
model = new BipedModel<>(1.0F);
}
IVertexBuilder buffer = buffers.getBuffer(model.getRenderType(texture));
@@ -39,7 +39,7 @@ import java.util.List;
public class ItemTravelBelt extends ItemBauble implements IManaUsingItem {
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TRAVEL_BELT);
@OnlyIn(Dist.CLIENT) private static BipedModel model;
@OnlyIn(Dist.CLIENT) private static BipedModel<LivingEntity> model;
private static final int COST = 1;
private static final int COST_INTERVAL = 10;
@@ -154,7 +154,7 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem {
float s = 0.85F;
ms.scale(s, s, s);
if (model == null) {
model = new BipedModel(1F);
model = new BipedModel<>(1F);
}
ResourceLocation texture = ((ItemTravelBelt) stack.getItem()).getRenderTexture();
@@ -42,8 +42,9 @@ public class ItemUnholyCloak extends ItemHolyCloak {
public boolean effectOnDamage(LivingHurtEvent event, PlayerEntity player, ItemStack stack) {
if (!event.getSource().isUnblockable()) {
int range = 6;
List mobs = player.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(player.getPosX() - range, player.getPosY() - range, player.getPosZ() - range, player.getPosX() + range, player.getPosY() + range, player.getPosZ() + range), Predicates.instanceOf(IMob.class));
for (IMob mob : (List<IMob>) mobs) {
@SuppressWarnings("unchecked")
List<IMob> mobs = (List<IMob>) (List<?>) player.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(player.getPosX() - range, player.getPosY() - range, player.getPosZ() - range, player.getPosX() + range, player.getPosY() + range, player.getPosZ() + range), Predicates.instanceOf(IMob.class));
for (IMob mob : mobs) {
if (mob instanceof LivingEntity) {
LivingEntity entity = (LivingEntity) mob;
entity.attackEntityFrom(DamageSource.causePlayerDamage(player), event.getAmount());
@@ -68,10 +68,11 @@ public class ItemElementiumShears extends ItemManasteelShears {
if (count != getUseDuration(stack) && count % 5 == 0) {
int range = 12;
List sheep = living.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(living.getPosX() - range, living.getPosY() - range, living.getPosZ() - range, living.getPosX() + range, living.getPosY() + range, living.getPosZ() + range), Predicates.instanceOf(IShearable.class));
List<Entity> sheep = living.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(living.getPosX() - range, living.getPosY() - range, living.getPosZ() - range, living.getPosX() + range, living.getPosY() + range, living.getPosZ() + range), Predicates.instanceOf(IShearable.class));
if (sheep.size() > 0) {
for (IShearable target : (List<IShearable>) sheep) {
Entity entity = (Entity) target;
for (Entity entity : sheep) {
@SuppressWarnings("unchecked")
IShearable target = (IShearable) entity;
if (target.isShearable(stack, entity.world, new BlockPos(entity))) {
List<ItemStack> drops = target.onSheared(stack, entity.world, new BlockPos(entity), EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack));
@@ -164,8 +164,8 @@ public class ItemRainbowRod extends Item implements IManaUsingItem, IAvatarWield
break;
case EAST:
axis = new AxisAlignedBB(tePos.add(1, -h, -w), tePos.add(l + 1, h, w + 1));
default:
break;
default:
}
List<PlayerEntity> players = world.getEntitiesWithinAABB(PlayerEntity.class, axis);
@@ -251,6 +251,7 @@ public class ManaInfusionProvider extends RecipeProvider {
}
}
@SuppressWarnings("unchecked")
private static <T extends Comparable<T>> String getName(IProperty<T> prop, Comparable<?> val) {
return prop.getName((T) val);
}