Search in sources :

Example 16 with JsonUtil

use of stevekung.mods.moreplanets.util.JsonUtil in project MorePlanets by SteveKunG.

the class ItemBlockDarkEnergyReceiver method placeBlockAt.

@Override
public boolean placeBlockAt(ItemStack itemStack, EntityPlayer player, World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, IBlockState state) {
    int angle = MathHelper.floor(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
    int change = EnumFacing.getHorizontal(angle).getOpposite().getHorizontalIndex();
    if (BlockEventHelper.isLiquidBlock(world, pos)) {
        if (world.isRemote) {
            FMLClientHandler.instance().getClient().ingameGUI.setOverlayMessage(new JsonUtil().text(I18n.format("gui.place_in_liquid.message")).setStyle(new JsonUtil().red()).getFormattedText(), false);
        }
        return false;
    }
    if (change == 0 || change == 2) {
        BlockPos vecToAdd = new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ());
        BlockPos vecToAdd1 = new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ());
        Block block = world.getBlockState(vecToAdd).getBlock();
        Block block1 = world.getBlockState(vecToAdd1).getBlock();
        if (world.getBlockState(vecToAdd).getMaterial() != Material.AIR && !block.isReplaceable(world, vecToAdd)) {
            if (world.isRemote) {
                FMLClientHandler.instance().getClient().ingameGUI.setOverlayMessage(new JsonUtil().text(I18n.format("gui.warning.noroom")).setStyle(new JsonUtil().red()).getFormattedText(), false);
            }
            return false;
        } else if (world.getBlockState(vecToAdd1).getMaterial() != Material.AIR && !block1.isReplaceable(world, vecToAdd1)) {
            if (world.isRemote) {
                FMLClientHandler.instance().getClient().ingameGUI.setOverlayMessage(new JsonUtil().text(I18n.format("gui.warning.noroom")).setStyle(new JsonUtil().red()).getFormattedText(), false);
            }
            return false;
        } else {
            if (!vecToAdd.equals(pos)) {
                MPBlocks.DUMMY_BLOCK.makeFakeBlock(world, vecToAdd, pos, BlockDummy.BlockType.DARK_ENERGY_SOLAR1);
            }
            if (!vecToAdd1.equals(pos)) {
                MPBlocks.DUMMY_BLOCK.makeFakeBlock(world, vecToAdd1, pos, BlockDummy.BlockType.DARK_ENERGY_SOLAR2);
            }
            return super.placeBlockAt(itemStack, player, world, pos, facing, hitX, hitY, hitZ, state);
        }
    }
    if (change == 1 || change == 3) {
        BlockPos vecToAdd = new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1);
        BlockPos vecToAdd1 = new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1);
        Block block = world.getBlockState(vecToAdd).getBlock();
        Block block1 = world.getBlockState(vecToAdd1).getBlock();
        if (world.getBlockState(vecToAdd).getMaterial() != Material.AIR && !block.isReplaceable(world, vecToAdd)) {
            if (world.isRemote) {
                FMLClientHandler.instance().getClient().ingameGUI.setOverlayMessage(new JsonUtil().text(I18n.format("gui.warning.noroom")).setStyle(new JsonUtil().red()).getFormattedText(), false);
            }
            return false;
        } else if (world.getBlockState(vecToAdd1).getMaterial() != Material.AIR && !block1.isReplaceable(world, vecToAdd1)) {
            if (world.isRemote) {
                FMLClientHandler.instance().getClient().ingameGUI.setOverlayMessage(new JsonUtil().text(I18n.format("gui.warning.noroom")).setStyle(new JsonUtil().red()).getFormattedText(), false);
            }
            return false;
        } else {
            if (!vecToAdd.equals(pos)) {
                MPBlocks.DUMMY_BLOCK.makeFakeBlock(world, vecToAdd, pos, BlockDummy.BlockType.DARK_ENERGY_SOLAR3);
            }
            if (!vecToAdd1.equals(pos)) {
                MPBlocks.DUMMY_BLOCK.makeFakeBlock(world, vecToAdd1, pos, BlockDummy.BlockType.DARK_ENERGY_SOLAR4);
            }
            return super.placeBlockAt(itemStack, player, world, pos, facing, hitX, hitY, hitZ, state);
        }
    }
    return false;
}
Also used : Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) JsonUtil(stevekung.mods.moreplanets.util.JsonUtil)

Aggregations

JsonUtil (stevekung.mods.moreplanets.util.JsonUtil)16 EntityPlayer (net.minecraft.entity.player.EntityPlayer)7 BlockPos (net.minecraft.util.math.BlockPos)7 Block (net.minecraft.block.Block)5 ItemStack (net.minecraft.item.ItemStack)3 TileEntity (net.minecraft.tileentity.TileEntity)3 Map (java.util.Map)2 IBlockState (net.minecraft.block.state.IBlockState)2 ActionResult (net.minecraft.util.ActionResult)2 EnumActionResult (net.minecraft.util.EnumActionResult)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 HashMap (java.util.HashMap)1 Random (java.util.Random)1 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)1 IMultiBlock (micdoodle8.mods.galacticraft.core.tile.IMultiBlock)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 Item (net.minecraft.item.Item)1 ItemBlock (net.minecraft.item.ItemBlock)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1