use of net.minecraft.world.effect.MobEffectInstance in project SpongeCommon by SpongePowered.
the class ServerPlayerMixin method impl$postPortalForceChangeTasks.
@Override
protected final void impl$postPortalForceChangeTasks(final Entity entity, final net.minecraft.server.level.ServerLevel targetWorld, final boolean isNetherPortal) {
// Standard vanilla processing
this.gameMode.setLevel(targetWorld);
this.connection.send(new ClientboundPlayerAbilitiesPacket(this.abilities));
final PlayerList playerlist = this.server.getPlayerList();
playerlist.sendLevelInfo((net.minecraft.server.level.ServerPlayer) (Object) this, targetWorld);
playerlist.sendAllPlayerInfo((net.minecraft.server.level.ServerPlayer) (Object) this);
// Sponge Start: teleport here after all data is sent to avoid any potential "stuttering" due to slow packets.
final net.minecraft.world.phys.Vec3 finalPos = this.shadow$position();
this.shadow$moveTo(finalPos.x, finalPos.y, finalPos.z);
for (final MobEffectInstance effectinstance : this.shadow$getActiveEffects()) {
this.connection.send(new ClientboundUpdateMobEffectPacket(this.shadow$getId(), effectinstance));
}
if (isNetherPortal) {
// Sponge: only play the sound if we've got a vanilla teleporter that reports a nether portal
this.connection.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false));
}
// Sponge: end if
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
}
use of net.minecraft.world.effect.MobEffectInstance in project Tropicraft by Tropicraft.
the class EntityKoaBase method mobInteract.
/*private static final Field _buyingPlayer = Util.findField(VillagerEntity.class, "field_70962_h", "buyingPlayer");
private static final Field _buyingList = Util.findField(VillagerEntity.class, "field_70963_i", "buyingList");*/
@Override
public InteractionResult mobInteract(Player player, InteractionHand hand) {
if (hand != InteractionHand.MAIN_HAND)
return InteractionResult.PASS;
InteractionResult ret = InteractionResult.PASS;
try {
boolean doTrade = true;
if (!this.level.isClientSide) {
ItemStack stack = player.getItemInHand(InteractionHand.MAIN_HAND);
if (!stack.isEmpty() && stack.getItem() == TropicraftItems.POISON_FROG_SKIN.get()) {
doTrade = false;
// drug the koa and make him forget everything
dbg("koa drugged, zapping memory");
if (!player.isCreative()) {
stack.shrink(1);
}
zapMemory();
druggedTime += 20 * 60 * 2;
addEffect(new MobEffectInstance(MobEffects.CONFUSION, druggedTime));
findAndSetDrums(true);
}
if (doTrade) {
// Make the super method think this villager is already trading, to block the GUI from opening
// _buyingPlayer.set(this, player);
ret = super.mobInteract(player, hand);
// _buyingPlayer.set(this, null);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return ret;
}
use of net.minecraft.world.effect.MobEffectInstance in project Tropicraft by Tropicraft.
the class PoisonBlotEntity method onHit.
@Override
protected void onHit(HitResult result) {
if (result.getType() == HitResult.Type.ENTITY) {
final Entity entity = ((EntityHitResult) result).getEntity();
if (entity instanceof Player) {
Player player = (Player) entity;
player.addEffect(new MobEffectInstance(MobEffects.POISON, 12 * 20, 0));
remove(RemovalReason.DISCARDED);
}
}
}
use of net.minecraft.world.effect.MobEffectInstance in project Tropicraft by Tropicraft.
the class BlowGunItem method getProjectile.
public static ItemStack getProjectile() {
ItemStack itemStack = new ItemStack(Items.TIPPED_ARROW);
itemStack = PotionUtils.setCustomEffects(itemStack, ImmutableList.of(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 3 * 20, 20)));
return itemStack;
}
use of net.minecraft.world.effect.MobEffectInstance in project SpongeCommon by SpongePowered.
the class PotionItemStackData method register.
// @formatter:off
public static void register(final DataProviderRegistrator registrator) {
registrator.asMutable(ItemStack.class).create(Keys.COLOR).get(h -> Color.ofRgb(PotionUtils.getColor(h))).set((h, v) -> {
final CompoundTag tag = h.getOrCreateTag();
tag.putInt(Constants.Item.CUSTOM_POTION_COLOR, v.rgb());
}).delete(h -> h.removeTagKey(Constants.Item.CUSTOM_POTION_COLOR)).supports(h -> h.getItem() == Items.POTION || h.getItem() == Items.SPLASH_POTION || h.getItem() == Items.LINGERING_POTION).create(Keys.POTION_EFFECTS).get(h -> {
final List<MobEffectInstance> effects = PotionUtils.getMobEffects(h);
return effects.isEmpty() ? null : ImmutableList.copyOf((List<PotionEffect>) (Object) effects);
}).set((h, v) -> {
final CompoundTag tag = h.getOrCreateTag();
final ListTag list = v.stream().map(effect -> {
final CompoundTag potionTag = new CompoundTag();
((MobEffectInstance) effect).save(potionTag);
return potionTag;
}).collect(NBTCollectors.toTagList());
tag.put(Constants.Item.CUSTOM_POTION_EFFECTS, list);
}).delete(h -> h.removeTagKey(Constants.Item.CUSTOM_POTION_EFFECTS)).supports(h -> h.getItem() == Items.POTION || h.getItem() == Items.SPLASH_POTION || h.getItem() == Items.LINGERING_POTION || h.getItem() == Items.TIPPED_ARROW).create(Keys.POTION_TYPE).get(h -> (PotionType) PotionUtils.getPotion(h)).set((h, v) -> {
h.getOrCreateTag();
PotionUtils.setPotion(h, (Potion) v);
}).delete(h -> {
if (h.hasTag()) {
PotionUtils.setPotion(h, Potions.EMPTY);
}
}).supports(h -> h.getItem() == Items.POTION || h.getItem() == Items.SPLASH_POTION || h.getItem() == Items.LINGERING_POTION || h.getItem() == Items.TIPPED_ARROW);
}
Aggregations