possible fix for nullpointer in colour packet

This commit is contained in:
MachineMuse 2013-05-08 12:17:29 -06:00
parent e35a7f7efd
commit 4889a7889d
6 changed files with 132 additions and 4 deletions

View file

@ -0,0 +1,24 @@
package net.machinemuse.phasedestabilizer
import net.minecraft.tileentity.TileEntity
/**
* Author: MachineMuse (Claire Semple)
* Created: 11:31 AM, 5/8/13
*/
class BlockEntry(val coords:BlockCoords, val id:Int, val meta:Int=0, var tileEntity:TileEntity=null) {
}
class BlockCoords(x: Int, y: Int, z: Int, val hashSize: Int = 1290) extends Tuple3(x,y,z) {
override val hashCode = _1 * hashSize * hashSize + _2 * hashSize + _3
override def equals(other: Any) = {
other match {
case o: BlockCoords => _1 == o._1 && _2 == o._2 && _3 == o._3
case _ => other == this
}
}
}

View file

@ -0,0 +1,9 @@
package net.machinemuse.phasedestabilizer
/**
* Author: MachineMuse (Claire Semple)
* Created: 5:30 PM, 5/6/13
*/
class EntityMultiBlock {
val innerWorld:InnerWorld = new InnerWorld(null,null,null,null,null,null)
}

View file

@ -0,0 +1,89 @@
package net.machinemuse.phasedestabilizer
import net.minecraft.world.{WorldSettings, WorldProvider, World}
import net.minecraft.entity.Entity
import net.minecraft.world.chunk.IChunkProvider
import net.minecraft.util.Vec3Pool
import net.minecraft.world.biome.BiomeGenBase
import net.minecraft.block.material.Material
import net.minecraft.tileentity.TileEntity
import net.minecraft.world.storage.ISaveHandler
import net.minecraft.profiler.Profiler
import net.minecraft.logging.ILogAgent
import scala.collection.mutable
import net.minecraft.block.Block
import net.minecraftforge.common.ForgeDirection
/**
* Author: MachineMuse (Claire Semple)
* Created: 11:18 AM, 5/8/13
*/
class InnerWorld(saveHandler: ISaveHandler, levelName: String, worldProvider: WorldProvider, settings: WorldSettings, profiler: Profiler, logger: ILogAgent)
extends World(saveHandler, levelName, worldProvider, settings, profiler, logger) {
val blocks: mutable.HashMap[BlockCoords, BlockEntry] = mutable.HashMap.empty
protected def createChunkProvider(): IChunkProvider = null
def getEntityByID(id: Int): Entity = null
override def getBlockId(x: Int, y: Int, z: Int): Int =
blocks.get(new BlockCoords(x, y, z)) match {
case Some(e) => e.id
case None => 0
}
override def getBlockTileEntity(x: Int, y: Int, z: Int): TileEntity =
blocks.get(new BlockCoords(x, y, z)) match {
case Some(e) => e.tileEntity
case None => null
}
override def getLightBrightnessForSkyBlocks(x: Int, y: Int, z:Int, w: Int): Int = 1
override def getBlockMetadata(x: Int, y: Int, z: Int): Int =
blocks.get(new BlockCoords(x, y, z)) match {
case Some(e) => e.meta
case None => 0
}
override def getBrightness(i: Int, j: Int, k: Int, l: Int): Float = 1
override def getLightBrightness(i: Int, j: Int, k: Int): Float = 1
override def getBlockMaterial(i: Int, j: Int, k: Int): Material =
blocks.get(new BlockCoords(i, j, k)) match {
case Some(e) => Block.blocksList(e.id).blockMaterial
case None => Material.air
}
override def isBlockOpaqueCube(i: Int, j: Int, k: Int): Boolean =
blocks.get(new BlockCoords(i, j, k)) match {
case Some(e) => Block.blocksList(e.id).isOpaqueCube
case None => false
}
override def isBlockNormalCube(x: Int, y: Int, z: Int): Boolean =
blocks.get(new BlockCoords(x, y, z)) match {
case Some(e) => Block.blocksList(e.id).isBlockNormalCube(this,x,y,z)
case None => false
}
override def isAirBlock(i: Int, j: Int, k: Int): Boolean =
blocks.get(new BlockCoords(i, j, k)) match {
case Some(e) => Block.blocksList(e.id).isAirBlock(this, i, j, k)
case None => true
}
override def getBiomeGenForCoords(i: Int, j: Int): BiomeGenBase = null
override def getHeight: Int = 256
override def extendedLevelsInChunkCache(): Boolean = false
override def doesBlockHaveSolidTopSurface(i: Int, j: Int, k: Int): Boolean =
blocks.get(new BlockCoords(i, j, k)) match {
case Some(e) => Block.blocksList(e.id).isBlockSolidOnSide(this, i, j, k, ForgeDirection.UP)
case None => false
}
}

View file

@ -1,7 +1,7 @@
package net.machinemuse.powersuits.item
import net.machinemuse.powersuits.common.Config
import net.machinemuse.powersuits.powermodule.misc.{TransparentArmorModule, TintModule}
import net.machinemuse.powersuits.powermodule.misc.{InvisibilityModule, TransparentArmorModule, TintModule}
import net.machinemuse.utils._
import net.minecraft.entity.{Entity, EntityLiving}
import net.minecraft.entity.player.EntityPlayer
@ -37,7 +37,7 @@ abstract class ItemPowerArmor(id: Int, renderIndex: Int, armorType: Int)
def getProperties(player: EntityLiving, armor: ItemStack, source: DamageSource, damage: Double, slot: Int): ISpecialArmor.ArmorProperties = {
val priority: Int = 1
if (source.isFireDamage && !(source == MuseHeatUtils.overheatDamage)) {
return new ISpecialArmor.ArmorProperties(priority, 0.25, (25 * damage).asInstanceOf[Int])
return new ISpecialArmor.ArmorProperties(priority, 0.25, (25 * damage).toInt)
}
val armorDouble = player match {
case player: EntityPlayer => getArmorDouble(player, armor)
@ -68,6 +68,10 @@ abstract class ItemPowerArmor(id: Int, renderIndex: Int, armorType: Int)
model.visible = armorSlot
if (itemstack != null) {
if(entityLiving.isInstanceOf[EntityPlayer]) {
Option(entityLiving.asInstanceOf[EntityPlayer].getCurrentArmor(2)).map(chest=>
if(MuseItemUtils.itemHasActiveModule(chest, InvisibilityModule.MODULE_ACTIVE_CAMOUFLAGE)) return null)
}
if (MuseItemUtils.itemHasActiveModule(itemstack, TransparentArmorModule.MODULE_TRANSPARENT_ARMOR)) {
return null
}

View file

@ -38,8 +38,11 @@ public abstract class MusePacket {
this.player = player;
this.bytes = new ByteArrayOutputStream();
this.dataout = new DataOutputStream(bytes);
try {
int id = MusePacketHandler.getTypeID(this);
writeInt(id);
} catch (NullPointerException e) {
}
}
protected MusePacket(DataInputStream data, Player player) {

View file

@ -89,8 +89,7 @@ public class MusePacketHandler implements IPacketHandler {
*/
public static int getTypeID(MusePacket packet) {
try {
return packetConstructors.inverse().get(
getConstructor(packet.getClass()));
return packetConstructors.inverse().get(getConstructor(packet.getClass()));
} catch (NoSuchMethodException e) {
MuseLogger.logError("INVALID PACKET CONSTRUCTOR D:");
e.printStackTrace();