mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 04:10:07 +00:00
Stop suppressing exceptions that may be important
This commit is contained in:
1 parent
163abc377e
commit
7c048de845
33 files changed
+111
-186
No files matched your search
@@ -149,16 +149,13 @@ public final class BinnieCore extends AbstractMod {
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleSpeciesDiscovered(final ForestryEvent.SpeciesDiscovered event) {
|
||||
try {
|
||||
final EntityPlayerMP player = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUUID(event.username.getId());
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
event.tracker.synchToPlayer(player);
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString("species", event.species.getUID());
|
||||
} catch (Exception ex) {
|
||||
final EntityPlayerMP player = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUUID(event.username.getId());
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
event.tracker.synchToPlayer(player);
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString("species", event.species.getUID());
|
||||
}
|
||||
|
||||
//TODO RENDERING
|
||||
|
||||
@@ -171,18 +171,15 @@ public class ManagerGenetics extends ManagerBase {
|
||||
final TreeSet<IAllele> alleles = new TreeSet<>(new ComparatorAllele());
|
||||
for (final IIndividual individual : root.getIndividualTemplates()) {
|
||||
final IGenome genome = individual.getGenome();
|
||||
try {
|
||||
final IAllele a1 = genome.getActiveAllele(chromosome);
|
||||
final IAllele a2 = genome.getInactiveAllele(chromosome);
|
||||
if (chromosome.getAlleleClass().isInstance(a1)) {
|
||||
alleles.add(a1);
|
||||
}
|
||||
if (!chromosome.getAlleleClass().isInstance(a2)) {
|
||||
continue;
|
||||
}
|
||||
alleles.add(a2);
|
||||
} catch (Exception ex) {
|
||||
final IAllele a1 = genome.getActiveAllele(chromosome);
|
||||
final IAllele a2 = genome.getInactiveAllele(chromosome);
|
||||
if (chromosome.getAlleleClass().isInstance(a1)) {
|
||||
alleles.add(a1);
|
||||
}
|
||||
if (!chromosome.getAlleleClass().isInstance(a2)) {
|
||||
continue;
|
||||
}
|
||||
alleles.add(a2);
|
||||
}
|
||||
system.addExtraAlleles(chromosome, alleles);
|
||||
if (alleles.size() == 0) {
|
||||
|
||||
@@ -16,7 +16,7 @@ public enum BinnieCoreGUI implements IBinnieGUID {
|
||||
FieldKit,
|
||||
Genesis;
|
||||
|
||||
public Window getWindow(final EntityPlayer player, final IInventory object, final Side side) throws Exception {
|
||||
public Window getWindow(final EntityPlayer player, final IInventory object, final Side side) {
|
||||
switch (this) {
|
||||
case Compartment: {
|
||||
return new WindowCompartment(player, object, side);
|
||||
@@ -35,17 +35,12 @@ public enum BinnieCoreGUI implements IBinnieGUID {
|
||||
|
||||
@Override
|
||||
public Window getWindow(final EntityPlayer player, final World world, final int x, final int y, final int z, final Side side) {
|
||||
Window window = null;
|
||||
final TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
|
||||
IInventory object = null;
|
||||
if (tileEntity instanceof IInventory) {
|
||||
object = (IInventory) tileEntity;
|
||||
}
|
||||
try {
|
||||
window = this.getWindow(player, object, side);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return window;
|
||||
|
||||
return this.getWindow(player, object, side);
|
||||
}
|
||||
}
|
||||
@@ -8,16 +8,13 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemMisc extends ItemCore {
|
||||
private IItemMiscProvider[] items;
|
||||
|
||||
public ItemMisc() {
|
||||
super("misc");
|
||||
}
|
||||
|
||||
protected ItemMisc(final CreativeTabs tab, final IItemMiscProvider[] items) {
|
||||
public ItemMisc(final CreativeTabs tab, final IItemMiscProvider[] items) {
|
||||
super("misc");
|
||||
this.setCreativeTab(tab);
|
||||
this.setHasSubtypes(true);
|
||||
@@ -27,14 +24,15 @@ public class ItemMisc extends ItemCore {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, List par3List) {
|
||||
public void getSubItems(@Nonnull final Item itemIn, final CreativeTabs creativeTabs, List<ItemStack> subItems) {
|
||||
for (IItemMiscProvider item : this.items) {
|
||||
if (item.isActive()) {
|
||||
par3List.add(this.getStack(item, 1));
|
||||
subItems.add(this.getStack(item, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private IItemMiscProvider getItem(int damage) {
|
||||
return (damage >= this.items.length) ? this.items[0] : this.items[damage];
|
||||
}
|
||||
@@ -48,9 +46,7 @@ public class ItemMisc extends ItemCore {
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
super.addInformation(stack, playerIn, tooltip, advanced);
|
||||
IItemMiscProvider item = this.getItem(stack.getItemDamage());
|
||||
if (item != null) {
|
||||
item.addInformation(tooltip);
|
||||
}
|
||||
item.addInformation(tooltip);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -59,12 +55,12 @@ public class ItemMisc extends ItemCore {
|
||||
for (IItemMiscProvider type : items) {
|
||||
manager.registerItemModel(item, type.ordinal(), "misc/" + type.getModelPath());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack stack) {
|
||||
public String getItemStackDisplayName(@Nonnull final ItemStack stack) {
|
||||
IItemMiscProvider item = this.getItem(stack.getItemDamage());
|
||||
return (item != null) ? item.getName(stack) : "null";
|
||||
return item.getName(stack);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package binnie.core.item;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
||||
public class ManagerItem {
|
||||
public ItemMisc registerMiscItems(final IItemMiscProvider[] items, final CreativeTabs tab) {
|
||||
return new ItemMisc(tab, items);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import binnie.core.BinnieCore;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@@ -36,7 +37,7 @@ public class MachineGroup {
|
||||
pack.assignMetadata(type.ordinal());
|
||||
pack.setActive(type.isActive());
|
||||
this.addPackage(pack);
|
||||
} catch (Exception e) {
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
throw new RuntimeException("Failed to create machine package " + type.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,9 @@ public class ManagerMachine extends ManagerBase {
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
BinnieCore.proxy.registerTileEntity(TileEntityMachine.class, "binnie.tile.machine", BinnieCore.proxy.createObject("binnie.core.machines.RendererMachine"));
|
||||
// TODO fix rendering
|
||||
Object rendererMachine = null; // BinnieCore.proxy.createObject("binnie.core.machines.RendererMachine");
|
||||
BinnieCore.proxy.registerTileEntity(TileEntityMachine.class, "binnie.tile.machine", rendererMachine);
|
||||
}
|
||||
|
||||
public Class<?>[] getComponentInterfaces(final Class<? extends MachineComponent> clss) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -28,26 +29,26 @@ public class ManagerConfig extends ManagerBase {
|
||||
}
|
||||
|
||||
public void loadConfiguration(final Class<?> cls, final AbstractMod mod) {
|
||||
try {
|
||||
final String filename = cls.getAnnotation(ConfigFile.class).filename();
|
||||
final BinnieConfiguration config = new BinnieConfiguration(filename, mod);
|
||||
config.load();
|
||||
for (final Field field : cls.getFields()) {
|
||||
if (field.isAnnotationPresent(ConfigProperty.class)) {
|
||||
final ConfigProperty propertyAnnot = field.getAnnotation(ConfigProperty.class);
|
||||
for (final Annotation annotation : field.getAnnotations()) {
|
||||
if (annotation.annotationType().isAnnotationPresent(ConfigProperty.Type.class)) {
|
||||
final Class<?> propertyClass = annotation.annotationType().getAnnotation(ConfigProperty.Type.class).propertyClass();
|
||||
final String filename = cls.getAnnotation(ConfigFile.class).filename();
|
||||
final BinnieConfiguration config = new BinnieConfiguration(filename, mod);
|
||||
config.load();
|
||||
for (final Field field : cls.getFields()) {
|
||||
if (field.isAnnotationPresent(ConfigProperty.class)) {
|
||||
final ConfigProperty propertyAnnot = field.getAnnotation(ConfigProperty.class);
|
||||
for (final Annotation annotation : field.getAnnotations()) {
|
||||
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));
|
||||
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
config.save();
|
||||
this.configurations.put(cls, config);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
config.save();
|
||||
this.configurations.put(cls, config);
|
||||
}
|
||||
|
||||
public void addItemID(final Integer configValue, final String configKey, final BinnieConfiguration configFile) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package binnie.core.models;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
@@ -24,6 +23,7 @@ import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -139,7 +139,7 @@ public class ModelManager implements IModelManager {
|
||||
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(String modID, String identifier) {
|
||||
return new ModelResourceLocation(modID + ":" + identifier, "inventory");
|
||||
return new ModelResourceLocation(new ResourceLocation(modID, identifier), "inventory");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -4,6 +4,7 @@ import binnie.Constants;
|
||||
import binnie.core.models.ModelManager;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUIResourceManager;
|
||||
import com.google.common.base.Throwables;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
@@ -162,7 +163,8 @@ public final class BinnieProxyClient extends BinnieProxy implements IBinnieProxy
|
||||
if (rendererClass != null) {
|
||||
object = rendererClass.newInstance();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user