Added refined dust block
This commit is contained in:
parent
b46156c0f1
commit
efdbcc7fb6
9 changed files with 156 additions and 8 deletions
|
@ -12,13 +12,19 @@ import resonantinduction.archaic.firebox.{TileFirebox, TileHotPlate}
|
|||
import resonantinduction.archaic.fluid.grate.TileGrate
|
||||
import resonantinduction.archaic.fluid.gutter.TileGutter
|
||||
import resonantinduction.archaic.fluid.tank.TileTank
|
||||
import resonantinduction.archaic.process.{TileWorkbench, TileCastingMold, TileMillstone}
|
||||
import resonantinduction.archaic.process.{TileCastingMold, TileMillstone, TileWorkbench}
|
||||
import resonantinduction.core.resource.content.TileDust
|
||||
import resonantinduction.core.{RICreativeTab, Reference}
|
||||
import resonantinduction.mechanical.mech.gear.ItemHandCrank
|
||||
;
|
||||
|
||||
object ArchaicContent extends ContentHolder
|
||||
{
|
||||
/**
|
||||
* Resources
|
||||
*/
|
||||
var blockDust: Block = new TileDust
|
||||
|
||||
var itemImprint: Item = new ItemImprint
|
||||
var itemHammer: Item = new ItemHammer
|
||||
var itemHandCrank: Item = new ItemHandCrank
|
||||
|
|
|
@ -179,7 +179,7 @@ class TileGutter extends TileFluidProvider(Material.rock)
|
|||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
val drainAmount = 10 + world.rand.nextInt(20)
|
||||
val drainAmount = 25
|
||||
val drain = fluidNode.drain(ForgeDirection.UP, drainAmount, false)
|
||||
|
||||
if (drain != null && drain.amount > 0 && world.rand.nextFloat < 0.05)
|
||||
|
|
|
@ -5,7 +5,8 @@ import resonantinduction.core.Reference
|
|||
/**
|
||||
* @author Calclavia
|
||||
*/
|
||||
class ItemDust(material : String) extends ItemResource(material)
|
||||
class ItemDust(newMaterial: String) extends ItemResource
|
||||
{
|
||||
setTextureName(Reference.prefix + "oreDust")
|
||||
material = newMaterial
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@ import resonantinduction.core.Reference
|
|||
/**
|
||||
* @author Calclavia
|
||||
*/
|
||||
class ItemMixtureBucket(material: String) extends ItemResource(material) with TBucket
|
||||
class ItemMixtureBucket(newMaterial: String) extends ItemResource with TBucket
|
||||
{
|
||||
setTextureName(Reference.prefix + "bucketMixture")
|
||||
material = newMaterial
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@ import resonantinduction.core.Reference
|
|||
/**
|
||||
* @author Calclavia
|
||||
*/
|
||||
class ItemMoltenBucket(material: String) extends ItemResource(material) with TBucket
|
||||
class ItemMoltenBucket(newMaterial: String) extends ItemResource with TBucket
|
||||
{
|
||||
setTextureName(Reference.prefix + "bucketMolten")
|
||||
material = newMaterial
|
||||
}
|
||||
|
|
|
@ -1,12 +1,115 @@
|
|||
package resonantinduction.core.resource.content
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.init.Blocks
|
||||
import net.minecraft.item.{Item, ItemStack}
|
||||
import net.minecraft.world.World
|
||||
import resonant.lib.transform.vector.Vector3
|
||||
import resonantinduction.archaic.ArchaicContent
|
||||
import resonantinduction.core.Reference
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*/
|
||||
class ItemRefinedDust(material : String) extends ItemResource(material)
|
||||
class ItemRefinedDust(newMaterial: String) extends Item with ItemResource
|
||||
{
|
||||
setTextureName(Reference.prefix + "oreRefinedDust")
|
||||
material = newMaterial
|
||||
|
||||
override def onItemUse(itemStack: ItemStack, player: EntityPlayer, world: World, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float): Boolean =
|
||||
{
|
||||
val block = world.getBlock(x, y, z)
|
||||
|
||||
if (block == getBlock)
|
||||
{
|
||||
val i1: Int = world.getBlockMetadata(x, y, z)
|
||||
val j1: Int = i1 & 7
|
||||
if (j1 <= 6 && world.checkNoEntityCollision(this.getBlock.getCollisionBoundingBoxFromPool(world, x, y, z)) && world.setBlockMetadataWithNotify(x, y, z, j1 + 1 | i1 & -8, 2))
|
||||
{
|
||||
world.playSoundEffect((x.toFloat + 0.5F).toDouble, (y.toFloat + 0.5F).toDouble, (z.toFloat + 0.5F).toDouble, this.getBlock.stepSound.func_150496_b, (this.getBlock.stepSound.getVolume + 1.0F) / 2.0F, this.getBlock.stepSound.getPitch * 0.8F)
|
||||
itemStack.stackSize -= 1
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
var actualSide = side
|
||||
val placeVec = new Vector3(x, y, z)
|
||||
|
||||
if (block == Blocks.snow_layer && (world.getBlockMetadata(x, y, z) & 7) < 1)
|
||||
{
|
||||
actualSide = 1
|
||||
}
|
||||
else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush && !block.isReplaceable(world, x, y, z))
|
||||
{
|
||||
if (actualSide == 0)
|
||||
{
|
||||
placeVec.y -= 1
|
||||
}
|
||||
if (actualSide == 1)
|
||||
{
|
||||
placeVec.y += 1
|
||||
}
|
||||
if (actualSide == 2)
|
||||
{
|
||||
placeVec.z -= 1
|
||||
}
|
||||
if (actualSide == 3)
|
||||
{
|
||||
placeVec.z += 1
|
||||
}
|
||||
if (actualSide == 4)
|
||||
{
|
||||
placeVec.x -= 1
|
||||
}
|
||||
if (actualSide == 5)
|
||||
{
|
||||
placeVec.x += 1
|
||||
}
|
||||
}
|
||||
|
||||
if (itemStack.stackSize == 0)
|
||||
{
|
||||
return false
|
||||
}
|
||||
else if (!player.canPlayerEdit(placeVec.xi, placeVec.yi, placeVec.zi, actualSide, itemStack))
|
||||
{
|
||||
return false
|
||||
}
|
||||
else if (y == 255 && getBlock.getMaterial.isSolid)
|
||||
{
|
||||
return false
|
||||
}
|
||||
else if (world.canPlaceEntityOnSide(this.getBlock, placeVec.xi, placeVec.yi, placeVec.zi, false, actualSide, player, itemStack))
|
||||
{
|
||||
val meta = this.getMetadata(itemStack.getItemDamage)
|
||||
val j1: Int = this.getBlock.onBlockPlaced(world, placeVec.xi, placeVec.yi, placeVec.zi, actualSide, placeVec.xi, placeVec.yi, placeVec.zi, meta)
|
||||
|
||||
if (placeBlockAt(itemStack, player, world, placeVec.xi, placeVec.yi, placeVec.zi, actualSide, placeVec.xi, placeVec.yi, placeVec.zi, j1))
|
||||
{
|
||||
world.playSoundEffect((x.toFloat + 0.5F).toDouble, (y.toFloat + 0.5F).toDouble, (z.toFloat + 0.5F).toDouble, this.getBlock.stepSound.func_150496_b, (this.getBlock.stepSound.getVolume + 1.0F) / 2.0F, this.getBlock.stepSound.getPitch * 0.8F)
|
||||
itemStack.stackSize -= 1
|
||||
}
|
||||
return true
|
||||
}
|
||||
else
|
||||
{
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
def placeBlockAt(stack: ItemStack, player: EntityPlayer, world: World, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float, metadata: Int): Boolean =
|
||||
{
|
||||
if (!world.setBlock(x, y, z, getBlock, metadata, 3))
|
||||
{
|
||||
return false
|
||||
}
|
||||
if (world.getBlock(x, y, z) == getBlock)
|
||||
{
|
||||
getBlock.onBlockPlacedBy(world, x, y, z, player, stack)
|
||||
getBlock.onPostBlockPlaced(world, x, y, z, metadata)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
def getBlock = ArchaicContent.blockDust
|
||||
}
|
||||
|
|
|
@ -7,8 +7,10 @@ import resonantinduction.core.resource.ResourceFactory
|
|||
* A class used by rubble, dusts and refined dusts
|
||||
* @author Calclavia
|
||||
*/
|
||||
abstract class ItemResource(material : String) extends Item
|
||||
trait ItemResource extends Item
|
||||
{
|
||||
var material: String = ""
|
||||
|
||||
override def getColorFromItemStack(p_82790_1_ : ItemStack, p_82790_2_ : Int): Int =
|
||||
{
|
||||
return ResourceFactory.getColor(material)
|
||||
|
|
|
@ -5,7 +5,8 @@ import resonantinduction.core.Reference
|
|||
/**
|
||||
* @author Calclavia
|
||||
*/
|
||||
class ItemRubble(material : String) extends ItemResource(material)
|
||||
class ItemRubble(newMaterial: String) extends ItemResource
|
||||
{
|
||||
setTextureName(Reference.prefix + "oreRubble")
|
||||
material = newMaterial
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package resonantinduction.core.resource.content
|
||||
|
||||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import resonant.lib.prefab.tile.spatial.SpatialTile
|
||||
import resonant.lib.transform.region.Cuboid
|
||||
|
||||
/**
|
||||
* A block for physical dust blocks
|
||||
*
|
||||
* Metadata is used as a value from 0 to 7, indicating the amount of dust that is within this block.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
class TileDust extends SpatialTile(Material.sand)
|
||||
{
|
||||
var resMaterial = ""
|
||||
isOpaqueCube = false
|
||||
|
||||
override def bounds: Cuboid = new Cuboid(0, 0, 0, 1, (metadata + 1) / 8f, 1)
|
||||
|
||||
override def readFromNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(nbt)
|
||||
resMaterial = nbt.getString("material")
|
||||
}
|
||||
|
||||
override def writeToNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(nbt)
|
||||
nbt.setString("material", resMaterial)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue