Search in sources :

Example 1 with TileEntitySpaceWarpPadFull

use of stevekung.mods.moreplanets.tileentity.TileEntitySpaceWarpPadFull in project MorePlanets by SteveKunG.

the class BlockSpaceWarpPadFull method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return true;
    } else {
        if (!player.isSneaking()) {
            TileEntity tile = world.getTileEntity(pos);
            if (tile instanceof TileEntitySpaceWarpPadFull) {
                TileEntitySpaceWarpPadFull warpPad = (TileEntitySpaceWarpPadFull) tile;
                JsonUtil json = new JsonUtil();
                if (!warpPad.disabled) {
                    if (warpPad.hasWarpCore()) {
                        if (warpPad.getDestinationPos() == null) {
                            player.sendMessage(json.text(GCCoreUtil.translate("gui.no_warp_destination.message")).setStyle(json.red()));
                            return true;
                        } else {
                            if (warpPad.getEnergyStoredGC() >= 5000.0F) {
                                warpPad.storage.setEnergyStored(warpPad.storage.getEnergyStoredGC() - 5000.0F);
                                TeleportUtil.teleportEntity(player, warpPad.getDimensionId(), warpPad.getDestinationPos().getX(), warpPad.getDestinationPos().getY(), warpPad.getDestinationPos().getZ(), warpPad.getRotationPitch(), warpPad.getRotationYaw());
                                world.playSound(null, pos, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 0.75F, 1.0F);
                                MPLog.debug("Teleport player to %s, %s, %s, %s, %s", warpPad.getDestinationPos().getX(), warpPad.getDestinationPos().getY(), warpPad.getDestinationPos().getZ(), warpPad.getDimensionId(), WorldUtil.getProviderForDimensionClient(warpPad.getDimensionId()).getDimensionType().getName());
                                return true;
                            } else {
                                player.sendMessage(json.text(GCCoreUtil.translate("gui.status.missingpower.name")).setStyle(json.red()));
                                return true;
                            }
                        }
                    } else {
                        player.sendMessage(json.text(GCCoreUtil.translate("gui.status.warp_core_required.name")).setStyle(json.red()));
                        return true;
                    }
                } else {
                    player.sendMessage(json.text(GCCoreUtil.translate("gui.dark_energy_disabled.message")).setStyle(json.red()));
                    return true;
                }
            }
        } else {
            player.openGui(MorePlanetsCore.INSTANCE, -1, world, pos.getX(), pos.getY(), pos.getZ());
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntitySpaceWarpPadFull(stevekung.mods.moreplanets.tileentity.TileEntitySpaceWarpPadFull) JsonUtil(stevekung.mods.moreplanets.util.JsonUtil)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)1 TileEntitySpaceWarpPadFull (stevekung.mods.moreplanets.tileentity.TileEntitySpaceWarpPadFull)1 JsonUtil (stevekung.mods.moreplanets.util.JsonUtil)1