Moved everything to scala folder
This commit is contained in:
parent
30e1b0c1bb
commit
90a85e7dcb
|
@ -1,127 +0,0 @@
|
||||||
package resonantinduction.archaic.blocks;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
import calclavia.lib.prefab.block.BlockRotatable;
|
|
||||||
import calclavia.lib.prefab.block.IRotatableBlock;
|
|
||||||
import calclavia.lib.prefab.tile.IRotatable;
|
|
||||||
import codechicken.multipart.TileMultipart;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
public class BlockTurntable extends BlockRotatable
|
|
||||||
{
|
|
||||||
private Icon top;
|
|
||||||
|
|
||||||
public BlockTurntable(int id)
|
|
||||||
{
|
|
||||||
super(id, Material.piston);
|
|
||||||
setTextureName(Reference.PREFIX + "turntable_side");
|
|
||||||
setTickRandomly(true);
|
|
||||||
rotationMask = Byte.parseByte("111111", 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int tickRate(World par1World)
|
|
||||||
{
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IconRegister iconReg)
|
|
||||||
{
|
|
||||||
super.registerIcons(iconReg);
|
|
||||||
this.top = iconReg.registerIcon(Reference.PREFIX + "turntable");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateTick(World world, int x, int y, int z, Random par5Random)
|
|
||||||
{
|
|
||||||
this.updateTurntableState(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int side)
|
|
||||||
{
|
|
||||||
int meta = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
|
||||||
|
|
||||||
if (side == meta)
|
|
||||||
{
|
|
||||||
return this.top;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.blockIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon getIcon(int side, int meta)
|
|
||||||
{
|
|
||||||
if (side == 1)
|
|
||||||
{
|
|
||||||
return this.top;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.blockIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNeighborBlockChange(World world, int x, int y, int z, int side)
|
|
||||||
{
|
|
||||||
world.scheduleBlockUpdate(x, y, z, this.blockID, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateTurntableState(World world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
if (world.isBlockIndirectlyGettingPowered(x, y, z))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ForgeDirection facing = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
|
|
||||||
|
|
||||||
Vector3 position = new Vector3(x, y, z).translate(facing);
|
|
||||||
TileEntity tileEntity = position.getTileEntity(world);
|
|
||||||
Block block = Block.blocksList[position.getBlockID(world)];
|
|
||||||
|
|
||||||
if (!(tileEntity instanceof TileMultipart))
|
|
||||||
{
|
|
||||||
if (tileEntity instanceof IRotatable)
|
|
||||||
{
|
|
||||||
ForgeDirection blockRotation = ((IRotatable) tileEntity).getDirection();
|
|
||||||
((IRotatable) tileEntity).setDirection(blockRotation.getRotation(facing.getOpposite()));
|
|
||||||
}
|
|
||||||
else if (block instanceof IRotatableBlock)
|
|
||||||
{
|
|
||||||
ForgeDirection blockRotation = ((IRotatableBlock) block).getDirection(world, position.intX(), position.intY(), position.intZ());
|
|
||||||
((IRotatableBlock) block).setDirection(world, position.intX(), position.intY(), position.intZ(), blockRotation.getRotation(facing.getOpposite()));
|
|
||||||
}
|
|
||||||
else if (block != null)
|
|
||||||
{
|
|
||||||
Block.blocksList[blockID].rotateBlock(world, position.intX(), position.intY(), position.intZ(), facing.getOpposite());
|
|
||||||
}
|
|
||||||
|
|
||||||
world.markBlockForUpdate(position.intX(), position.intY(), position.intZ());
|
|
||||||
world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "tile.piston.in", 0.5F, world.rand.nextFloat() * 0.15F + 0.6F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
System.out.println("Error while rotating a block near " + x + "x " + y + "y " + z + "z " + (world != null && world.provider != null ? world.provider.dimensionId + "d" : "null:world"));
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -4,7 +4,6 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||||
import resonantinduction.archaic.blocks.BlockTurntable;
|
|
||||||
import resonantinduction.archaic.crate.BlockCrate;
|
import resonantinduction.archaic.crate.BlockCrate;
|
||||||
import resonantinduction.archaic.crate.ItemBlockCrate;
|
import resonantinduction.archaic.crate.ItemBlockCrate;
|
||||||
import resonantinduction.archaic.crate.TileCrate;
|
import resonantinduction.archaic.crate.TileCrate;
|
||||||
|
@ -99,7 +98,7 @@ public class Archaic
|
||||||
blockEngineeringTable = contentRegistry.newBlock(TileEngineeringTable.class);
|
blockEngineeringTable = contentRegistry.newBlock(TileEngineeringTable.class);
|
||||||
blockCrate = contentRegistry.createBlock(BlockCrate.class, ItemBlockCrate.class, TileCrate.class);
|
blockCrate = contentRegistry.createBlock(BlockCrate.class, ItemBlockCrate.class, TileCrate.class);
|
||||||
blockImprinter = contentRegistry.createTile(BlockImprinter.class, TileImprinter.class);
|
blockImprinter = contentRegistry.createTile(BlockImprinter.class, TileImprinter.class);
|
||||||
blockTurntable = contentRegistry.createBlock(BlockTurntable.class);
|
blockTurntable = contentRegistry.createBlock(TileTurntable.class);
|
||||||
blockFirebox = contentRegistry.createBlock(BlockFirebox.class, ItemBlockMetadata.class, TileFirebox.class);
|
blockFirebox = contentRegistry.createBlock(BlockFirebox.class, ItemBlockMetadata.class, TileFirebox.class);
|
||||||
blockHotPlate = contentRegistry.createTile(BlockHotPlate.class, TileHotPlate.class);
|
blockHotPlate = contentRegistry.createTile(BlockHotPlate.class, TileHotPlate.class);
|
||||||
blockMillstone = contentRegistry.createTile(BlockMillstone.class, TileMillstone.class);
|
blockMillstone = contentRegistry.createTile(BlockMillstone.class, TileMillstone.class);
|
|
@ -0,0 +1,111 @@
|
||||||
|
package resonantinduction.archaic.blocks
|
||||||
|
|
||||||
|
import java.util.Random
|
||||||
|
import net.minecraft.block.Block
|
||||||
|
import net.minecraft.block.material.Material
|
||||||
|
import net.minecraft.client.renderer.texture.IconRegister
|
||||||
|
import net.minecraft.tileentity.TileEntity
|
||||||
|
import net.minecraft.util.Icon
|
||||||
|
import net.minecraft.world.IBlockAccess
|
||||||
|
import net.minecraft.world.World
|
||||||
|
import net.minecraftforge.common.ForgeDirection
|
||||||
|
import resonantinduction.core.Reference
|
||||||
|
import universalelectricity.api.vector.Vector3
|
||||||
|
import calclavia.lib.prefab.block.BlockRotatable
|
||||||
|
import calclavia.lib.prefab.block.IRotatableBlock
|
||||||
|
import calclavia.lib.prefab.tile.IRotatable
|
||||||
|
import codechicken.multipart.TileMultipart
|
||||||
|
import cpw.mods.fml.relauncher.Side
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly
|
||||||
|
import calclavia.lib.content.prefab.TraitRotatable
|
||||||
|
import calclavia.lib.content.module.TileBlock
|
||||||
|
|
||||||
|
class TileTurntable extends TileBlock(Material.piston) with TraitRotatable
|
||||||
|
{
|
||||||
|
textureName= "turntable_side"
|
||||||
|
tickRandomly = true
|
||||||
|
rotationMask = Byte.parseByte("111111", 2)
|
||||||
|
|
||||||
|
override def tickRate(par1World: World): Int =
|
||||||
|
{
|
||||||
|
return 5
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT) override def registerIcons(iconReg: IconRegister)
|
||||||
|
{
|
||||||
|
super.registerIcons(iconReg)
|
||||||
|
this.top = iconReg.registerIcon(Reference.PREFIX + "turntable")
|
||||||
|
}
|
||||||
|
|
||||||
|
override def updateTick(world: World, x: Int, y: Int, z: Int, par5Random: Random)
|
||||||
|
{
|
||||||
|
this.updateTurntableState(world, x, y, z)
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT) override def getBlockTexture(par1IBlockAccess: IBlockAccess, par2: Int, par3: Int, par4: Int, side: Int): Icon =
|
||||||
|
{
|
||||||
|
val meta: Int = par1IBlockAccess.getBlockMetadata(par2, par3, par4)
|
||||||
|
if (side == meta)
|
||||||
|
{
|
||||||
|
return this.top
|
||||||
|
}
|
||||||
|
return this.blockIcon
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT) override def getIcon(side: Int, meta: Int): Icon =
|
||||||
|
{
|
||||||
|
if (side == 1)
|
||||||
|
{
|
||||||
|
return this.top
|
||||||
|
}
|
||||||
|
return this.blockIcon
|
||||||
|
}
|
||||||
|
|
||||||
|
override def onNeighborBlockChange(world: World, x: Int, y: Int, z: Int, side: Int)
|
||||||
|
{
|
||||||
|
world.scheduleBlockUpdate(x, y, z, this.blockID, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
private def updateTurntableState(world: World, x: Int, y: Int, z: Int)
|
||||||
|
{
|
||||||
|
if (world.isBlockIndirectlyGettingPowered(x, y, z))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
val facing: ForgeDirection = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z))
|
||||||
|
val position: Vector3 = new Vector3(x, y, z).translate(facing)
|
||||||
|
val tileEntity: TileEntity = position.getTileEntity(world)
|
||||||
|
val block: Block = Block.blocksList(position.getBlockID(world))
|
||||||
|
if (!(tileEntity.isInstanceOf[TileMultipart]))
|
||||||
|
{
|
||||||
|
if (tileEntity.isInstanceOf[IRotatable])
|
||||||
|
{
|
||||||
|
val blockRotation: ForgeDirection = (tileEntity.asInstanceOf[IRotatable]).getDirection
|
||||||
|
(tileEntity.asInstanceOf[IRotatable]).setDirection(blockRotation.getRotation(facing.getOpposite))
|
||||||
|
}
|
||||||
|
else if (block.isInstanceOf[IRotatableBlock])
|
||||||
|
{
|
||||||
|
val blockRotation: ForgeDirection = (block.asInstanceOf[IRotatableBlock]).getDirection(world, position.intX, position.intY, position.intZ)
|
||||||
|
(block.asInstanceOf[IRotatableBlock]).setDirection(world, position.intX, position.intY, position.intZ, blockRotation.getRotation(facing.getOpposite))
|
||||||
|
}
|
||||||
|
else if (block != null)
|
||||||
|
{
|
||||||
|
Block.blocksList(blockID).rotateBlock(world, position.intX, position.intY, position.intZ, facing.getOpposite)
|
||||||
|
}
|
||||||
|
world.markBlockForUpdate(position.intX, position.intY, position.intZ)
|
||||||
|
world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "tile.piston.in", 0.5F, world.rand.nextFloat * 0.15F + 0.6F)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
case e: Exception =>
|
||||||
|
{
|
||||||
|
System.out.println("Error while rotating a block near " + x + "x " + y + "y " + z + "z " + (if (world != null && world.provider != null) world.provider.dimensionId + "d" else "null:world"))
|
||||||
|
e.printStackTrace
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var top: Icon = null
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue