storage cells + drives
This commit is contained in:
28
src/main/java/storagecraft/block/BlockDrive.java
Normal file
28
src/main/java/storagecraft/block/BlockDrive.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package storagecraft.block;
|
||||
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import storagecraft.SC;
|
||||
import storagecraft.tile.TileDrive;
|
||||
|
||||
public class BlockDrive extends BlockSC implements ITileEntityProvider {
|
||||
public BlockDrive() {
|
||||
super("drive");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if (!world.isRemote) {
|
||||
player.openGui(SC.INSTANCE, SC.GUI.DRIVE, world, x, y, z);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileDrive();
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@ package storagecraft.block;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -31,8 +33,10 @@ public class BlockSC extends Block {
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) {
|
||||
super.onBlockPlacedBy(world, x, y, z, entityLiving, itemStack);
|
||||
|
||||
if (world.getTileEntity(x, y, z) instanceof TileSC) {
|
||||
ForgeDirection direction = ForgeDirection.UNKNOWN;
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileSC) {
|
||||
ForgeDirection direction = null;
|
||||
|
||||
int facing = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
|
||||
@@ -51,7 +55,18 @@ public class BlockSC extends Block {
|
||||
break;
|
||||
}
|
||||
|
||||
((TileSC) world.getTileEntity(x, y, z)).setDirection(direction);
|
||||
((TileSC) tile).setDirection(direction);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPreDestroy(World world, int x, int y, int z, int meta) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof IInventory) {
|
||||
SC.dropInventoryContent(world, (IInventory) tile, x, y, z, 0);
|
||||
}
|
||||
|
||||
super.onBlockPreDestroy(world, x, y, z, meta);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user