Compare commits

..
32 changed files with 60 additions and 42 deletions

No files matched your search

+1 -1
View File
@@ -45,7 +45,7 @@ enableModernJavaSyntax = true
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = true
enableGenericInjection = false
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
@@ -1294,7 +1294,8 @@ public class BookmarkPanel extends PanelWidget {
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glDisable(GL11.GL_DEPTH_TEST);
List<Slot> slots = this.gui.slotcontainer.inventorySlots;
@SuppressWarnings("unchecked")
List<Slot> slots = (List<Slot>) this.gui.slotcontainer.inventorySlots;
for (Slot slot : slots) {
if (slot != null && slot.getStack() != null) {
@@ -358,10 +358,9 @@ public class ClientHandler {
}
};
@SuppressWarnings("serial")
CustomModLoadingErrorDisplayException e = new CustomModLoadingErrorDisplayException() {
private static final long serialVersionUID = -5593387489666663375L;
@Override
public void initGui(GuiErrorScreen errorScreen, FontRenderer fontRenderer) {
Minecraft.getMinecraft().displayGuiScreen(errorGui);
@@ -116,6 +116,7 @@ public class ContainerPotionCreator extends ContainerExtended {
if (!player.worldObj.isRemote) InventoryUtils.dropOnClose(player, potionInv);
}
@SuppressWarnings("unchecked")
@Override
public void handleServerPacket(PacketCustom packet) {
ItemStack potion = potionInv.getStackInSlot(0);
@@ -60,13 +60,13 @@ public class GuiExtendedCreativeInv extends GuiContainer implements INEIGuiHandl
}
@Override
protected void handleMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType) {
protected void handleMouseClick(Slot p_146984_1_, int p_146984_2_, int p_146984_3_, int p_146984_4_) {
// Hack for armor slots, because they are outside the container
if (slotIn != null && clickType == 4 && slotIn.xDisplayPosition < 0) {
clickType = 0;
if (p_146984_1_ != null && p_146984_4_ == 4 && p_146984_1_.xDisplayPosition < 0) {
p_146984_4_ = 0;
}
super.handleMouseClick(slotIn, slotId, clickedButton, clickType);
super.handleMouseClick(p_146984_1_, p_146984_2_, p_146984_3_, p_146984_4_);
}
}
@@ -210,6 +210,7 @@ public class ItemList {
}
}
@SuppressWarnings("unchecked")
private String getTooltip(ItemStack stack) {
try {
return String.join("\n", stack.getTooltip(Minecraft.getMinecraft().thePlayer, false));
@@ -66,7 +66,7 @@ public class ItemMobSpawner extends ItemBlock {
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer par2EntityPlayer, List<String> list, boolean par4) {
public void addInformation(ItemStack itemstack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
setDefaultTag(itemstack);
int meta = itemstack.getItemDamage();
if (meta == 0) {
@@ -106,10 +106,9 @@ public class ItemMobSpawner extends ItemBlock {
public static void loadSpawners(World world) {
if (loaded) return;
loaded = true;
Map<Class<? extends Entity>, String> classToStringMapping = EntityList.classToStringMapping;
@SuppressWarnings("unchecked")
Map<Class<? extends Entity>, Integer> classToIDMapping = (Map<Class<? extends Entity>, Integer>) EntityList.classToIDMapping;
for (Class<? extends Entity> eclass : classToStringMapping.keySet()) {
HashMap<Class<Entity>, String> classToStringMapping = (HashMap<Class<Entity>, String>) EntityList.classToStringMapping;
HashMap<Class<Entity>, Integer> classToIDMapping = (HashMap<Class<Entity>, Integer>) EntityList.classToIDMapping;
for (Class<Entity> eclass : classToStringMapping.keySet()) {
if (!EntityLiving.class.isAssignableFrom(eclass)) continue;
try {
EntityLiving entityliving = (EntityLiving) eclass.getConstructor(new Class[] { World.class })
@@ -132,7 +131,7 @@ public class ItemMobSpawner extends ItemBlock {
}
@Override
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
public void getSubItems(Item item, CreativeTabs tab, List list) {
if (!NEIClientConfig.hasSMPCounterPart()) list.add(new ItemStack(item));
else for (int i : IDtoNameMap.keySet()) list.add(new ItemStack(item, 1, i));
}
@@ -78,6 +78,7 @@ public class ItemZoom extends Widget implements IContainerInputHandler {
if (key > 0) {
String helpText = NEIClientUtils
.translate("itemzoom.toggle", NEIClientConfig.getKeyName(key, true));
@SuppressWarnings("unchecked")
List<String> lines = fontRenderer.listFormattedStringToWidth(helpText, this.availableAreaWidth);
for (String line : lines) {
@@ -681,7 +681,7 @@ public class NEIClientConfig {
NEIClientConfig.pluginsList.parallelStream().forEach(clazz -> {
try {
IConfigureNEI config = (IConfigureNEI) clazz.getConstructor().newInstance();
IConfigureNEI config = (IConfigureNEI) clazz.newInstance();
config.loadConfig();
NEIModContainer.plugins.add(config);
logger.debug("Loaded {}", clazz.getName());
@@ -89,8 +89,9 @@ public class NEIServerUtils {
else return player.inventory.getStackInSlot(slot);
}
@SuppressWarnings("unchecked")
public static void deleteAllItems(EntityPlayerMP player) {
for (Slot slot : player.openContainer.inventorySlots) slot.putStack(null);
for (Slot slot : (List<Slot>) player.openContainer.inventorySlots) slot.putStack(null);
player.sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory());
}
@@ -43,6 +43,7 @@ public class SearchTokenParser {
public ItemFilter getFilter(String searchText);
@SuppressWarnings("unchecked")
public static List<Language> getAllLanguages() {
return new ArrayList<>(Minecraft.getMinecraft().getLanguageManager().getLanguages());
}
@@ -64,6 +64,7 @@ public class SpawnerRenderer implements IItemRenderer {
BossStatus.hasColorModifier = bossHasColorModifier;
}
@SuppressWarnings("incomplete-switch")
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
switch (type) {
@@ -74,8 +75,6 @@ public class SpawnerRenderer implements IItemRenderer {
case ENTITY:
renderInventoryItem((RenderBlocks) data[0], item);
break;
default:
break;
}
}
@@ -1,5 +1,6 @@
package codechicken.nei;
import static codechicken.nei.LayoutManager.searchField;
import static codechicken.nei.NEIClientUtils.translate;
import java.awt.Point;
@@ -71,7 +72,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
if (slot < sorted.size()) {
SubsetTag tag = sorted.get(slot);
if (NEIClientUtils.shiftKey()) {
LayoutManager.searchField.setText("%" + tag.fullname);
searchField.setText("%" + tag.fullname.replace(" ", ""));
} else if (button == 0 && count >= 2) {
SubsetWidget.showOnly(tag);
} else {
@@ -6,9 +6,9 @@ import cpw.mods.fml.common.FMLCommonHandler;
public class ThreadOperationTimer extends Thread {
@SuppressWarnings("serial")
public static class TimeoutException extends RuntimeException {
private static final long serialVersionUID = -8621458005263888185L;
public final Object operation;
public TimeoutException(String msg, Object op) {
@@ -19,6 +19,7 @@ public interface IOverlayHandler {
default List<Boolean> presenceOverlay(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex) {
final List<Boolean> itemPresenceSlots = new ArrayList<>();
final List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
@SuppressWarnings("unchecked")
final List<ItemStack> invStacks = ((List<Slot>) firstGui.inventorySlots.inventorySlots).stream()
.filter(
s -> s != null && s.getStack() != null
@@ -191,7 +191,7 @@ public class ItemInfo {
public String[] dump(Block block, int id, String name) {
final Item item = Item.getItemFromBlock(block);
return new String[] { name, Integer.toString(id), Boolean.toString(item != null),
ItemInfo.itemOwners.get(item), block.getClass().getCanonicalName(),
ItemInfo.itemOwners.get(block), block.getClass().getCanonicalName(),
item != null ? EnumChatFormatting.getTextWithoutFormattingCodes(
GuiContainerManager.itemDisplayNameShort(new ItemStack(item))) : "null" };
}
@@ -442,6 +442,7 @@ public class ItemInfo {
addEntityEgg(EntityIronGolem.class, 0xC5C2C1, 0xffe1cc);
}
@SuppressWarnings("unchecked")
private static void addEntityEgg(Class<?> entity, int i, int j) {
int id = (Integer) EntityList.classToIDMapping.get(entity);
EntityList.entityEggs.put(id, new EntityEggInfo(id, i, j));
@@ -10,7 +10,6 @@ public abstract class RegistryDumper<T> extends DataDumper {
super(name);
}
@SuppressWarnings("unchecked")
@Override
public Iterable<String[]> dump(int mode) {
LinkedList<String[]> list = new LinkedList<>();
@@ -17,6 +17,7 @@ import cpw.mods.fml.common.eventhandler.Event;
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
*/
@SuppressWarnings("unused")
public class NEIRegisterHandlerInfosEvent extends Event {
public void registerHandlerInfo(HandlerInfo info) {
@@ -149,6 +149,7 @@ public class GuiContainerManager {
* @param includeHandlers If true tooltip handlers will add to the item tip
* @return A list of Strings representing the text to be displayed on each line of the tool tip.
*/
@SuppressWarnings("unchecked")
public static List<String> itemDisplayNameMultiline(ItemStack stack, GuiContainer gui, boolean includeHandlers) {
List<String> namelist = null;
try {
@@ -238,6 +239,7 @@ public class GuiContainerManager {
public static String itemDisplayNameShort(ItemStack itemstack) {
try {
@SuppressWarnings("unchecked")
List<String> namelist = itemstack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
if (!namelist.isEmpty() && !"".equals(namelist.get(0))) {
@@ -21,7 +21,6 @@ import java.util.stream.Stream;
*/
final class HideousLinkedList<E> extends LinkedList<E> {
private static final long serialVersionUID = -8504433551965776915L;
private final List<E> backing;
HideousLinkedList(List<E> backing) {
@@ -17,9 +17,10 @@ import codechicken.nei.FastTransferManager;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.IOverlayHandler;
@SuppressWarnings("rawtypes, unchecked")
public class DefaultOverlayHandler implements IOverlayHandler {
public static Class<?> gtItem;
public static Class gtItem;
static {
try {
@@ -84,6 +85,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
if (quantity != 0) moveIngredients(gui, assignedIngredients, quantity);
}
@SuppressWarnings("unchecked")
private boolean clearIngredients(GuiContainer gui, List<PositionedStack> ingreds) {
for (PositionedStack pstack : ingreds) for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots)
if (slot.xDisplayPosition == pstack.relx + offsetx && slot.yDisplayPosition == pstack.rely + offsety) {
@@ -96,6 +98,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
return true;
}
@SuppressWarnings("unchecked")
private void moveIngredients(GuiContainer gui, List<IngredientDistribution> assignedIngredients, int quantity) {
for (IngredientDistribution distrib : assignedIngredients) {
if (distrib.slots.length == 0) continue;
@@ -242,6 +245,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
return assignedIngredients;
}
@SuppressWarnings("unchecked")
private void findInventoryQuantities(GuiContainer gui, List<DistributedIngred> ingredStacks) {
for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots) /* work out how much we have to go round */ {
if (slot.getHasStack() && canMoveFrom(slot, gui)) {
@@ -268,6 +272,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
return slot.inventory instanceof InventoryPlayer;
}
@SuppressWarnings("unchecked")
public Slot[][] mapIngredSlots(GuiContainer gui, List<PositionedStack> ingredients) {
Slot[][] recipeSlotList = new Slot[ingredients.size()][];
for (int i = 0; i < ingredients.size(); i++) /* identify slots */ {
@@ -51,6 +51,7 @@ public class FuelRecipeHandler extends FurnaceRecipeHandler {
return NEIClientUtils.translate("recipe.fuel");
}
@SuppressWarnings("unchecked")
private void loadAllSmelting() {
// Note: Not safe as written for parallelStream
final Map<ItemStack, ItemStack> smeltingRecipes = (Map<ItemStack, ItemStack>) FurnaceRecipes.smelting()
@@ -9,6 +9,7 @@ import java.util.Optional;
import java.util.stream.Collectors;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.event.GuiScreenEvent;
@@ -222,7 +223,8 @@ public class GuiOverlayButton extends GuiNEIButton {
private List<Boolean> presenceOverlay(List<PositionedStack> ingredients) {
final List<Boolean> itemPresenceSlots = new ArrayList<>();
final List<ItemStack> invStacks = this.firstGui.inventorySlots.inventorySlots.stream()
@SuppressWarnings("unchecked")
final List<ItemStack> invStacks = ((List<Slot>) this.firstGui.inventorySlots.inventorySlots).stream()
.filter(
s -> s != null && s.getStack() != null
&& s.getStack().stackSize > 0
@@ -402,6 +402,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
}
}
@SuppressWarnings("unchecked")
public void initGui() {
xSize = 176;
ySize = Math.min(Math.max(height - 68, 166), 370);
@@ -477,6 +478,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
refreshPage();
}
@SuppressWarnings("unchecked")
private void updateOverlayButtons() {
final List<Integer> indices = getRecipeIndices();
@@ -213,9 +213,10 @@ public abstract class GuiRecipeTab extends Widget {
File handlerFile = NEIClientConfig.handlerFile;
if (!handlerFile.exists()) {
NEIClientConfig.logger.info("Config file doesn't exist, creating");
try (FileOutputStream fileOutputStream = new FileOutputStream(handlerFile.getAbsoluteFile())) {
try {
assert handlerUrl != null;
ReadableByteChannel readableByteChannel = Channels.newChannel(handlerUrl.openStream());
FileOutputStream fileOutputStream = new FileOutputStream(handlerFile.getAbsoluteFile());
FileChannel fileChannel = fileOutputStream.getChannel();
fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
} catch (IOException e) {
@@ -232,7 +233,7 @@ public abstract class GuiRecipeTab extends Widget {
}
}
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
CSVParser csvParser = CSVFormat.EXCEL.builder().setHeader().setSkipHeaderRecord(true).build().parse(reader);
CSVParser csvParser = CSVFormat.EXCEL.withFirstRecordAsHeader().parse(reader);
for (CSVRecord record : csvParser) {
final String handler = record.get("handler");
final String modName = record.get("modName");
@@ -70,12 +70,12 @@ class ItemsHistoryHandler implements ICraftingHandler, IUsageHandler {
}
@Override
public boolean keyTyped(GuiRecipe<?> gui, char keyChar, int keyCode, int recipe) {
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) {
return false;
}
@Override
public boolean mouseClicked(GuiRecipe<?> gui, int button, int recipe) {
public boolean mouseClicked(GuiRecipe gui, int button, int recipe) {
return true;
}
@@ -145,9 +145,10 @@ public class RecipeCatalysts {
File catalystFile = NEIClientConfig.catalystFile;
if (!catalystFile.exists()) {
NEIClientConfig.logger.info("Config file doesn't exist, creating");
try (FileOutputStream fileOutputStream = new FileOutputStream(catalystFile.getAbsoluteFile())) {
try {
assert handlerUrl != null;
ReadableByteChannel readableByteChannel = Channels.newChannel(handlerUrl.openStream());
FileOutputStream fileOutputStream = new FileOutputStream(catalystFile.getAbsoluteFile());
FileChannel fileChannel = fileOutputStream.getChannel();
fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
} catch (IOException e) {
@@ -164,7 +165,7 @@ public class RecipeCatalysts {
}
}
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
CSVParser csvParser = CSVFormat.EXCEL.builder().setHeader().setSkipHeaderRecord(true).build().parse(reader);
CSVParser csvParser = CSVFormat.EXCEL.withFirstRecordAsHeader().parse(reader);
for (CSVRecord record : csvParser) {
final String handler = record.get("handler");
final String modId = record.get("modId");
@@ -193,7 +194,7 @@ public class RecipeCatalysts {
try {
// gently handling copy&paste from handlers.csv
Class<?> clazz = Class.forName(handler);
Object object = clazz.getConstructor().newInstance();
Object object = clazz.newInstance();
if (object instanceof IRecipeHandler) {
if (forceClassName) {
forceClassNameList.add(handler);
@@ -24,9 +24,7 @@ public class StackInfo {
public static final ArrayList<IStackStringifyHandler> stackStringifyHandlers = new ArrayList<>();
private static final HashMap<String, HashMap<String, String[]>> guidfilters = new HashMap<>();
private static final ItemStackMap<String> guidcache = new ItemStackMap<>();
private static final LinkedHashMap<ItemStack, FluidStack> fluidcache = new LinkedHashMap<>() {
private static final long serialVersionUID = 1042213947848622164L;
private static final LinkedHashMap<ItemStack, FluidStack> fluidcache = new LinkedHashMap<ItemStack, FluidStack>() {
@Override
protected boolean removeEldestEntry(Map.Entry<ItemStack, FluidStack> eldest) {
@@ -594,7 +594,7 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
// available
// This will ideally have been pre-cached elsewhere and will be a NOOP
findFuelsOnce();
return getClass().getConstructor().newInstance();
return getClass().newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -1,5 +1,7 @@
package codechicken.nei.util;
import java.util.Set;
import javax.annotation.Nullable;
import net.minecraft.nbt.NBTBase;
@@ -32,7 +34,8 @@ public class NBTHelper {
private static boolean matchTagCompound(NBTTagCompound template, NBTTagCompound target) {
if (template.tagMap.size() > target.tagMap.size()) return false;
for (String key : template.func_150296_c()) {
// noinspection unchecked
for (String key : (Set<String>) template.func_150296_c()) {
if (!matchTag(template.getTag(key), target.getTag(key))) return false;
}
@@ -1,6 +1,5 @@
package codechicken.nei.util;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -217,9 +216,8 @@ public class NBTJson {
if (obj.has("__custom_type")) {
try {
final String className = obj.get("__custom_type").getAsString();
return (NBTBase) Class.forName(className).getConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException
| SecurityException | ClassNotFoundException th) {}
return (NBTBase) Class.forName(className).newInstance();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException th) {}
}
return null;
@@ -31,7 +31,7 @@ public class TextHistory {
}
public Optional<String> get(Direction direction, String currentText) {
if (direction == Direction.NEXT) {
if (direction == direction.NEXT) {
return getNext(currentText);
} else {
return getPrevious(currentText);