Fix crash with RenderPlayerAPI installed without SmartRenderer

This commit is contained in:
Leon 2016-12-07 08:47:41 -05:00
parent 8343d60aad
commit f134baa092
23 changed files with 33 additions and 34 deletions

View file

@ -6,7 +6,6 @@ import net.machinemuse.api.moduletrigger.IPlayerTickModule;
import net.machinemuse.api.moduletrigger.IRightClickModule;
import net.machinemuse.api.moduletrigger.IToggleableModule;
import net.machinemuse.numina.item.IModeChangingItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

View file

@ -5,7 +5,6 @@ import ic2.api.item.ElectricItem;
import net.machinemuse.api.ModuleManager;
import net.machinemuse.utils.ElectricItemUtils;
import net.machinemuse.utils.MuseItemUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

View file

@ -2,7 +2,6 @@ package net.machinemuse.api.moduletrigger;
import net.machinemuse.api.IPowerModule;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

View file

@ -12,6 +12,7 @@ import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
/**
* Author: MachineMuse (Claire Semple)
@ -102,7 +103,7 @@ public class PartManipContainer extends ScrollableFrame {
@Override
public void update(double mousex, double mousey) {
super.update(mousex, mousey);
if (lastItemSlot != getItemSlot()) {
if (!Objects.equals(lastItemSlot, getItemSlot())) {
lastItemSlot = getItemSlot();
colourSelect.refreshColours();

View file

@ -3,7 +3,6 @@ package net.machinemuse.powersuits.client.render.item;
import net.machinemuse.numina.general.MuseLogger;
import net.machinemuse.powersuits.common.ModCompatibility;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.nbt.NBTTagCompound;
/**
* Author: MachineMuse (Claire Semple)
* Created: 10:01 PM, 11/07/13
@ -13,7 +12,7 @@ public class ArmorModelInstance {
public static ModelBiped getInstance() {
// TODO: Actual (skinned) vanilla model as low bandwitdth alternative
if (instance == null) {
if ( ModCompatibility.isRenderPlayerAPILoaded()) {
if ( ModCompatibility.isRenderPlayerAPILoaded() && ModCompatibility.isSmartRendererLoaded()) {
try {
MuseLogger.logInfo("Attempting to load SmartMoving armor model.");
instance = Class.forName("net.machinemuse.powersuits.client.render.item.SMovingArmorModel").asSubclass(ModelBiped.class).newInstance();

View file

@ -1,7 +1,6 @@
package net.machinemuse.powersuits.client.render.item;
import api.player.model.ModelPlayer;
import cpw.mods.fml.common.Optional;
import net.machinemuse.powersuits.client.render.modelspec.RenderPart;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

View file

@ -1,9 +1,7 @@
package net.machinemuse.powersuits.common;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModAPIManager;
import cpw.mods.fml.relauncher.Side;
import net.machinemuse.api.ModuleManager;
import net.machinemuse.api.electricity.IModularItem;
import net.machinemuse.numina.general.MuseLogger;
@ -87,6 +85,11 @@ public class ModCompatibility {
return Loader.isModLoaded("RenderPlayerAPI");
}
public static boolean isSmartRendererLoaded() {
return Loader.isModLoaded("SmartRender");
}
public static boolean enableThaumGogglesModule() {
boolean defaultval = isThaumCraftLoaded();
return Config.getConfig().get("Special Modules", "Thaumcraft Goggles Module", defaultval).getBoolean(defaultval);

View file

@ -32,6 +32,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.Objects;
/**
* Ported to Java by lehjr on 10/24/16.
@ -129,7 +130,7 @@ public class ClientTickHandler {
Minecraft mc = Minecraft.getMinecraft();
ScaledResolution screen = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
for (int i = 0; i < modules.size(); i++) {
if (modules.get(i) == AutoFeederModule.MODULE_AUTO_FEEDER) {
if (Objects.equals(modules.get(i), AutoFeederModule.MODULE_AUTO_FEEDER)) {
int foodLevel = (int) MuseItemUtils.getFoodLevel(player.getCurrentArmor(3));
String num = MuseStringUtils.formatNumberShort(foodLevel);
if (i == 0) {
@ -139,7 +140,7 @@ public class ClientTickHandler {
MuseRenderer.drawString(num, 17, yBaseString + (yOffsetString * i));
MuseRenderer.drawItemAt(-1.0, yBaseIcon + (yOffsetIcon * i), food);
}
} else if(modules.get(i) == ClockModule.MODULE_CLOCK) {
} else if(Objects.equals(modules.get(i), ClockModule.MODULE_CLOCK)) {
long time = player.worldObj.provider.getWorldTime();
long hour = ((time % 24000) / 1000);
if (Config.use24hClock()) {
@ -174,13 +175,13 @@ public class ClientTickHandler {
MuseRenderer.drawString(hour + ampm, 17, yBaseString + (yOffsetString * i));
MuseRenderer.drawItemAt(-1.0, yBaseIcon + (yOffsetIcon * i), clock);
}
} else if (modules.get(i) == CompassModule.MODULE_COMPASS) {
} else if (Objects.equals(modules.get(i), CompassModule.MODULE_COMPASS)) {
if (i == 0) {
MuseRenderer.drawItemAt(-1.0, yBaseIcon, compass);
} else {
MuseRenderer.drawItemAt(-1.0, yBaseIcon + (yOffsetIcon * i), compass);
}
} else if (modules.get(i) == WaterTankModule.MODULE_WATER_TANK) {
} else if (Objects.equals(modules.get(i), WaterTankModule.MODULE_WATER_TANK)) {
drawWaterMeter = true;
}
}

View file

@ -22,11 +22,10 @@ import java.util.Set;
* Ported to Java by lehjr on 11/4/16.
*/
public class MPSItemElectricTool extends ItemTool implements IModularItemBase, IMuseElectricItem {
public static final Set<Block> blocksEffectiveOn = Sets.newHashSet(new Block[] {
Blocks.cobblestone, Blocks.double_stone_slab, Blocks.stone_slab, Blocks.stone, Blocks.sandstone, Blocks.mossy_cobblestone,
public static final Set<Block> blocksEffectiveOn = Sets.newHashSet(Blocks.cobblestone, Blocks.double_stone_slab, Blocks.stone_slab, Blocks.stone, Blocks.sandstone, Blocks.mossy_cobblestone,
Blocks.iron_ore, Blocks.iron_block, Blocks.coal_ore, Blocks.gold_block, Blocks.gold_ore, Blocks.diamond_ore,
Blocks.diamond_block, Blocks.ice, Blocks.netherrack, Blocks.lapis_ore, Blocks.lapis_block, Blocks.redstone_ore,
Blocks.lit_redstone_ore, Blocks.rail, Blocks.detector_rail, Blocks.golden_rail, Blocks.activator_rail});
Blocks.lit_redstone_ore, Blocks.rail, Blocks.detector_rail, Blocks.golden_rail, Blocks.activator_rail);
protected MPSItemElectricTool(float damageBonus, ToolMaterial material) {

View file

@ -5,7 +5,6 @@ import net.machinemuse.numina.network.MusePackager;
import net.machinemuse.numina.network.MusePacket;
import net.machinemuse.utils.MuseItemUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

View file

@ -6,7 +6,6 @@ import net.machinemuse.numina.network.MusePackager;
import net.machinemuse.numina.network.MusePacket;
import net.machinemuse.utils.MuseItemUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

View file

@ -6,7 +6,6 @@ import net.machinemuse.general.gui.MuseGui;
import net.machinemuse.numina.network.MusePackager;
import net.machinemuse.numina.network.MusePacket;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;

View file

@ -6,7 +6,6 @@ import net.machinemuse.numina.network.MusePackager;
import net.machinemuse.numina.network.MusePacket;
import net.machinemuse.powersuits.entity.EntityPlasmaBolt;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.entity.player.EntityPlayer;
import java.io.DataInputStream;

View file

@ -5,7 +5,6 @@ import net.machinemuse.numina.network.MusePacket;
import net.machinemuse.numina.network.PacketSender;
import net.machinemuse.powersuits.control.PlayerInputMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import java.io.DataInputStream;

View file

@ -11,7 +11,6 @@ import net.machinemuse.powersuits.powermodule.PowerModuleBase;
import net.machinemuse.powersuits.powermodule.PropertyModifierFlatAdditive;
import net.machinemuse.powersuits.powermodule.PropertyModifierIntLinearAdditive;
import net.machinemuse.powersuits.powermodule.PropertyModifierLinearAdditive;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.entity.player.EntityPlayer;
import java.io.DataInputStream;

View file

@ -4,7 +4,6 @@ import net.machinemuse.numina.network.MusePackager;
import net.machinemuse.numina.network.MusePacket;
import net.machinemuse.utils.MuseItemUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import java.io.DataInputStream;

View file

@ -6,7 +6,6 @@ import net.machinemuse.numina.network.MusePackager;
import net.machinemuse.numina.network.MusePacket;
import net.machinemuse.utils.MuseItemUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

View file

@ -15,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import java.util.List;
import java.util.Objects;
/**
* Created by leon on 10/18/16.
@ -71,7 +72,7 @@ public class SprintAssistModule extends PowerModuleBase implements IToggleableMo
NBTTagList modifiers = item.getTagCompound().getTagList("AttributeModifiers", (byte)10);
for (int i = 0; i< modifiers.tagCount(); i++) {
NBTTagCompound tag = modifiers.getCompoundTagAt(i);
if (new AttributeModifier(tag).name == "Sprint Assist") {
if (Objects.equals(new AttributeModifier(tag).name, "Sprint Assist")) {
tag.setDouble("Amount", 0);
}
}
@ -84,7 +85,7 @@ public class SprintAssistModule extends PowerModuleBase implements IToggleableMo
NBTTagCompound sprintModifiers = new NBTTagCompound();
for (int i = 0; i < modifiers.tagCount(); i++) {
NBTTagCompound tag = modifiers.getCompoundTagAt(i);
if (new AttributeModifier(tag).name == "Sprint Assist") {
if (Objects.equals(new AttributeModifier(tag).name, "Sprint Assist")) {
sprintModifiers = tag;
sprintModifiers.setInteger("Operation", 1);
sprintModifiers.setDouble("Amount", multiplier - 1);

View file

@ -18,6 +18,7 @@ import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import java.util.List;
import java.util.Objects;
public class AxeModule extends PowerModuleBase implements IBlockBreakingModule, IToggleableModule {
@ -81,7 +82,7 @@ public class AxeModule extends PowerModuleBase implements IBlockBreakingModule,
}
}
}
return (effectiveTool == "axe");
return (Objects.equals(effectiveTool, "axe"));
}
@Override

View file

@ -9,13 +9,17 @@ import net.machinemuse.powersuits.powermodule.PropertyModifierIntLinearAdditive;
import net.machinemuse.utils.ElectricItemUtils;
import net.machinemuse.utils.MuseCommonStrings;
import net.machinemuse.utils.MuseItemUtils;
import net.minecraft.block.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockSnow;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.List;
import java.util.Objects;
/**
* Created by User: Andrew2448
@ -82,21 +86,21 @@ public class LeafBlowerModule extends PowerModuleBase implements IRightClickModu
return false;
// Plants
if ((blocktype == "plants") && (block instanceof BlockBush) && block.canHarvestBlock(player, meta)) {
if ((Objects.equals(blocktype, "plants")) && (block instanceof BlockBush) && block.canHarvestBlock(player, meta)) {
block.harvestBlock(world, player, x, y, z, meta);
world.setBlockToAir(x, y, z);
return true;
}
// Leaves
if ((blocktype == "leaves") && block instanceof BlockLeaves && block.canHarvestBlock(player, meta)) {
if ((Objects.equals(blocktype, "leaves")) && block instanceof BlockLeaves && block.canHarvestBlock(player, meta)) {
block.harvestBlock(world, player, x, y, z, meta);
world.setBlockToAir(x, y, z);
return true;
}
// Snow
if ((blocktype == "snow") && block instanceof BlockSnow && block.canHarvestBlock(player, meta)) {
if ((Objects.equals(blocktype, "snow")) && block instanceof BlockSnow && block.canHarvestBlock(player, meta)) {
block.harvestBlock(world, player, x, y, z, meta);
world.setBlockToAir(x, y, z);
}

View file

@ -18,6 +18,7 @@ import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import java.util.List;
import java.util.Objects;
public class PickaxeModule extends PowerModuleBase implements IBlockBreakingModule, IToggleableModule {
@ -83,7 +84,7 @@ public class PickaxeModule extends PowerModuleBase implements IBlockBreakingModu
private static boolean istEffectiveHarvestTool(Block block, int metadata) {
ItemStack emulatedTool = new ItemStack(Items.iron_pickaxe);
String effectiveHarvestTool = block.getHarvestTool(metadata);
if (effectiveHarvestTool == "pickaxe") {
if (Objects.equals(effectiveHarvestTool, "pickaxe")) {
return block.getHarvestLevel(metadata) <= 2; // higher than 2 requires better then iron
}

View file

@ -18,6 +18,7 @@ import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import java.util.List;
import java.util.Objects;
public class ShovelModule extends PowerModuleBase implements IBlockBreakingModule, IToggleableModule {
public static final String MODULE_SHOVEL = "Shovel";
@ -72,7 +73,7 @@ public class ShovelModule extends PowerModuleBase implements IBlockBreakingModul
return true;
}
}
return (effectiveTool == "shovel");
return (Objects.equals(effectiveTool, "shovel"));
}
@Override

View file

@ -291,7 +291,7 @@ public abstract class MuseRenderer {
by = y1 + cy;
bz = z1 + cz;
int index = (int) Math.random() * 50; // FIXME: Math.random() cast to int is always rounded down to 0
int index = (int) (Math.random() * 50); // FIXME: Math.random() cast to int is always rounded down to 0
drawLightningBetweenPointsFast(ax, ay, az, bx, by, bz, index);
}