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