Finished Water, Lava, and Void sigils
Also added in bloodstone
This commit is contained in:
parent
5ec35fcd08
commit
86fcd4808b
24 changed files with 698 additions and 25 deletions
|
@ -0,0 +1,24 @@
|
|||
package WayofTime.bloodmagic.item.block;
|
||||
|
||||
import WayofTime.bloodmagic.block.BlockBloodStoneBrick;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemBlockBloodStoneBrick extends ItemBlock {
|
||||
|
||||
public ItemBlockBloodStoneBrick(Block block) {
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + BlockBloodStoneBrick.names[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int meta) {
|
||||
return meta;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import WayofTime.bloodmagic.registry.ModPotions;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
|
133
src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java
Normal file
133
src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java
Normal file
|
@ -0,0 +1,133 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class ItemSigilLava extends ItemSigilBase implements ISigil {
|
||||
|
||||
public ItemSigilLava() {
|
||||
super("lava", 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (!world.isRemote && !isUnusable(stack)) {
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true);
|
||||
|
||||
if (movingobjectposition != null) {
|
||||
ItemStack ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(player, world, stack, movingobjectposition);
|
||||
if (ret != null) return ret;
|
||||
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
BlockPos blockpos = movingobjectposition.getBlockPos();
|
||||
|
||||
if (!world.isBlockModifiable(player, blockpos)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (!player.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, stack)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
BlockPos blockpos1 = blockpos.offset(movingobjectposition.sideHit);
|
||||
|
||||
if (!player.canPlayerEdit(blockpos1, movingobjectposition.sideHit, stack)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (this.canPlaceLava(world, blockpos1) && syphonBatteries(stack, player, getEnergyUsed())) {
|
||||
this.tryPlaceLava(world, blockpos1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
this.setUnusable(stack, !syphonBatteries(stack, player, getEnergyUsed()));
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote || !BindableHelper.checkAndSetItemOwner(stack, player) || player.isSneaking() || isUnusable(stack)) {
|
||||
return false;
|
||||
}
|
||||
if (!world.canMineBlockBody(player, blockPos)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(blockPos);
|
||||
if (tile instanceof IFluidHandler) {
|
||||
FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000);
|
||||
int amount = ((IFluidHandler) tile).fill(side, fluid, false);
|
||||
|
||||
if (amount > 0 && syphonBatteries(stack, player, getEnergyUsed())) {
|
||||
((IFluidHandler) tile).fill(side, fluid, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// else if (tile instanceof TESocket) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
{
|
||||
int x = blockPos.getX();
|
||||
int y = blockPos.getY();
|
||||
int z = blockPos.getZ();
|
||||
|
||||
if (side.getIndex() == 0) --y;
|
||||
if (side.getIndex() == 1) ++y;
|
||||
if (side.getIndex() == 2) --z;
|
||||
if (side.getIndex() == 3) ++z;
|
||||
if (side.getIndex() == 4) --x;
|
||||
if (side.getIndex() == 5) ++x;
|
||||
|
||||
if (!player.canPlayerEdit(new BlockPos(x, y, z), side, stack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.canPlaceLava(world, new BlockPos(x, y, z)) && syphonBatteries(stack, player, getEnergyUsed())) {
|
||||
return this.tryPlaceLava(world, new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canPlaceLava(World world, BlockPos blockPos) {
|
||||
if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial().isSolid()) {
|
||||
return false;
|
||||
}
|
||||
else if ((world.getBlockState(blockPos).getBlock() == Blocks.lava || world.getBlockState(blockPos).getBlock() == Blocks.flowing_lava) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
world.setBlockState(blockPos, Blocks.lava.getBlockState().getBaseState());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean tryPlaceLava(World worldIn, BlockPos pos) {
|
||||
Material material = worldIn.getBlockState(pos).getBlock().getMaterial();
|
||||
|
||||
return worldIn.isAirBlock(pos) && !material.isSolid();
|
||||
}
|
||||
}
|
108
src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java
Normal file
108
src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java
Normal file
|
@ -0,0 +1,108 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class ItemSigilVoid extends ItemSigilBase {
|
||||
|
||||
public ItemSigilVoid() {
|
||||
super("void", 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (!world.isRemote && !isUnusable(stack)) {
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true);
|
||||
|
||||
if (movingobjectposition != null) {
|
||||
ItemStack ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(player, world, stack, movingobjectposition);
|
||||
if (ret != null) return ret;
|
||||
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
BlockPos blockpos = movingobjectposition.getBlockPos();
|
||||
|
||||
if (!world.isBlockModifiable(player, blockpos)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (!player.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, stack)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (!player.canPlayerEdit(blockpos, movingobjectposition.sideHit, stack)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (world.getBlockState(blockpos).getBlock().getMaterial().isLiquid() && syphonBatteries(stack, player, getEnergyUsed())) {
|
||||
world.setBlockToAir(blockpos);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
this.setUnusable(stack, !syphonBatteries(stack, player, getEnergyUsed()));
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote || !BindableHelper.checkAndSetItemOwner(stack, player) || player.isSneaking() || isUnusable(stack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!world.canMineBlockBody(player, blockPos)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(blockPos);
|
||||
if (tile instanceof IFluidHandler) {
|
||||
FluidStack amount = ((IFluidHandler) tile).drain(side, 1000, false);
|
||||
|
||||
if (amount != null && amount.amount > 0 && syphonBatteries(stack, player, getEnergyUsed())) {
|
||||
((IFluidHandler) tile).drain(side, 1000, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
int x = blockPos.getX();
|
||||
int y = blockPos.getY();
|
||||
int z = blockPos.getZ();
|
||||
|
||||
if (side.getIndex() == 0) --y;
|
||||
if (side.getIndex() == 1) ++y;
|
||||
if (side.getIndex() == 2) --z;
|
||||
if (side.getIndex() == 3) ++z;
|
||||
if (side.getIndex() == 4) --x;
|
||||
if (side.getIndex() == 5) ++x;
|
||||
|
||||
if (!player.canPlayerEdit(new BlockPos(x, y, z), side, stack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlockState(new BlockPos(x, y, z)).getBlock() instanceof IFluidBlock && syphonBatteries(stack, player, getEnergyUsed())) {
|
||||
world.setBlockToAir(new BlockPos(x, y, z));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class ItemSigilWater extends ItemSigilBase implements ISigil {
|
||||
|
||||
public ItemSigilWater() {
|
||||
super("water", 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (!world.isRemote && !isUnusable(stack)) {
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true);
|
||||
|
||||
if (movingobjectposition != null) {
|
||||
ItemStack ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(player, world, stack, movingobjectposition);
|
||||
if (ret != null) return ret;
|
||||
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
BlockPos blockpos = movingobjectposition.getBlockPos();
|
||||
|
||||
if (!world.isBlockModifiable(player, blockpos)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (!player.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, stack)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
BlockPos blockpos1 = blockpos.offset(movingobjectposition.sideHit);
|
||||
|
||||
if (!player.canPlayerEdit(blockpos1, movingobjectposition.sideHit, stack)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (this.canPlaceWater(world, blockpos1) && syphonBatteries(stack, player, getEnergyUsed())) {
|
||||
this.tryPlaceWater(world, blockpos1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
this.setUnusable(stack, !syphonBatteries(stack, player, getEnergyUsed()));
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote || !BindableHelper.checkAndSetItemOwner(stack, player) || player.isSneaking() || isUnusable(stack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!world.canMineBlockBody(player, blockPos)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(blockPos);
|
||||
if (tile instanceof IFluidHandler) {
|
||||
FluidStack fluid = new FluidStack(FluidRegistry.WATER, 1000);
|
||||
int amount = ((IFluidHandler) tile).fill(side, fluid, false);
|
||||
|
||||
if (amount > 0 && syphonBatteries(stack, player, getEnergyUsed())) {
|
||||
((IFluidHandler) tile).fill(side, fluid, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// else if (tile instanceof TESocket) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
{
|
||||
int x = blockPos.getX();
|
||||
int y = blockPos.getY();
|
||||
int z = blockPos.getZ();
|
||||
|
||||
if (side.getIndex() == 0) --y;
|
||||
if (side.getIndex() == 1) ++y;
|
||||
if (side.getIndex() == 2) --z;
|
||||
if (side.getIndex() == 3) ++z;
|
||||
if (side.getIndex() == 4) --x;
|
||||
if (side.getIndex() == 5) ++x;
|
||||
|
||||
if (!player.canPlayerEdit(new BlockPos(x, y, z), side, stack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.canPlaceWater(world, new BlockPos(x, y, z)) && syphonBatteries(stack, player, getEnergyUsed())) {
|
||||
return this.tryPlaceWater(world, new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canPlaceWater(World world, BlockPos blockPos) {
|
||||
return (world.isAirBlock(blockPos) && !world.getBlockState(blockPos).getBlock().getMaterial().isSolid()) && !((world.getBlockState(blockPos).getBlock() == Blocks.water || world.getBlockState(blockPos).getBlock() == Blocks.flowing_water) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0);
|
||||
}
|
||||
|
||||
public boolean tryPlaceWater(World worldIn, BlockPos pos) {
|
||||
|
||||
Material material = worldIn.getBlockState(pos).getBlock().getMaterial();
|
||||
boolean flag = !material.isSolid();
|
||||
|
||||
if (!worldIn.isAirBlock(pos) && !flag) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if (worldIn.provider.doesWaterVaporize()) {
|
||||
int i = pos.getX();
|
||||
int j = pos.getY();
|
||||
int k = pos.getZ();
|
||||
worldIn.playSoundEffect((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);
|
||||
|
||||
for (int l = 0; l < 8; ++l) {
|
||||
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!worldIn.isRemote && flag && !material.isLiquid()) {
|
||||
worldIn.destroyBlock(pos, true);
|
||||
}
|
||||
|
||||
worldIn.setBlockState(pos, Blocks.water.getDefaultState(), 3);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue