Basic sigils implementation

This commit is contained in:
Arcaratus 2015-12-27 19:38:12 -05:00
parent ae85224003
commit 5dff08380d
61 changed files with 1394 additions and 106 deletions

View file

@ -0,0 +1,42 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
import WayofTime.bloodmagic.entity.projectile.EntityBloodLight;
import WayofTime.bloodmagic.item.ItemBindable;
import WayofTime.bloodmagic.registry.ModBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import org.lwjgl.Sys;
public class ItemSigilBloodLight extends ItemSigilBase {
public ItemSigilBloodLight() {
super("bloodLight", 10);
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonBatteries(stack, player, getEnergyUsed() * 5) && !world.isRemote)
world.spawnEntityInWorld(new EntityBloodLight(world, player));
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) return false;
if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonBatteries(stack, player, getEnergyUsed())) {
BlockPos newPos = blockPos.offset(side);
if (world.isAirBlock(newPos)) {
world.setBlockState(newPos, ModBlocks.bloodLight.getDefaultState());
}
}
return true;
}
}

View file

@ -0,0 +1,4 @@
package WayofTime.bloodmagic.item.sigil;
public class ItemSigilCompression {
}

View file

@ -16,7 +16,7 @@ import net.minecraft.util.ChatComponentText;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class ItemSigilDivination extends ItemSigilBase implements ISigil, IAltarReader {
public class ItemSigilDivination extends ItemSigilBase implements IAltarReader {
public ItemSigilDivination() {
super("divination");

View file

@ -0,0 +1,22 @@
package WayofTime.bloodmagic.item.sigil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilElementalAffinity extends ItemSigilToggleable {
public ItemSigilElementalAffinity() {
super("elementalAffinity", 200);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
player.fallDistance = 0;
player.extinguish();
player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 2, 1, true, false));
player.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 2, 0, true, false));
}
}

View file

@ -0,0 +1,4 @@
package WayofTime.bloodmagic.item.sigil;
public class ItemSigilEnderSeverance {
}

View file

@ -0,0 +1,19 @@
package WayofTime.bloodmagic.item.sigil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilFastMiner extends ItemSigilToggleable {
public ItemSigilFastMiner() {
super("fastMiner", 100);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 2, 0, true, false));
}
}

View file

@ -0,0 +1,81 @@
package WayofTime.bloodmagic.item.sigil;
import net.minecraft.block.Block;
import net.minecraft.block.IGrowable;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
public class ItemSigilGreenGrove extends ItemSigilToggleable {
public ItemSigilGreenGrove() {
super("greenGrove", 150);
}
@Override
public boolean onSigilUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) {
if (applyBonemeal(stack, world, blockPos)) {
world.playAuxSFX(2005, blockPos, 0);
return true;
}
return false;
}
@Override
public void onSigilUpdate(ItemStack stack, World worldIn, EntityPlayer player, int itemSlot, boolean isSelected) {
int range = 3;
int verticalRange = 2;
int posX = (int) Math.round(player.posX - 0.5f);
int posY = (int) player.posY;
int posZ = (int) Math.round(player.posZ - 0.5f);
for (int ix = posX - range; ix <= posX + range; ix++) {
for (int iz = posZ - range; iz <= posZ + range; iz++) {
for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++) {
BlockPos blockPos = new BlockPos(ix, iy, iz);
Block block = worldIn.getBlockState(blockPos).getBlock();
if (block instanceof IPlantable || block instanceof IGrowable) {
if (worldIn.rand.nextInt(50) == 0) {
IBlockState preBlockState = worldIn.getBlockState(blockPos);
block.updateTick(worldIn, blockPos, worldIn.getBlockState(blockPos), worldIn.rand);
if (!worldIn.getBlockState(blockPos).equals(preBlockState))
worldIn.playAuxSFX(2005, blockPos, 0);
}
}
}
}
}
}
private boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target) {
return worldIn instanceof net.minecraft.world.WorldServer && applyBonemeal(stack, worldIn, target, net.minecraftforge.common.util.FakePlayerFactory.getMinecraft((net.minecraft.world.WorldServer) worldIn));
}
private boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target, EntityPlayer player) {
IBlockState iblockstate = worldIn.getBlockState(target);
int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, target, iblockstate, stack);
if (hook != 0) return hook > 0;
if (iblockstate.getBlock() instanceof IGrowable) {
IGrowable igrowable = (IGrowable) iblockstate.getBlock();
if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote)) {
if (!worldIn.isRemote) {
if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate))
igrowable.grow(worldIn, worldIn.rand, target, iblockstate);
}
return true;
}
}
return false;
}
}

View file

@ -0,0 +1,19 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.registry.ModPotions;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSigilHaste extends ItemSigilToggleable {
public ItemSigilHaste() {
super("haste", 250);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
player.addPotionEffect(new PotionEffect(ModPotions.boost.id, 2, 0, true, false));
}
}

View file

@ -0,0 +1,4 @@
package WayofTime.bloodmagic.item.sigil;
public class ItemSigilHurricane {
}

View file

@ -23,7 +23,7 @@ public class ItemSigilLava extends ItemSigilBase {
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (!world.isRemote && !isUnusable(stack)) {
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true);
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false);
if (movingobjectposition != null) {
ItemStack ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(player, world, stack, movingobjectposition);
@ -47,12 +47,10 @@ public class ItemSigilLava extends ItemSigilBase {
return stack;
}
if (this.canPlaceLava(world, blockpos1) && syphonBatteries(stack, player, getEnergyUsed())) {
this.tryPlaceLava(world, blockpos1);
if (this.canPlaceLava(world, blockpos1) && syphonBatteries(stack, player, getEnergyUsed()) && this.tryPlaceLava(world, blockpos1)) {
return stack;
}
}
} else {
return stack;
}
if (!player.capabilities.isCreativeMode)
@ -86,25 +84,14 @@ public class ItemSigilLava extends ItemSigilBase {
// return false;
// }
{
int x = blockPos.getX();
int y = blockPos.getY();
int z = blockPos.getZ();
BlockPos newPos = blockPos.offset(side);
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(newPos, side, stack)) {
return false;
}
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));
}
if (this.canPlaceLava(world, newPos) && syphonBatteries(stack, player, getEnergyUsed())) {
return this.tryPlaceLava(world, newPos);
}
return false;
@ -116,7 +103,7 @@ public class ItemSigilLava extends ItemSigilBase {
} 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());
world.setBlockState(blockPos, Blocks.lava.getBlockState().getBaseState(), 3);
return true;
}
}

View file

@ -0,0 +1,40 @@
package WayofTime.bloodmagic.item.sigil;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import java.util.List;
public class ItemSigilMagnetism extends ItemSigilToggleable {
public ItemSigilMagnetism() {
super("magnetism", 50);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
int range = 5;
int verticalRange = 5;
float posX = Math.round(player.posX);
float posY = (float) (player.posY - player.getEyeHeight());
float posZ = Math.round(player.posZ);
List<EntityItem> entities = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.fromBounds(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
List<EntityXPOrb> xpOrbs = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, AxisAlignedBB.fromBounds(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
for (EntityItem entity : entities) {
if (entity != null && !world.isRemote) {
entity.onCollideWithPlayer(player);
}
}
for (EntityXPOrb xpOrb : xpOrbs) {
if (xpOrb != null && !world.isRemote) {
xpOrb.onCollideWithPlayer(player);
}
}
}
}

View file

@ -0,0 +1,57 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.registry.ModBlocks;
import WayofTime.bloodmagic.tile.TilePhantomBlock;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class ItemSigilPhantomBridge extends ItemSigilToggleable {
public ItemSigilPhantomBridge() {
super("phantomBridge", 100);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (!player.onGround && !player.isSneaking())
return;
int range = 2;
int verticalOffset = -1;
if (player.isSneaking())
verticalOffset--;
if (world.isRemote)
verticalOffset--;
int posX = (int) Math.round(player.posX - 0.5f);
int posY = (int) player.posY;
int posZ = (int) Math.round(player.posZ - 0.5f);
for (int ix = posX - range; ix <= posX + range; ix++) {
for (int iz = posZ - range; iz <= posZ + range; iz++) {
BlockPos blockPos = new BlockPos(ix, posY + verticalOffset, iz);
Block block = world.getBlockState(blockPos).getBlock();
if (world.isAirBlock(blockPos)) {
world.setBlockState(blockPos, ModBlocks.phantomBlock.getDefaultState(), 3);
TileEntity tile = world.getTileEntity(blockPos);
if (tile instanceof TilePhantomBlock) {
((TilePhantomBlock) tile).setDuration(100);
}
} else if (block == ModBlocks.phantomBlock) {
TileEntity tile = world.getTileEntity(blockPos);
if (tile instanceof TilePhantomBlock) {
((TilePhantomBlock) tile).setDuration(100);
}
}
}
}
}
}

View file

@ -0,0 +1,73 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.altar.IBloodAltar;
import WayofTime.bloodmagic.api.iface.IAltarReader;
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.tile.TileInventory;
import WayofTime.bloodmagic.util.ChatUtil;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class ItemSigilSeer extends ItemSigilBase implements IAltarReader {
public ItemSigilSeer() {
super("seer");
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (PlayerHelper.isFakePlayer(player))
return stack;
super.onItemRightClick(stack, world, player);
if (!world.isRemote) {
MovingObjectPosition position = getMovingObjectPositionFromPlayer(world, player, false);
int currentEssence = NetworkHelper.getSoulNetwork(BindableHelper.getOwnerName(stack), world).getCurrentEssence();
if (position == null) {
ChatUtil.sendNoSpam(player, new ChatComponentText(TextHelper.localize(tooltipBase + "currentEssence", currentEssence)));
return stack;
} else {
if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
TileEntity tile = world.getTileEntity(position.getBlockPos());
if (tile != null && tile instanceof IBloodAltar) {
IBloodAltar altar = (IBloodAltar) tile;
int tier = altar.getTier().ordinal() + 1;
currentEssence = altar.getCurrentBlood();
int capacity = altar.getCapacity();
altar.checkTier();
if (tile instanceof IInventory) {
if (((IInventory) tile).getStackInSlot(0) != null) {
int progress = altar.getProgress();
int totalLiquidRequired = altar.getLiquidRequired() * ((IInventory) tile).getStackInSlot(0).stackSize;
int consumptionRate = (int) (altar.getConsumptionRate() * (altar.getConsumptionMultiplier() + 1));
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentAltarProgress", progress, totalLiquidRequired), TextHelper.localize(tooltipBase + "currentAltarConsumptionRate", consumptionRate), TextHelper.localize(tooltipBase + "currentAltarTier", tier), TextHelper.localize(tooltipBase + "currentEssence", currentEssence), TextHelper.localize(tooltipBase + "currentAltarCapacity", capacity));
}
else {
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentAltarTier", tier), TextHelper.localize(tooltipBase + "currentEssence", currentEssence), TextHelper.localize(tooltipBase + "currentAltarCapacity", capacity));
}
}
} else {
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentEssence", currentEssence));
}
return stack;
}
}
}
return stack;
}
}

View file

@ -0,0 +1,51 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.tile.TileSpectralBlock;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.IFluidBlock;
public class ItemSigilSuppression extends ItemSigilToggleable {
public ItemSigilSuppression() {
super("suppression", 400);
}
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
int x = (int) player.posX;
int y = (int) player.posY;
int z = (int) player.posZ;
final int radius = 5;
final int refresh = 100;
for (int i = -radius; i <= radius; i++) {
for (int j = -radius; j <= radius; j++) {
for (int k = -radius; k <= radius; k++) {
if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f)) {
continue;
}
BlockPos blockPos = new BlockPos(x + i, y + j, z + k);
Block block = world.getBlockState(blockPos).getBlock();
if (isBlockLiquid(block) && world.getTileEntity(blockPos) == null)
TileSpectralBlock.createSpectralBlock(world, blockPos, refresh);
else {
TileEntity tile = world.getTileEntity(blockPos);
if (tile instanceof TileSpectralBlock)
((TileSpectralBlock) tile).resetDuration(refresh);
}
}
}
}
}
private boolean isBlockLiquid(Block block) {
return (block instanceof IFluidBlock || block.getMaterial().isLiquid());
}
}

View file

@ -0,0 +1,74 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
import WayofTime.bloodmagic.item.ItemBindable;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public class ItemSigilToggleable extends ItemSigilBase {
public ItemSigilToggleable(String name, int lpUsed) {
super(name, lpUsed);
setToggleable();
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
if (getActivated(stack))
tooltip.add(TextHelper.localize("tooltip.BloodMagic.activated"));
else
tooltip.add(TextHelper.localize("tooltip.BloodMagic.deactivated"));
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (!world.isRemote && !isUnusable(stack)) {
if (player.isSneaking())
setActivated(stack, !getActivated(stack));
if (getActivated(stack) && ItemBindable.syphonBatteries(stack, player, getEnergyUsed()))
return stack;
}
return stack;
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) {
if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonBatteries(stack, player, getEnergyUsed()))
return onSigilUseFirst(stack, player, world, blockPos, side, hitX, hitY, hitZ);
return false;
}
public boolean onSigilUseFirst(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) {
return false;
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack)) {
if (worldIn.getWorldTime() % 100 == 0) {
if (!ItemBindable.syphonBatteries(stack, (EntityPlayer) entityIn, getEnergyUsed())) {
setActivated(stack, false);
}
}
onSigilUpdate(stack, worldIn, (EntityPlayer) entityIn, itemSlot, isSelected);
}
}
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {}
}

View file

@ -80,26 +80,15 @@ public class ItemSigilVoid extends ItemSigilBase {
return false;
}
{
int x = blockPos.getX();
int y = blockPos.getY();
int z = blockPos.getZ();
BlockPos newPos = blockPos.offset(side);
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(newPos, side, stack)) {
return false;
}
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;
}
if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && syphonBatteries(stack, player, getEnergyUsed())) {
world.setBlockToAir(newPos);
return true;
}
return false;

View file

@ -24,7 +24,7 @@ public class ItemSigilWater extends ItemSigilBase {
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (!world.isRemote && !isUnusable(stack)) {
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true);
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false);
if (movingobjectposition != null) {
ItemStack ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(player, world, stack, movingobjectposition);
@ -47,12 +47,10 @@ public class ItemSigilWater extends ItemSigilBase {
return stack;
}
if (this.canPlaceWater(world, blockpos1) && syphonBatteries(stack, player, getEnergyUsed())) {
this.tryPlaceWater(world, blockpos1);
if (this.canPlaceWater(world, blockpos1) && syphonBatteries(stack, player, getEnergyUsed()) && this.tryPlaceWater(world, blockpos1)) {
return stack;
}
}
} else {
return stack;
}
if (!player.capabilities.isCreativeMode)
@ -87,32 +85,27 @@ public class ItemSigilWater extends ItemSigilBase {
// return false;
// }
{
int x = blockPos.getX();
int y = blockPos.getY();
int z = blockPos.getZ();
BlockPos newPos = blockPos.offset(side);
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(newPos, side, stack)) {
return false;
}
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));
}
if (this.canPlaceWater(world, newPos) && syphonBatteries(stack, player, getEnergyUsed())) {
return this.tryPlaceWater(world, newPos);
}
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);
if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial().isSolid()) {
return false;
} else if ((world.getBlockState(blockPos).getBlock() == Blocks.water || world.getBlockState(blockPos).getBlock() == Blocks.flowing_water) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0) {
return false;
} else {
return true;
}
}
public boolean tryPlaceWater(World worldIn, BlockPos pos) {