use of net.minecraft.network.play.server.SPacketChat in project SpongeCommon by SpongePowered.
the class MixinEntityPlayerMP method sendMessage.
@Override
public void sendMessage(ChatType type, Text message) {
if (this.isFake) {
// Don't bother sending messages to fake players
return;
}
checkNotNull(type, "type");
checkNotNull(message, "message");
ITextComponent component = SpongeTexts.toComponent(message);
if (type == ChatTypes.ACTION_BAR) {
component = SpongeTexts.fixActionBarFormatting(component);
}
this.connection.sendPacket(new SPacketChat(component, (net.minecraft.util.text.ChatType) (Object) type));
}
use of net.minecraft.network.play.server.SPacketChat in project Random-Things by lumien231.
the class FestivalHandler method tick.
public void tick(World worldObj) {
long time = worldObj.getWorldTime();
boolean celebrationTime = time > 14000 & time < 20000;
Iterator<Festival> iterator = currentFestivals.iterator();
while (iterator.hasNext()) {
boolean firework = false;
Festival festival = iterator.next();
if (festival.getState() == STATE.SCHEDULED && celebrationTime) {
festival.setActive();
firework = true;
this.markDirty();
} else if (festival.getState() == STATE.ACTIVE && !celebrationTime) {
iterator.remove();
this.markDirty();
} else if (festival.getState() == STATE.ACTIVE && celebrationTime) {
firework = true;
}
if (firework) {
List<BlockPos> doorPositions = festival.getDoorPositions();
if (time == 14001) {
MessageUtil.sendToAllWatchingPos(worldObj, doorPositions.get(0), new SPacketChat(new TextComponentTranslation("festival.celebrating"), ChatType.SYSTEM));
}
boolean midnight = Math.abs(time - 18000) < 20 * 15;
if (time == 18000) {
for (BlockPos pos : doorPositions) {
if (worldObj.isBlockLoaded(pos) && worldObj.isAnyPlayerWithinRangeAt(pos.getX(), pos.getY(), pos.getZ(), 256)) {
ItemStack rocket = getRandomFirework();
if (!rocket.isEmpty()) {
BlockPos topPos = worldObj.getTopSolidOrLiquidBlock(pos);
EntityFireworkRocket entity = new EntityFireworkRocket(worldObj, topPos.getX() + rng.nextFloat(), topPos.getY() + 1, topPos.getZ() + rng.nextFloat(), rocket);
worldObj.spawnEntity(entity);
}
}
}
} else {
if (!doorPositions.isEmpty() && rng.nextFloat() < (midnight ? 0.1 : 0.05)) {
BlockPos randomPosition = doorPositions.get(rng.nextInt(doorPositions.size()));
if (worldObj.isBlockLoaded(randomPosition) && worldObj.isAnyPlayerWithinRangeAt(randomPosition.getX(), randomPosition.getY(), randomPosition.getZ(), 256)) {
ItemStack rocket = getRandomFirework();
if (!rocket.isEmpty()) {
BlockPos pos = worldObj.getTopSolidOrLiquidBlock(randomPosition);
EntityFireworkRocket entity = new EntityFireworkRocket(worldObj, pos.getX() + rng.nextFloat(), pos.getY() + 1, pos.getZ() + rng.nextFloat(), rocket);
worldObj.spawnEntity(entity);
}
}
}
}
}
}
}
Aggregations