Generics for everyone \o/

This commit is contained in:
Chocohead committed 2017-01-26 18:18:14 +00:00
1 parent ac9344cbda
commit 23ed2dcaea
55 files changed
+164 -163

No files matched your search

+2 -2
View File
@@ -41,7 +41,7 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
return new IBinnieGUID[0];
}
public Class[] getConfigs() {
public Class<?>[] getConfigs() {
return new Class[0];
}
@@ -63,7 +63,7 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
}
registerModules();
if (this.getConfigs() != null) {
for (final Class cls : this.getConfigs()) {
for (final Class<?> cls : this.getConfigs()) {
Binnie.CONFIGURATION.registerConfiguration(cls, this);
}
}
@@ -33,7 +33,7 @@ import javax.vecmath.Vector3f;
import java.util.EnumMap;
public abstract class BaseBakedModel implements IPerspectiveAwareModel {
private final EnumMap<ItemCameraTransforms.TransformType, TRSRTransformation> transformMap = new EnumMap(ItemCameraTransforms.TransformType.class);
private final EnumMap<ItemCameraTransforms.TransformType, TRSRTransformation> transformMap = new EnumMap<>(ItemCameraTransforms.TransformType.class);
private final ResourceLocation particle;
public BaseBakedModel() {
@@ -4,7 +4,7 @@ import java.util.List;
public interface IItemMiscProvider extends IItemEnum {
void addInformation(List tooltip);
void addInformation(List<String> tooltip);
String getModelPath();
}
@@ -73,8 +73,8 @@ public class ItemFieldKit extends ItemCore {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(final ItemStack p_77624_1_, final EntityPlayer p_77624_2_, final List p_77624_3_, final boolean p_77624_4_) {
final int i = this.getMaxDamage() - p_77624_1_.getItemDamage();
public void addInformation(final ItemStack p_77624_1_, final EntityPlayer p_77624_2_, final List<String> p_77624_3_, final boolean p_77624_4_) {
final int i = p_77624_1_.getMaxDamage() - p_77624_1_.getItemDamage();
if (i == 0) {
p_77624_3_.add("No paper");
} else {
@@ -23,7 +23,7 @@ public class ItemGenesis extends ItemCore {
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand) {
BinnieCore.proxy.openGui(BinnieCoreGUI.Genesis, player, new BlockPos((int) player.posX, (int) player.posY, (int) player.posZ));
return new ActionResult(EnumActionResult.SUCCESS, itemStack);
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
@@ -61,7 +61,7 @@ public class ItemFluidContainer extends ItemFood implements IItemModelRegister {
}
@Override
public void getSubItems(final Item item, final CreativeTabs tab, final List subItems) {
public void getSubItems(final Item item, final CreativeTabs tab, final List<ItemStack> subItems) {
super.getSubItems(item, tab, subItems);
for (final IFluidType liquid : Binnie.LIQUID.fluids.values()) {
if (!liquid.canPlaceIn(this.container)) {
@@ -127,7 +127,7 @@ public class ItemFluidContainer extends ItemFood implements IItemModelRegister {
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if (this.isDrinkable(stack) && player.canEat(false)) {
player.setActiveHand(hand);
return new ActionResult(EnumActionResult.SUCCESS, stack);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}else{
return super.onItemRightClick(stack, world, player, hand);
}
@@ -32,7 +32,7 @@ import java.util.Map;
public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, INetwork.TilePacketSync, IMachine, INetwork.GuiNBT {
private MachinePackage machinePackage;
private Map<Class, List<MachineComponent>> componentInterfaceMap;
private Map<Class<? extends MachineComponent>, List<MachineComponent>> componentInterfaceMap;
private Map<Class<? extends MachineComponent>, MachineComponent> componentMap;
private TileEntity tile;
private boolean queuedInventoryUpdate;
@@ -55,7 +55,7 @@ public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, IN
}
component.setMachine(this);
this.componentMap.put(component.getClass(), component);
for (final Class inter : component.getComponentInterfaces()) {
for (final Class<? extends MachineComponent> inter : component.getComponentInterfaces()) {
if (!this.componentInterfaceMap.containsKey(inter)) {
this.componentInterfaceMap.put(inter, new ArrayList<>());
}
@@ -256,7 +256,7 @@ public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, IN
this.owner = owner;
}
public Packet getDescriptionPacket() {
public Packet<?> getDescriptionPacket() {
final NBTTagCompound nbt = new NBTTagCompound();
this.syncToNBT(nbt);
if (nbt.hasNoTags()) {
@@ -35,7 +35,7 @@ public class MachineComponent implements INbtReadable, INbtWritable {
public void onUpdate() {
}
public Class[] getComponentInterfaces() {
public Class<? extends MachineComponent>[] getComponentInterfaces() {
return Binnie.MACHINE.getComponentInterfaces(this.getClass());
}
@@ -14,7 +14,7 @@ import java.util.Map;
import java.util.Set;
public class ManagerMachine extends ManagerBase {
private Map<Class<?>, Class<?>[]> componentInterfaceMap;
private Map<Class<?>, Class<? extends MachineComponent>[]> componentInterfaceMap;
private Map<String, MachineGroup> machineGroups;
private Map<Integer, Class<?>> networkIDToComponent;
private Map<Class<?>, Integer> componentToNetworkID;
@@ -41,6 +41,7 @@ public class ManagerMachine extends ManagerBase {
return (machineGroup == null) ? null : machineGroup.getPackage(name);
}
@SuppressWarnings("unchecked")
private void registerComponentClass(final Class<? extends MachineComponent> component) {
if (this.componentInterfaceMap.containsKey(component)) {
return;
@@ -83,7 +84,7 @@ public class ManagerMachine extends ManagerBase {
BinnieCore.proxy.registerTileEntity(TileEntityMachine.class, "binnie.tile.machine", rendererMachine);
}
public Class<?>[] getComponentInterfaces(final Class<? extends MachineComponent> clss) {
public Class<? extends MachineComponent>[] getComponentInterfaces(final Class<? extends MachineComponent> clss) {
if (!this.componentInterfaceMap.containsKey(clss)) {
this.registerComponentClass(clss);
}
@@ -17,7 +17,7 @@ public @interface ConfigProperty {
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
@interface Type {
Class<? extends PropertyBase> propertyClass();
Class<? extends PropertyBase<?, ?>> propertyClass();
String category() default "general";
}
@@ -39,7 +39,7 @@ public class ManagerConfig extends ManagerBase {
if (annotation.annotationType().isAnnotationPresent(ConfigProperty.Type.class)) {
final Class<?> propertyClass = annotation.annotationType().getAnnotation(ConfigProperty.Type.class).propertyClass();
try {
final PropertyBase property = (PropertyBase) propertyClass.getConstructor(Field.class, BinnieConfiguration.class, ConfigProperty.class, annotation.annotationType()).newInstance(field, config, propertyAnnot, annotation.annotationType().cast(annotation));
final PropertyBase<?, ?> property = (PropertyBase<?, ?>) propertyClass.getConstructor(Field.class, BinnieConfiguration.class, ConfigProperty.class, annotation.annotationType()).newInstance(field, config, propertyAnnot, annotation.annotationType().cast(annotation));
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace();
}
@@ -3,5 +3,5 @@ package binnie.core.network.packet;
import net.minecraft.network.Packet;
public interface IPacket {
Packet getPacket();
Packet<?> getPacket();
}