diff --git a/codechicken/microblock/IHollowConnect.java b/codechicken/microblock/IHollowConnect.scala similarity index 75% rename from codechicken/microblock/IHollowConnect.java rename to codechicken/microblock/IHollowConnect.scala index 835c9d6..9e88a85 100644 --- a/codechicken/microblock/IHollowConnect.java +++ b/codechicken/microblock/IHollowConnect.scala @@ -1,12 +1,12 @@ -package codechicken.microblock; +package codechicken.microblock /** * Implement this on center parts that connect through hollow covers to have the covers render their hollows to fit the connection size */ -public interface IHollowConnect +trait IHollowConnect { /** * @return The size (width and height) of the connection in pixels. Must be be less than 12 and more than 0 */ - public int getSize(); + def getSize:Int } diff --git a/codechicken/multipart/TileMultipart.scala b/codechicken/multipart/TileMultipart.scala index adf349c..cd674de 100644 --- a/codechicken/multipart/TileMultipart.scala +++ b/codechicken/multipart/TileMultipart.scala @@ -22,7 +22,6 @@ import scala.collection.mutable.HashSet import codechicken.multipart.handler.MultipartProxy import net.minecraft.block.Block import net.minecraft.item.ItemStack -import codechicken.core.inventory.InventoryUtils import codechicken.core.vec.Vector3 import net.minecraft.nbt.NBTTagList import net.minecraft.client.particle.EffectRenderer @@ -36,6 +35,7 @@ import scala.collection.mutable.Queue import codechicken.multipart.handler.MultipartSPH import codechicken.core.lighting.LazyLightMatrix import net.minecraft.world.ChunkCoordIntPair +import net.minecraft.entity.item.EntityItem trait TileMultipart extends TileEntity { @@ -278,7 +278,7 @@ trait TileMultipart extends TileEntity def dropItems(items:Seq[ItemStack]) { val pos = Vector3.fromTileEntityCenter(this) - items.foreach(item => InventoryUtils.dropItem(item, worldObj, pos)) + items.foreach(item => TileMultipartObj.dropItem(item, worldObj, pos)) } def markRender() @@ -494,4 +494,13 @@ object TileMultipartObj tmb.loadParts(parts) return tmb } + + def dropItem(stack:ItemStack, world:World, pos:Vector3) + { + val item = new EntityItem(world, pos.x, pos.y, pos.z, stack); + item.motionX = world.rand.nextGaussian() * 0.05; + item.motionY = world.rand.nextGaussian() * 0.05 + 0.2F; + item.motionZ = world.rand.nextGaussian() * 0.05; + world.spawnEntityInWorld(item); + } } diff --git a/codechicken/multipart/handler/Proxies.scala b/codechicken/multipart/handler/Proxies.scala index 584ce50..74066c4 100644 --- a/codechicken/multipart/handler/Proxies.scala +++ b/codechicken/multipart/handler/Proxies.scala @@ -10,7 +10,6 @@ import cpw.mods.fml.common.registry.GameRegistry import java.io.File import codechicken.multipart.handler.MultipartProxy._ import codechicken.multipart.BlockMultipartImpl -import codechicken.core.CommonUtils import codechicken.multipart.MultipartRenderer import java.util.HashMap import net.minecraftforge.common.MinecraftForge @@ -23,6 +22,7 @@ import cpw.mods.fml.client.registry.KeyBindingRegistry import codechicken.multipart.ControlKeyHandler import cpw.mods.fml.common.network.NetworkRegistry import cpw.mods.fml.common.registry.TickRegistry +import net.minecraft.block.Block class MultipartProxy_serverImpl { @@ -38,7 +38,7 @@ class MultipartProxy_serverImpl def postInit() { - block = new BlockMultipartImpl(config.getTag("block.id").getIntValue(CommonUtils.getFreeBlockID(1281))) + block = new BlockMultipartImpl(config.getTag("block.id").getIntValue(getFreeBlockID(1281))) block.setUnlocalizedName("ccmultipart") MinecraftForge.EVENT_BUS.register(MultipartEventHandler) @@ -47,6 +47,14 @@ class MultipartProxy_serverImpl TickRegistry.registerTickHandler(MultipartEventHandler, Side.SERVER) } + def getFreeBlockID(preferred:Int):Int = + { + for(i <- (preferred until 4096) ++ (preferred-1 until 255)) + if(Block.blocksList(i) == null) + return i + throw new RuntimeException("Out of Block IDs") + } + def onTileClassBuilt(t:Class[_ <: TileEntity]) { MultipartSaveLoad.registerTileClass(t) diff --git a/codechicken/multipart/minecraft/EventHandler.java b/codechicken/multipart/minecraft/EventHandler.java index efc867f..70d6c4e 100644 --- a/codechicken/multipart/minecraft/EventHandler.java +++ b/codechicken/multipart/minecraft/EventHandler.java @@ -4,7 +4,6 @@ import codechicken.core.packet.PacketCustom; import codechicken.core.raytracer.RayTracer; import codechicken.core.vec.BlockCoord; import codechicken.core.vec.Vector3; -import codechicken.multipart.TMultiPart; import codechicken.multipart.TileMultipart; import codechicken.multipart.TileMultipartObj; import net.minecraft.block.Block; @@ -34,6 +33,9 @@ public class EventHandler BlockCoord pos = new BlockCoord(hit.blockX, hit.blockY, hit.blockZ).offset(hit.sideHit); ItemStack held = player.getHeldItem(); McBlockPart part = null; + if(held == null) + return false; + if(held.itemID == Block.torchWood.blockID) part = TorchPart.placement(world, pos, hit.sideHit);