more porting. Still haven't broken anything yet.

This commit is contained in:
Leon 2016-10-23 15:17:24 -04:00
parent bd887f87dd
commit ffcf71939d
14 changed files with 111 additions and 87 deletions

View file

@ -7,6 +7,7 @@ import net.machinemuse.numina.general.MuseLogger;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nullable;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
@ -53,6 +54,7 @@ public class NBTTagAccessor extends NBTTagCompound {
}
}
@Nullable
public static Map getMap(NBTTagCompound nbt) {
try {
return (Map) getTagAccessor().invoke(nbt, nbt);

View file

@ -71,7 +71,7 @@ public class ToolRenderer extends MuseRender implements IItemRenderer {
break;
case INVENTORY:
RenderBlocks renderInventory = (RenderBlocks) data[0];
MuseIconUtils.drawIconAt(0, 0, MPSItems.powerTool().getIconIndex(itemStack), colour);
MuseIconUtils.drawIconAt(0, 0, MPSItems.INSTANCE.powerTool.getIconIndex(itemStack), colour);
break;
case EQUIPPED:
RenderBlocks renderEquipped = (RenderBlocks) data[0];

View file

@ -0,0 +1,45 @@
package net.machinemuse.powersuits.common;
import cpw.mods.fml.common.registry.GameRegistry;
import net.machinemuse.powersuits.block.BlockLuxCapacitor;
import net.machinemuse.powersuits.block.BlockTinkerTable;
import net.machinemuse.powersuits.item.*;
/**
* Created by Claire Semple on 9/9/2014.
*
* Ported to Java by lehjr on 10/22/16.
*/
public final class MPSItems {
public final ItemPowerArmorHelmet powerArmorHead;
public final ItemPowerArmorChestplate powerArmorTorso;
public final ItemPowerArmorLeggings powerArmorLegs;
public final ItemPowerArmorBoots powerArmorFeet;
public final ItemPowerFist powerTool;
public final BlockTinkerTable tinkerTable;
public final BlockLuxCapacitor luxCapacitor;
public final ItemComponent components;
public static MPSItems INSTANCE = new MPSItems();
private MPSItems() {
this.powerArmorHead = new ItemPowerArmorHelmet();
GameRegistry.registerItem(this.powerArmorHead, this.powerArmorHead.getUnlocalizedName());
this.powerArmorTorso = new ItemPowerArmorChestplate();
GameRegistry.registerItem(this.powerArmorTorso, this.powerArmorTorso.getUnlocalizedName());
this.powerArmorLegs = new ItemPowerArmorLeggings();
GameRegistry.registerItem(this.powerArmorLegs, this.powerArmorLegs.getUnlocalizedName());
this.powerArmorFeet = new ItemPowerArmorBoots();
GameRegistry.registerItem(this.powerArmorFeet, this.powerArmorFeet.getUnlocalizedName());
this.powerTool = new ItemPowerFist();
GameRegistry.registerItem(this.powerTool, this.powerTool.getUnlocalizedName());
this.tinkerTable = new BlockTinkerTable();
GameRegistry.registerBlock(this.tinkerTable, this.tinkerTable.getUnlocalizedName());
this.luxCapacitor = new BlockLuxCapacitor();
GameRegistry.registerBlock(this.luxCapacitor, this.luxCapacitor.getUnlocalizedName());
this.components = new ItemComponent();
this.components.setUnlocalizedName("powerArmorComponent");
GameRegistry.registerItem(this.components, "powerArmorComponent");
this.components.populate();
}
}

View file

@ -111,37 +111,37 @@ public class ModCompatibility {
// CoFH Lib - CoFHLib is included in CoFHCore
if (isCOFHLibLoaded()|| isCOFHCoreLoaded()) {
ModuleManager.addModule(new OmniWrenchModule(Collections.singletonList((IModularItem) MPSItems.powerTool())));
ModuleManager.addModule(new OmniWrenchModule(Collections.singletonList((IModularItem) MPSItems.INSTANCE.powerTool)));
}
// Thaumcraft
if (isThaumCraftLoaded() && enableThaumGogglesModule()) {
ModuleManager.addModule(new ThaumGogglesModule(Collections.singletonList((IModularItem) MPSItems.powerArmorHead())));
ModuleManager.addModule(new ThaumGogglesModule(Collections.singletonList((IModularItem) MPSItems.INSTANCE.powerArmorHead)));
}
//IPowerModule module = new MultimeterModule(Collections.singletonList((IModularItem) MPSItems.powerTool()));
// Hazmat
if (isIndustrialCraftLoaded()) {
ModuleManager.addModule(new HazmatModule(Arrays.<IModularItem>asList(MPSItems.powerArmorHead(), MPSItems.powerArmorTorso(), MPSItems.powerArmorLegs(), MPSItems.powerArmorFeet())));
ModuleManager.addModule(new HazmatModule(Arrays.<IModularItem>asList(MPSItems.INSTANCE.powerArmorHead, MPSItems.INSTANCE.powerArmorTorso, MPSItems.INSTANCE.powerArmorLegs, MPSItems.INSTANCE.powerArmorFeet)));
}
// Galacticraft
if (isGalacticraftLoaded()) {
ModuleManager.addModule(new AirtightSealModule(Collections.singletonList((IModularItem) MPSItems.powerArmorHead())));
ModuleManager.addModule(new AirtightSealModule(Collections.singletonList((IModularItem) MPSItems.INSTANCE.powerArmorHead)));
}
// Forestry
if (isForestryLoaded()) {
ModuleManager.addModule(new GrafterModule(Collections.singletonList((IModularItem) MPSItems.powerTool())));
ModuleManager.addModule(new ScoopModule(Collections.singletonList((IModularItem) MPSItems.powerTool())));
ModuleManager.addModule(new ApiaristArmorModule(Arrays.<IModularItem>asList(MPSItems.powerArmorHead(), MPSItems.powerArmorTorso(), MPSItems.powerArmorLegs(), MPSItems.powerArmorFeet())));
ModuleManager.addModule(new GrafterModule(Collections.singletonList((IModularItem) MPSItems.INSTANCE.powerTool)));
ModuleManager.addModule(new ScoopModule(Collections.singletonList((IModularItem) MPSItems.INSTANCE.powerTool)));
ModuleManager.addModule(new ApiaristArmorModule(Arrays.<IModularItem>asList(MPSItems.INSTANCE.powerArmorHead, MPSItems.INSTANCE.powerArmorTorso, MPSItems.INSTANCE.powerArmorLegs, MPSItems.INSTANCE.powerArmorFeet)));
}
// Chisel
if(isChiselLoaded()) {
try {
ModuleManager.addModule(new ChiselModule(Collections.singletonList((IModularItem) MPSItems.powerTool())));
ModuleManager.addModule(new ChiselModule(Collections.singletonList((IModularItem) MPSItems.INSTANCE.powerTool)));
} catch(Exception e) {
MuseLogger.logException("Couldn't add Chisel module", e);
}
@ -149,21 +149,21 @@ public class ModCompatibility {
// Applied Energistics
if (isAppengLoaded()) {
ModuleManager.addModule(new AppEngWirelessModule(Collections.singletonList((IModularItem) MPSItems.powerTool())));
ModuleManager.addModule(new AppEngWirelessModule(Collections.singletonList((IModularItem) MPSItems.INSTANCE.powerTool)));
// Extra Cells 2
if (isExtraCellsLoaded())
ModuleManager.addModule(new AppEngWirelessFluidModule(Collections.singletonList((IModularItem) MPSItems.powerTool())));
ModuleManager.addModule(new AppEngWirelessFluidModule(Collections.singletonList((IModularItem) MPSItems.INSTANCE.powerTool)));
}
// Multi-Mod Compatible OmniProbe
if (isEnderIOLoaded() || isMFRLoaded() || isRailcraftLoaded()) {
ModuleManager.addModule(new OmniProbeModule(Collections.singletonList((IModularItem) MPSItems.powerTool())));
ModuleManager.addModule(new OmniProbeModule(Collections.singletonList((IModularItem) MPSItems.INSTANCE.powerTool)));
}
// Compact Machines Personal Shrinking Device
if (isCompactMachinesLoaded()) {
ModuleManager.addModule(new PersonalShrinkingModule(Collections.singletonList((IModularItem) MPSItems.powerTool())));
ModuleManager.addModule(new PersonalShrinkingModule(Collections.singletonList((IModularItem) MPSItems.INSTANCE.powerTool)));
}
}
}

View file

@ -75,7 +75,7 @@ public class EntityLuxCapacitor extends EntityThrowable {
if (block == null || block.isAir(worldObj, x, y, z)) {
Block blockToStickTo = worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
if (blockToStickTo.isNormalCube(worldObj, x, y, z)) {
worldObj.setBlock(x, y, z, MPSItems.luxCapacitor(), 0, 7);
worldObj.setBlock(x, y, z, MPSItems.INSTANCE.luxCapacitor, 0, 7);
worldObj.setTileEntity(x, y, z, new TileEntityLuxCapacitor(dir, red, green, blue));
} else {
for (ForgeDirection d : ForgeDirection.values()) {
@ -84,7 +84,7 @@ public class EntityLuxCapacitor extends EntityThrowable {
int zo = z + d.offsetZ;
blockToStickTo = worldObj.getBlock(xo, yo, zo);
if (blockToStickTo.isNormalCube(worldObj, x, y, z)) {
worldObj.setBlock(x, y, z, MPSItems.luxCapacitor(), 0, 7);
worldObj.setBlock(x, y, z, MPSItems.INSTANCE.luxCapacitor, 0, 7);
worldObj.setTileEntity(x, y, z, new TileEntityLuxCapacitor(d, red, green, blue));
}
}

View file

@ -552,7 +552,7 @@ public class MuseItemUtils {
public static void setFluidTermTag(ItemStack stack, NBTTagCompound tag) {
NBTTagCompound t = MuseItemUtils.getMuseItemTag(stack);
t.setTag("AppEng EC Wireless Fluid Terminal", tag);
stack.stackTagCompound.setTag(MuseItemTag.NBTPREFIX(), t);
stack.stackTagCompound.setTag(MuseItemTag.NBTPREFIX, t);
}
public static boolean getCanShrink(ItemStack stack) {

View file

@ -0,0 +1,36 @@
package net.machinemuse.api;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nullable;
/**
* Author: MachineMuse (Claire Semple)
* Created: 6:58 PM, 8/6/13
*
* Ported to Java by lehjr on 10/22/16.
*/
public class MuseItemTag {
public static final String NBTPREFIX = "mmmpsmod";
/**
* Gets or creates stack.getTagCompound().getTag(NBTPREFIX)
*
* @param stack
* @return an NBTTagCompound, may be newly created. If stack is null,
* returns null.
*/
@Nullable
public static NBTTagCompound getMuseItemTag(ItemStack stack) {
if (stack == null) {
return null;
}
NBTTagCompound stackTag = (stack.hasTagCompound()) ? stack.getTagCompound() : new NBTTagCompound();
stack.setTagCompound(stackTag);
NBTTagCompound properties = (stackTag.hasKey(NBTPREFIX)) ? stackTag.getCompoundTag(NBTPREFIX) : new NBTTagCompound();
stackTag.setTag(NBTPREFIX, properties);
return properties;
}
}

View file

@ -1,31 +0,0 @@
package net.machinemuse.api
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
/**
* Author: MachineMuse (Claire Semple)
* Created: 6:58 PM, 8/6/13
*/
object MuseItemTag {
final val NBTPREFIX: String = "mmmpsmod"
/**
* Gets or creates stack.getTagCompound().getTag(NBTPREFIX)
*
* @param stack
* @return an NBTTagCompound, may be newly created. If stack is null,
* returns null.
*/
def getMuseItemTag(stack: ItemStack): NBTTagCompound = {
if (stack == null) {
return null
}
val stackTag: NBTTagCompound = if (stack.hasTagCompound) stack.getTagCompound else new NBTTagCompound
stack.setTagCompound(stackTag)
val properties: NBTTagCompound = if (stackTag.hasKey(NBTPREFIX)) stackTag.getCompoundTag(NBTPREFIX) else new NBTTagCompound
stackTag.setTag(NBTPREFIX, properties)
properties
}
}

View file

@ -51,6 +51,7 @@ object DefaultModelSpec {
ModelRegistry.loadModel(file) match {
case Some(m) => Some(ModelRegistry.put(MuseStringUtils.extractName(file), new ModelSpec(m, textures, None, None, file.toString)))
case None => MuseLogger.logError("Model file " + file + " not found! D:")
None
}
}

View file

@ -26,6 +26,7 @@ object ModelRegistry extends MuseRegistry[ModelSpec] {
AdvancedModelLoader.loadModel(resource) match {
case m: WavefrontObject => Some(m)
case _ => MuseLogger.logError("Model loading failed :( " + resource)
None
}
}

View file

@ -8,7 +8,6 @@ import net.machinemuse.general.sound.SoundDictionary
import net.machinemuse.numina.network.{MusePacket, MusePacketHandler, MusePacketModeChangeRequest, PacketSender}
import net.machinemuse.numina.render.RenderGameOverlayEventHandler
import net.machinemuse.powersuits.block.{BlockTinkerTable, TileEntityLuxCapacitor, TileEntityTinkerTable}
import net.machinemuse.powersuits.client.render.TinkerTableRenderer
import net.machinemuse.powersuits.client.render.block.{RenderLuxCapacitorTESR, TinkerTableRenderer}
import net.machinemuse.powersuits.client.render.entity.{RenderLuxCapacitorEntity, RenderPlasmaBolt, RenderSpinningBlade}
import net.machinemuse.powersuits.client.render.item.ToolRenderer
@ -50,7 +49,7 @@ class ClientProxy extends CommonProxy {
* Register all the custom renderers for this mod.
*/
override def registerRenderers {
MinecraftForgeClient.registerItemRenderer(MPSItems.powerTool, new ToolRenderer)
MinecraftForgeClient.registerItemRenderer(MPSItems.INSTANCE.powerTool, new ToolRenderer)
val tinkTableRenderID: Int = RenderingRegistry.getNextAvailableRenderId
val tinkTableRenderer: TinkerTableRenderer = new TinkerTableRenderer(tinkTableRenderID)
BlockTinkerTable.setRenderType(tinkTableRenderID)
@ -58,7 +57,7 @@ class ClientProxy extends CommonProxy {
RenderingRegistry.registerBlockHandler(tinkTableRenderer)
val luxCapacitorRenderID: Int = RenderingRegistry.getNextAvailableRenderId
val luxCapacitorRenderer: RenderLuxCapacitorTESR = new RenderLuxCapacitorTESR(luxCapacitorRenderID)
MPSItems.luxCapacitor.setRenderType(luxCapacitorRenderID)
MPSItems.INSTANCE.luxCapacitor.setRenderType(luxCapacitorRenderID)
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileEntityLuxCapacitor], luxCapacitorRenderer)
RenderingRegistry.registerBlockHandler(luxCapacitorRenderer)
RenderingRegistry.registerEntityRenderingHandler(classOf[EntityPlasmaBolt], new RenderPlasmaBolt)

View file

@ -176,13 +176,13 @@ object Config {
* they are hardcoded.
*/
def loadPowerModules() {
val ARMORONLY: List[IModularItem] = Arrays.asList[IModularItem](MPSItems.powerArmorHead.asInstanceOf[IModularItem], MPSItems.powerArmorTorso.asInstanceOf[IModularItem], MPSItems.powerArmorLegs.asInstanceOf[IModularItem], MPSItems.powerArmorFeet.asInstanceOf[IModularItem])
val ALLITEMS: List[IModularItem] = Arrays.asList(MPSItems.powerArmorHead.asInstanceOf[IModularItem], MPSItems.powerArmorTorso.asInstanceOf[IModularItem], MPSItems.powerArmorLegs.asInstanceOf[IModularItem], MPSItems.powerArmorFeet.asInstanceOf[IModularItem], MPSItems.powerTool.asInstanceOf[IModularItem])
val HEADONLY: List[IModularItem] = Collections.singletonList(MPSItems.powerArmorHead.asInstanceOf[IModularItem])
val TORSOONLY: List[IModularItem] = Collections.singletonList(MPSItems.powerArmorTorso.asInstanceOf[IModularItem])
val LEGSONLY: List[IModularItem] = Collections.singletonList(MPSItems.powerArmorLegs.asInstanceOf[IModularItem])
val FEETONLY: List[IModularItem] = Collections.singletonList(MPSItems.powerArmorFeet.asInstanceOf[IModularItem])
val TOOLONLY: List[IModularItem] = Collections.singletonList(MPSItems.powerTool.asInstanceOf[IModularItem])
val ARMORONLY: List[IModularItem] = Arrays.asList[IModularItem](MPSItems.INSTANCE.powerArmorHead.asInstanceOf[IModularItem], MPSItems.INSTANCE.powerArmorTorso.asInstanceOf[IModularItem], MPSItems.INSTANCE.powerArmorLegs.asInstanceOf[IModularItem], MPSItems.INSTANCE.powerArmorFeet.asInstanceOf[IModularItem])
val ALLITEMS: List[IModularItem] = Arrays.asList(MPSItems.INSTANCE.powerArmorHead.asInstanceOf[IModularItem], MPSItems.INSTANCE.powerArmorTorso.asInstanceOf[IModularItem], MPSItems.INSTANCE.powerArmorLegs.asInstanceOf[IModularItem], MPSItems.INSTANCE.powerArmorFeet.asInstanceOf[IModularItem], MPSItems.INSTANCE.powerTool.asInstanceOf[IModularItem])
val HEADONLY: List[IModularItem] = Collections.singletonList(MPSItems.INSTANCE.powerArmorHead.asInstanceOf[IModularItem])
val TORSOONLY: List[IModularItem] = Collections.singletonList(MPSItems.INSTANCE.powerArmorTorso.asInstanceOf[IModularItem])
val LEGSONLY: List[IModularItem] = Collections.singletonList(MPSItems.INSTANCE.powerArmorLegs.asInstanceOf[IModularItem])
val FEETONLY: List[IModularItem] = Collections.singletonList(MPSItems.INSTANCE.powerArmorFeet.asInstanceOf[IModularItem])
val TOOLONLY: List[IModularItem] = Collections.singletonList(MPSItems.INSTANCE.powerTool.asInstanceOf[IModularItem])
addModule(new BasicPlatingModule(ARMORONLY))
addModule(new DiamondPlatingModule(ARMORONLY))
addModule(new EnergyShieldModule(ARMORONLY))

View file

@ -3,5 +3,5 @@ package net.machinemuse.powersuits.common
import net.minecraft.creativetab.CreativeTabs
object MPSCreativeTab extends CreativeTabs(CreativeTabs.getNextID, "powersuits") {
def getTabIconItem = MPSItems.powerArmorHead
def getTabIconItem = MPSItems.INSTANCE.powerArmorHead
}

View file

@ -1,29 +0,0 @@
package net.machinemuse.powersuits.common
import cpw.mods.fml.common.registry.GameRegistry
import net.machinemuse.powersuits.block.{BlockLuxCapacitor, BlockTinkerTable}
import net.machinemuse.powersuits.item._
/**
* Created by Claire Semple on 9/9/2014.
*/
object MPSItems {
val powerArmorHead = new ItemPowerArmorHelmet
GameRegistry.registerItem(powerArmorHead, powerArmorHead.getUnlocalizedName)
val powerArmorTorso = new ItemPowerArmorChestplate
GameRegistry.registerItem(powerArmorTorso, powerArmorTorso.getUnlocalizedName)
val powerArmorLegs = new ItemPowerArmorLeggings
GameRegistry.registerItem(powerArmorLegs, powerArmorLegs.getUnlocalizedName)
val powerArmorFeet = new ItemPowerArmorBoots
GameRegistry.registerItem(powerArmorFeet, powerArmorFeet.getUnlocalizedName)
val powerTool = new ItemPowerFist
GameRegistry.registerItem(powerTool, powerTool.getUnlocalizedName)
val tinkerTable = new BlockTinkerTable
GameRegistry.registerBlock(tinkerTable, tinkerTable.getUnlocalizedName)
val luxCapacitor = new BlockLuxCapacitor
GameRegistry.registerBlock(luxCapacitor, luxCapacitor.getUnlocalizedName)
val components = new ItemComponent()
components.setUnlocalizedName("powerArmorComponent")
GameRegistry.registerItem(components, "powerArmorComponent")
components.populate()
}