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;
}
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);
}
}
}
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));
}
}
}
}
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);
}
}
}
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);
});
}
Aggregations