Search in sources :

Example 6 with WorldServer

use of net.minecraft.world.WorldServer in project Overloaded by CJ-MC-Mods.

the class MultiToolRightClickHandler method onMessage.

/**
     * Called when a message is received of the appropriate type. You can optionally return a reply message, or null if no reply
     * is needed.
     *
     * @param message The message
     * @param ctx the context of the message
     * @return an optional return message
     */
@Override
@Nullable
public IMessage onMessage(MultiToolRightClickMessage message, MessageContext ctx) {
    EntityPlayerMP player = ctx.getServerHandler().player;
    WorldServer world = player.getServerWorld();
    world.addScheduledTask(() -> ModItems.itemMultiTool.rightClickWithItem(world, player, message.getPos(), message.getHitSide(), message.getHitX(), message.getHitY(), message.getHitZ()));
    // Nothing to send to client from here
    return null;
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldServer(net.minecraft.world.WorldServer) Nullable(javax.annotation.Nullable)

Example 7 with WorldServer

use of net.minecraft.world.WorldServer in project ICBM-Classic by BuiltBrokenModding.

the class BlastRegen method doExplode.

@Override
public void doExplode() {
    if (!world().isRemote) {
        try {
            Chunk oldChunk = world().getChunkFromBlockCoords(position.xi(), position.zi());
            if (world() instanceof WorldServer) {
                IChunkProvider provider = world().getChunkProvider();
                Chunk newChunk = ((ChunkProviderServer) provider).currentChunkProvider.provideChunk(oldChunk.xPosition, oldChunk.zPosition);
                for (int x = 0; x < 16; x++) {
                    for (int z = 0; z < 16; z++) {
                        for (int y = 0; y < world().getHeight(); y++) {
                            Block blockID = newChunk.getBlock(x, y, z);
                            int metadata = newChunk.getBlockMetadata(x, y, z);
                            world().setBlock(x + oldChunk.xPosition * 16, y, z + oldChunk.zPosition * 16, blockID, metadata, 3);
                        }
                    }
                }
                oldChunk.isTerrainPopulated = false;
                provider.populate(provider, oldChunk.xPosition, oldChunk.zPosition);
                oldChunk.isModified = true;
            }
        } catch (Exception e) {
            ICBMClassic.INSTANCE.logger().error("ICBM Rejuvenation Failed!", e);
        }
    }
}
Also used : IChunkProvider(net.minecraft.world.chunk.IChunkProvider) Block(net.minecraft.block.Block) WorldServer(net.minecraft.world.WorldServer) Chunk(net.minecraft.world.chunk.Chunk)

Example 8 with WorldServer

use of net.minecraft.world.WorldServer in project ICBM-Classic by BuiltBrokenModding.

the class MissileHoming method update.

@Override
public void update(EntityMissile missileObj) {
    if (missileObj.getTicksInAir() > missileObj.missileFlightTime / 2 && missileObj.missileType == MissileType.MISSILE) {
        WorldServer worldServer = (WorldServer) missileObj.worldObj;
        Entity trackingEntity = worldServer.getEntityByID(missileObj.trackingVar);
        if (trackingEntity != null) {
            if (trackingEntity.equals(missileObj)) {
                missileObj.setExplode();
            }
            missileObj.targetVector = new Pos(trackingEntity);
            missileObj.missileType = MissileType.CruiseMissile;
            missileObj.deltaPathX = missileObj.targetVector.x() - missileObj.posX;
            missileObj.deltaPathY = missileObj.targetVector.y() - missileObj.posY;
            missileObj.deltaPathZ = missileObj.targetVector.z() - missileObj.posZ;
            missileObj.flatDistance = missileObj.sourceOfProjectile.toVector2().distance(missileObj.targetVector.toVector2());
            missileObj.maxHeight = 150 + (int) (missileObj.flatDistance * 1.8);
            missileObj.missileFlightTime = (float) Math.max(100, 2.4 * missileObj.flatDistance);
            missileObj.acceleration = (float) missileObj.maxHeight * 2 / (missileObj.missileFlightTime * missileObj.missileFlightTime);
            if (missileObj.xiaoDanMotion.equals(new Pos()) || missileObj.xiaoDanMotion == null) {
                float suDu = 0.3f;
                missileObj.xiaoDanMotion = new Pos(missileObj.deltaPathX / (missileObj.missileFlightTime * suDu), missileObj.deltaPathY / (missileObj.missileFlightTime * suDu), missileObj.deltaPathZ / (missileObj.missileFlightTime * suDu));
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) Pos(com.builtbroken.mc.imp.transform.vector.Pos) WorldServer(net.minecraft.world.WorldServer)

Example 9 with WorldServer

use of net.minecraft.world.WorldServer in project ICBM-Classic by BuiltBrokenModding.

the class MissileHoming method launch.

@Override
public void launch(EntityMissile missileObj) {
    if (!missileObj.worldObj.isRemote) {
        WorldServer worldServer = (WorldServer) missileObj.worldObj;
        Entity trackingEntity = worldServer.getEntityByID(missileObj.trackingVar);
        if (trackingEntity != null) {
            if (trackingEntity == missileObj) {
                missileObj.setExplode();
            }
            missileObj.targetVector = new Pos(trackingEntity);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) Pos(com.builtbroken.mc.imp.transform.vector.Pos) WorldServer(net.minecraft.world.WorldServer)

Example 10 with WorldServer

use of net.minecraft.world.WorldServer in project Totemic by TeamTotemic.

the class CeremonyBuffaloDance method effect.

@Override
public void effect(World world, BlockPos pos, CeremonyEffectContext context) {
    if (world.isRemote)
        return;
    getCows(world, pos, 8).stream().limit(2).forEach(cow -> {
        EntityBuffalo buffalo = new EntityBuffalo(world);
        float health = cow.getHealth() / cow.getMaxHealth() * buffalo.getMaxHealth();
        buffalo.setHealth(health);
        buffalo.setGrowingAge(-24000);
        EntityUtil.spawnEntity(world, cow.posX, cow.posY, cow.posZ, buffalo);
        if (cow.getLeashed())
            buffalo.setLeashHolder(cow.getLeashHolder(), true);
        cow.setDead();
        ((WorldServer) world).spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, cow.posX, cow.posY + 1.0, cow.posZ, 24, 0.6D, 0.5D, 0.6D, 1.0D);
    });
}
Also used : EntityBuffalo(pokefenn.totemic.entity.animal.EntityBuffalo) WorldServer(net.minecraft.world.WorldServer)

Aggregations

WorldServer (net.minecraft.world.WorldServer)322 BlockPos (net.minecraft.util.math.BlockPos)96 EntityPlayer (net.minecraft.entity.player.EntityPlayer)63 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)51 ItemStack (net.minecraft.item.ItemStack)48 IMixinWorldServer (org.spongepowered.common.interfaces.world.IMixinWorldServer)48 TileEntity (net.minecraft.tileentity.TileEntity)42 Entity (net.minecraft.entity.Entity)41 IBlockState (net.minecraft.block.state.IBlockState)39 MinecraftServer (net.minecraft.server.MinecraftServer)35 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)31 World (net.minecraft.world.World)29 Block (net.minecraft.block.Block)26 EntityLivingBase (net.minecraft.entity.EntityLivingBase)23 ArrayList (java.util.ArrayList)20 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)18 Nullable (javax.annotation.Nullable)17 PotionEffect (net.minecraft.potion.PotionEffect)16 Chunk (net.minecraft.world.chunk.Chunk)16 World (org.spongepowered.api.world.World)13