Remove redundant casts, unnecessary object creation, and string ==

This commit is contained in:
mezz committed 2016-10-21 00:32:06 -07:00
1 parent 100784b51b
commit a4cd13282a
57 files changed
+180 -156

No files matched your search

+6 -4
View File
@@ -10,6 +10,8 @@ import net.minecraftforge.fml.common.versioning.ArtifactVersion;
import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion;
import net.minecraftforge.fml.common.versioning.Restriction;
import java.util.Objects;
public class Mods {
public static Mod Forestry;
public static Mod IC2;
@@ -18,7 +20,7 @@ public class Mods {
private static Item findItem(final String modId, final String name) {
final Item stack = Item.REGISTRY.getObject(new ResourceLocation(modId, name));
if (stack == null && Mods.WARN && modId == "forestry") {
if (stack == null && Mods.WARN && Objects.equals(modId, "forestry")) {
//throw new RuntimeException("Item not found: " + modId + ":" + name);
}
@@ -27,7 +29,7 @@ public class Mods {
private static ItemStack findItemStack(final String modId, final String name, final int stackSize) {
final ItemStack stack = GameRegistry.makeItemStack(modId + ":" + name, 0, stackSize, null);
if (stack == null && Mods.WARN && modId == "forestry") {
if (stack == null && Mods.WARN && Objects.equals(modId, "forestry")) {
//throw new RuntimeException("Stack not found: " + modId + ":" + name);
}
return stack;
@@ -35,7 +37,7 @@ public class Mods {
private static Block findBlock(final String modId, final String name) {
final Block stack = Block.REGISTRY.getObject(new ResourceLocation(modId + ":" + name));
if (stack == null && Mods.WARN && modId == "forestry") {
if (stack == null && Mods.WARN && Objects.equals(modId, "forestry")) {
//throw new RuntimeException("Block not found: " + modId + ":" + name);
}
return stack;
@@ -46,7 +48,7 @@ public class Mods {
@Override
public boolean dev() {
final String forVersion = Loader.instance().getIndexedModList().get("forestry").getVersion();
final Restriction rest = new Restriction(new DefaultArtifactVersion("3.6"), true, (ArtifactVersion) null, false);
final Restriction rest = new Restriction(new DefaultArtifactVersion("3.6"), true, null, false);
return rest.containsVersion(new DefaultArtifactVersion(forVersion));
}
};
@@ -405,7 +405,7 @@ public abstract class BreedingSystem implements IItemStackRepresentitive {
if (allele instanceof IAlleleBoolean) {
return ((IAlleleBoolean) allele).getValue() ? Binnie.Language.localise(BinnieCore.instance, "allele.true") : Binnie.Language.localise(BinnieCore.instance, "allele.false");
}
if (allele.getName() == "for.gui.maximum") {
if (Objects.equals(allele.getName(), "for.gui.maximum")) {
return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.maximum");
}
return allele.getName();
@@ -20,7 +20,7 @@ class FlowerBreedingSystem extends BreedingSystem {
@Override
public float getChance(final IMutation mutation, final EntityPlayer player, final IAllele species1, final IAllele species2) {
return ((IFlowerMutation) mutation).getBaseChance();
return mutation.getBaseChance();
}
@Override
@@ -29,7 +29,7 @@ public class ModuleItems implements IInitializable {
@Override
public void postInit() {
GameRegistry.addRecipe(new ItemStack(BinnieCore.fieldKit, 1, 63), new Object[]{"g ", " is", " pi", 'g', Blocks.GLASS_PANE, 'i', Items.IRON_INGOT, 'p', Items.PAPER, 's', new ItemStack(Items.DYE, 1)});
GameRegistry.addRecipe(new ItemStack(BinnieCore.fieldKit, 1, 63), "g ", " is", " pi", 'g', Blocks.GLASS_PANE, 'i', Items.IRON_INGOT, 'p', Items.PAPER, 's', new ItemStack(Items.DYE, 1));
}
@SubscribeEvent
@@ -66,7 +66,7 @@ public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, IN
}
public <T extends MachineComponent> T getComponent(final Class<T> componentClass) {
return this.hasComponent(componentClass) ? ((T) componentClass.cast(this.componentMap.get(componentClass))) : null;
return this.hasComponent(componentClass) ? componentClass.cast(this.componentMap.get(componentClass)) : null;
}
@Override
@@ -18,7 +18,7 @@ class ModelBlock extends ModelBase {
}
public void render(final float f, final float f1, final float f2, final float f3, final float f4, final float f5) {
super.render((Entity) null, f, f1, f2, f3, f4, f5);
super.render(null, f, f1, f2, f3, f4, f5);
this.setRotationAngles(f, f1, f2, f3, f4, f5);
this.Block.render(f5);
}
@@ -30,6 +30,6 @@ class ModelBlock extends ModelBase {
}
public void setRotationAngles(final float f, final float f1, final float f2, final float f3, final float f4, final float f5) {
super.setRotationAngles(f, f1, f2, f3, f4, f5, (Entity) null);
super.setRotationAngles(f, f1, f2, f3, f4, f5, null);
}
}
@@ -143,6 +143,6 @@ class ModelCompartment extends ModelBase {
}
public void setRotationAngles(final float f, final float f1, final float f2, final float f3, final float f4, final float f5) {
super.setRotationAngles(f, f1, f2, f3, f4, f5, (Entity) null);
super.setRotationAngles(f, f1, f2, f3, f4, f5, null);
}
}
@@ -25,11 +25,11 @@ public class ModuleStorage implements IInitializable {
final String ironGear = OreDictionary.getOres("gearIron").isEmpty() ? "ingotIron" : "gearIron";
final String goldGear = OreDictionary.getOres("gearGold").isEmpty() ? "ingotGold" : "gearGold";
final String diamondGear = "gemDiamond";
GameRegistry.addRecipe(new ShapedOreRecipe(Compartment.Compartment.get(1), new Object[]{"pcp", "cbc", "pcp", 'b', Items.BOOK, 'c', Blocks.CHEST, 'p', Blocks.STONE_BUTTON}));
GameRegistry.addRecipe(new ShapedOreRecipe(Compartment.CompartmentCopper.get(1), new Object[]{"pcp", "cbc", "pcp", 'b', Compartment.Compartment.get(1), 'c', "gearCopper", 'p', Blocks.STONE_BUTTON}));
GameRegistry.addRecipe(new ShapedOreRecipe(Compartment.CompartmentBronze.get(1), new Object[]{"pcp", "cbc", "pcp", 'b', Compartment.CompartmentCopper.get(1), 'c', "gearBronze", 'p', Items.GOLD_NUGGET}));
GameRegistry.addRecipe(new ShapedOreRecipe(Compartment.CompartmentIron.get(1), new Object[]{"pcp", "cbc", "pcp", 'b', Compartment.CompartmentCopper.get(1), 'c', ironGear, 'p', Items.GOLD_NUGGET}));
GameRegistry.addRecipe(new ShapedOreRecipe(Compartment.CompartmentGold.get(1), new Object[]{"pcp", "cbc", "pcp", 'b', Compartment.CompartmentIron.get(1), 'c', goldGear, 'p', Items.EMERALD}));
GameRegistry.addRecipe(new ShapedOreRecipe(Compartment.CompartmentDiamond.get(1), new Object[]{"pcp", "cbc", "pcp", 'b', Compartment.CompartmentGold.get(1), 'c', diamondGear, 'p', Items.EMERALD}));
GameRegistry.addRecipe(new ShapedOreRecipe(Compartment.Compartment.get(1), "pcp", "cbc", "pcp", 'b', Items.BOOK, 'c', Blocks.CHEST, 'p', Blocks.STONE_BUTTON));
GameRegistry.addRecipe(new ShapedOreRecipe(Compartment.CompartmentCopper.get(1), "pcp", "cbc", "pcp", 'b', Compartment.Compartment.get(1), 'c', "gearCopper", 'p', Blocks.STONE_BUTTON));
GameRegistry.addRecipe(new ShapedOreRecipe(Compartment.CompartmentBronze.get(1), "pcp", "cbc", "pcp", 'b', Compartment.CompartmentCopper.get(1), 'c', "gearBronze", 'p', Items.GOLD_NUGGET));
GameRegistry.addRecipe(new ShapedOreRecipe(Compartment.CompartmentIron.get(1), "pcp", "cbc", "pcp", 'b', Compartment.CompartmentCopper.get(1), 'c', ironGear, 'p', Items.GOLD_NUGGET));
GameRegistry.addRecipe(new ShapedOreRecipe(Compartment.CompartmentGold.get(1), "pcp", "cbc", "pcp", 'b', Compartment.CompartmentIron.get(1), 'c', goldGear, 'p', Items.EMERALD));
GameRegistry.addRecipe(new ShapedOreRecipe(Compartment.CompartmentDiamond.get(1), "pcp", "cbc", "pcp", 'b', Compartment.CompartmentGold.get(1), 'c', diamondGear, 'p', Items.EMERALD));
}
}
@@ -32,7 +32,7 @@ public class BinnieModProxy implements IBinnieModProxy {
@Override
public void sendToPlayer(final MessageBase packet, final EntityPlayer entityplayer) {
if (entityplayer instanceof EntityPlayerMP) {
this.mod.getNetworkWrapper().sendTo((IMessage) packet.GetMessage(), (EntityPlayerMP) entityplayer);
this.mod.getNetworkWrapper().sendTo(packet.GetMessage(), (EntityPlayerMP) entityplayer);
}
}
@@ -91,7 +91,7 @@ public final class BinnieProxyClient extends BinnieProxy implements IBinnieProxy
public boolean checkTexture(final BinnieResource location) {
final SimpleTexture texture = new SimpleTexture(location.getResourceLocation());
try {
((ITextureObject) texture).loadTexture(this.getMinecraftInstance().getResourceManager());
texture.loadTexture(this.getMinecraftInstance().getResourceManager());
} catch (IOException e) {
return false;
}