Search in sources :

Example 91 with WorldServer

use of net.minecraft.world.WorldServer in project RFTools by McJty.

the class TeleportDestinations method getValidDestinations.

// Server side only
public Collection<TeleportDestinationClientInfo> getValidDestinations(World worldObj, String playerName) {
    FavoriteDestinationsProperties properties = null;
    if (playerName != null) {
        List<EntityPlayerMP> list = ((WorldServer) worldObj).getMinecraftServer().getPlayerList().getPlayers();
        for (EntityPlayerMP entityplayermp : list) {
            if (playerName.equals(entityplayermp.getName())) {
                properties = PlayerExtendedProperties.getFavoriteDestinations(entityplayermp);
                break;
            }
        }
    }
    List<TeleportDestinationClientInfo> result = new ArrayList<>();
    for (TeleportDestination destination : destinations.values()) {
        TeleportDestinationClientInfo destinationClientInfo = new TeleportDestinationClientInfo(destination);
        BlockPos c = destination.getCoordinate();
        World world = DimensionManager.getWorld(destination.getDimension());
        String dimName = null;
        if (world != null) {
            dimName = DimensionManager.getProvider(destination.getDimension()).getDimensionType().getName();
        }
        // }
        if (dimName == null || dimName.trim().isEmpty()) {
            dimName = "Id " + destination.getDimension();
        } else {
            dimName = dimName + " (" + destination.getDimension() + ")";
        }
        destinationClientInfo.setDimensionName(dimName);
        if (world != null) {
            TileEntity te = world.getTileEntity(c);
            if (te instanceof MatterReceiverTileEntity) {
                MatterReceiverTileEntity matterReceiverTileEntity = (MatterReceiverTileEntity) te;
                if (playerName != null && !matterReceiverTileEntity.checkAccess(playerName)) {
                    // No access.
                    continue;
                }
            }
        }
        if (properties != null) {
            destinationClientInfo.setFavorite(properties.isDestinationFavorite(new GlobalCoordinate(c, destination.getDimension())));
        }
        result.add(destinationClientInfo);
    }
    Collections.sort(result);
    return result;
}
Also used : WorldServer(net.minecraft.world.WorldServer) World(net.minecraft.world.World) FavoriteDestinationsProperties(mcjty.rftools.playerprops.FavoriteDestinationsProperties) TileEntity(net.minecraft.tileentity.TileEntity) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos)

Example 92 with WorldServer

use of net.minecraft.world.WorldServer in project BloodMagic by WayofTime.

the class BloodAltar method updateAltar.

private void updateAltar() {
    if (!isActive) {
        if (cooldownAfterCrafting > 0)
            cooldownAfterCrafting--;
        return;
    }
    ItemStack input = tileAltar.getStackInSlot(0);
    if (input.isEmpty())
        return;
    World world = tileAltar.getWorld();
    BlockPos pos = tileAltar.getPos();
    if (world.isRemote)
        return;
    if (!canBeFilled) {
        boolean hasOperated = false;
        int stackSize = input.getCount();
        if (totalCharge > 0) {
            int chargeDrained = Math.min(liquidRequired * stackSize - progress, totalCharge);
            totalCharge -= chargeDrained;
            progress += chargeDrained;
            hasOperated = true;
        }
        if (fluid != null && fluid.amount >= 1) {
            int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
            if (liquidDrained > (liquidRequired * stackSize - progress))
                liquidDrained = liquidRequired * stackSize - progress;
            fluid.amount = fluid.amount - liquidDrained;
            progress += liquidDrained;
            hasOperated = true;
            if (internalCounter % 4 == 0 && world instanceof WorldServer) {
                WorldServer server = (WorldServer) world;
                server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.2, 0, 0.2, 0);
            }
        } else if (!hasOperated && progress > 0) {
            progress -= (int) (efficiencyMultiplier * drainRate);
            if (internalCounter % 2 == 0 && world instanceof WorldServer) {
                WorldServer server = (WorldServer) world;
                server.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.1, 0, 0.1, 0);
            }
        }
        if (hasOperated) {
            if (progress >= liquidRequired * stackSize) {
                ItemStack result = ItemHandlerHelper.copyStackWithSize(recipe.getOutput(), stackSize);
                BloodMagicCraftedEvent.Altar event = new BloodMagicCraftedEvent.Altar(recipe.getInput(), result);
                MinecraftForge.EVENT_BUS.post(event);
                tileAltar.setInventorySlotContents(0, event.getOutput());
                progress = 0;
                if (world instanceof WorldServer) {
                    WorldServer server = (WorldServer) world;
                    server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 40, 0.3, 0, 0.3, 0);
                }
                this.cooldownAfterCrafting = 30;
                this.isActive = false;
            }
        }
    } else {
        ItemStack contained = tileAltar.getStackInSlot(0);
        if (contained.isEmpty() || !(contained.getItem() instanceof IBloodOrb) || !(contained.getItem() instanceof IBindable))
            return;
        BloodOrb orb = ((IBloodOrb) contained.getItem()).getOrb(contained);
        Binding binding = ((IBindable) contained.getItem()).getBinding(contained);
        if (binding == null || orb == null)
            return;
        if (fluid != null && fluid.amount >= 1) {
            int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? orb.getFillRate() * (1 + consumptionMultiplier) : orb.getFillRate()), fluid.amount);
            int drain = NetworkHelper.getSoulNetwork(binding).add(liquidDrained, (int) (orb.getCapacity() * this.orbCapacityMultiplier));
            fluid.amount = fluid.amount - drain;
            if (drain > 0 && internalCounter % 4 == 0 && world instanceof WorldServer) {
                WorldServer server = (WorldServer) world;
                server.spawnParticle(EnumParticleTypes.SPELL_WITCH, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0, 0, 0, 0.001);
            }
        }
    }
    tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) IBindable(WayofTime.bloodmagic.iface.IBindable) IBloodOrb(WayofTime.bloodmagic.orb.IBloodOrb) BloodOrb(WayofTime.bloodmagic.orb.BloodOrb) IBloodOrb(WayofTime.bloodmagic.orb.IBloodOrb) WorldServer(net.minecraft.world.WorldServer) BloodMagicCraftedEvent(WayofTime.bloodmagic.api.event.BloodMagicCraftedEvent) World(net.minecraft.world.World) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) RecipeBloodAltar(WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar) TileAltar(WayofTime.bloodmagic.tile.TileAltar)

Example 93 with WorldServer

use of net.minecraft.world.WorldServer in project BloodMagic by WayofTime.

the class EntityDemonBase method performEmergencyHeal.

public void performEmergencyHeal(double toHeal) {
    this.heal((float) toHeal);
    if (getEntityWorld() instanceof WorldServer) {
        WorldServer server = (WorldServer) getEntityWorld();
        server.spawnParticle(EnumParticleTypes.HEART, this.posX + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, this.posY + 0.5D + (double) (this.rand.nextFloat() * this.height), this.posZ + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, 7, 0.2, 0.2, 0.2, 0);
    }
}
Also used : WorldServer(net.minecraft.world.WorldServer)

Example 94 with WorldServer

use of net.minecraft.world.WorldServer in project BloodMagic by WayofTime.

the class EntitySentientSpecter method performEmergencyHeal.

@Override
public void performEmergencyHeal(double toHeal) {
    this.heal((float) toHeal);
    if (getEntityWorld() instanceof WorldServer) {
        WorldServer server = (WorldServer) getEntityWorld();
        server.spawnParticle(EnumParticleTypes.HEART, this.posX + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, this.posY + 0.5D + (double) (this.rand.nextFloat() * this.height), this.posZ + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, 7, 0.2, 0.2, 0.2, 0);
    }
}
Also used : WorldServer(net.minecraft.world.WorldServer)

Example 95 with WorldServer

use of net.minecraft.world.WorldServer in project Galacticraft by micdoodle8.

the class EventHandlerMars method onPlayerWakeUp.

@SubscribeEvent
public void onPlayerWakeUp(EventWakePlayer event) {
    BlockPos c = event.entityPlayer.playerLocation;
    IBlockState state = event.entityPlayer.getEntityWorld().getBlockState(c);
    Block blockID = state.getBlock();
    if (blockID == MarsBlocks.machine && state.getValue(BlockMachineMars.TYPE) == EnumMachineType.CRYOGENIC_CHAMBER) {
        if (!event.immediately && event.updateWorld && event.setSpawn) {
            event.result = EnumStatus.NOT_POSSIBLE_HERE;
        } else if (!event.immediately && !event.updateWorld && event.setSpawn) {
            if (!event.entityPlayer.worldObj.isRemote) {
                event.entityPlayer.heal(5.0F);
                GCPlayerStats.get(event.entityPlayer).setCryogenicChamberCooldown(6000);
                WorldServer ws = (WorldServer) event.entityPlayer.worldObj;
                ws.updateAllPlayersSleepingFlag();
                if (ws.areAllPlayersAsleep() && ws.getGameRules().getBoolean("doDaylightCycle")) {
                    WorldUtil.setNextMorning(ws);
                }
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.BlockPos) WorldServer(net.minecraft.world.WorldServer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

WorldServer (net.minecraft.world.WorldServer)338 BlockPos (net.minecraft.util.math.BlockPos)101 EntityPlayer (net.minecraft.entity.player.EntityPlayer)63 ItemStack (net.minecraft.item.ItemStack)55 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)51 IMixinWorldServer (org.spongepowered.common.interfaces.world.IMixinWorldServer)47 Entity (net.minecraft.entity.Entity)44 TileEntity (net.minecraft.tileentity.TileEntity)42 IBlockState (net.minecraft.block.state.IBlockState)39 MinecraftServer (net.minecraft.server.MinecraftServer)36 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)32 World (net.minecraft.world.World)29 Block (net.minecraft.block.Block)28 EntityLivingBase (net.minecraft.entity.EntityLivingBase)28 ArrayList (java.util.ArrayList)20 PotionEffect (net.minecraft.potion.PotionEffect)19 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)19 Nullable (javax.annotation.Nullable)17 Chunk (net.minecraft.world.chunk.Chunk)16 World (org.spongepowered.api.world.World)14