Remove the old WorldEvent util. This is no longer needed in 1.17

This commit is contained in:
Sollace 2021-08-25 14:22:11 +02:00
parent 96d2e7b1f9
commit e9e238dd3d
9 changed files with 22 additions and 99 deletions

View file

@ -13,7 +13,6 @@ import com.minelittlepony.unicopia.ability.data.tree.TreeType;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.RayTraceHelper; import com.minelittlepony.unicopia.util.RayTraceHelper;
import com.minelittlepony.unicopia.util.WorldEvent;
import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere; import com.minelittlepony.unicopia.util.shape.Sphere;
@ -31,6 +30,7 @@ import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box; import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.WorldEvents;
/** /**
* Earth Pony kicking ability * Earth Pony kicking ability
@ -164,7 +164,7 @@ public class EarthPonyKickAbility implements Ability<Pos> {
if (world.getBlockState(position.down()).isAir()) { if (world.getBlockState(position.down()).isAir()) {
ItemStack stack = tree.pickRandomStack(state); ItemStack stack = tree.pickRandomStack(state);
if (!stack.isEmpty()) { if (!stack.isEmpty()) {
WorldEvent.play(WorldEvent.DESTROY_BLOCK, world, position, state); world.syncWorldEvent(WorldEvents.BLOCK_BROKEN, position, Block.getRawIdFromState(state));
capturedDrops.add(new ItemEntity(world, capturedDrops.add(new ItemEntity(world,
position.getX() + world.random.nextFloat(), position.getX() + world.random.nextFloat(),

View file

@ -11,7 +11,8 @@ import com.minelittlepony.unicopia.particle.ParticleUtils;
import com.minelittlepony.unicopia.particle.UParticles; import com.minelittlepony.unicopia.particle.UParticles;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.WorldEvent;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
@ -22,6 +23,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box; import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldEvents;
/** /**
* Earth Pony stomping ability * Earth Pony stomping ability
@ -162,7 +164,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
if (destr.damageBlock(pos, damage) >= BlockDestructionManager.MAX_DAMAGE) { if (destr.damageBlock(pos, damage) >= BlockDestructionManager.MAX_DAMAGE) {
w.breakBlock(pos, true); w.breakBlock(pos, true);
} else { } else {
WorldEvent.play(WorldEvent.DESTROY_BLOCK, w, pos, state); w.syncWorldEvent(WorldEvents.BLOCK_BROKEN, pos, Block.getRawIdFromState(state));
} }
} }
} }

View file

@ -6,7 +6,6 @@ import java.util.List;
import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.entity.EntityReference; import com.minelittlepony.unicopia.entity.EntityReference;
import com.minelittlepony.unicopia.util.Weighted; import com.minelittlepony.unicopia.util.Weighted;
import com.minelittlepony.unicopia.util.WorldEvent;
import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere; import com.minelittlepony.unicopia.util.shape.Sphere;
@ -19,6 +18,7 @@ import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.Difficulty; import net.minecraft.world.Difficulty;
import net.minecraft.world.WorldEvents;
public class NecromancySpell extends AbstractPlacedSpell { public class NecromancySpell extends AbstractPlacedSpell {
@ -106,7 +106,7 @@ public class NecromancySpell extends AbstractPlacedSpell {
zombie.updatePositionAndAngles(pos.x, pos.y, pos.z, 0, 0); zombie.updatePositionAndAngles(pos.x, pos.y, pos.z, 0, 0);
zombie.setVelocity(0, 0.3, 0); zombie.setVelocity(0, 0.3, 0);
source.getWorld().syncWorldEvent(WorldEvent.ZOMBIE_BREAK_WOODEN_DOOR, zombie.getBlockPos(), 0); source.getWorld().syncWorldEvent(WorldEvents.ZOMBIE_BREAKS_WOODEN_DOOR, zombie.getBlockPos(), 0);
source.getWorld().spawnEntity(zombie); source.getWorld().spawnEntity(zombie);

View file

@ -68,6 +68,7 @@ public interface UTradeOffers {
return (e, rng) -> new TradeOffer(new ItemStack(item.getRandom(rng), count), new ItemStack(returnItem, returnCount), maxUses, experience, priceChange); return (e, rng) -> new TradeOffer(new ItemStack(item.getRandom(rng), count), new ItemStack(returnItem, returnCount), maxUses, experience, priceChange);
} }
@SuppressWarnings("unused")
private static TradeOffers.Factory buy(Tag<Item> item, int count, Tag<Item> returnItem, int returnCount, int maxUses, int experience, float priceChange) { private static TradeOffers.Factory buy(Tag<Item> item, int count, Tag<Item> returnItem, int returnCount, int maxUses, int experience, float priceChange) {
return (e, rng) -> new TradeOffer(new ItemStack(item.getRandom(rng), count), new ItemStack(returnItem.getRandom(rng), returnCount), maxUses, experience, priceChange); return (e, rng) -> new TradeOffer(new ItemStack(item.getRandom(rng), count), new ItemStack(returnItem.getRandom(rng), returnCount), maxUses, experience, priceChange);
} }

View file

@ -5,8 +5,8 @@ import java.util.Random;
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell; import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.mixin.MixinSheepEntity; import com.minelittlepony.unicopia.mixin.MixinSheepEntity;
import com.minelittlepony.unicopia.util.WorldEvent;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.ItemEntity; import net.minecraft.entity.ItemEntity;
@ -15,6 +15,7 @@ import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldEvents;
public class SheepBehaviour extends EntityBehaviour<SheepEntity> { public class SheepBehaviour extends EntityBehaviour<SheepEntity> {
@Override @Override
@ -32,7 +33,7 @@ public class SheepBehaviour extends EntityBehaviour<SheepEntity> {
} }
} else { } else {
if (entity.isSheared() && grass) { if (entity.isSheared() && grass) {
WorldEvent.play(WorldEvent.DESTROY_BLOCK, entity.world, pos, state); entity.world.syncWorldEvent(WorldEvents.BLOCK_BROKEN, pos, Block.getRawIdFromState(state));
entity.world.setBlockState(pos, Blocks.DIRT.getDefaultState(), 2); entity.world.setBlockState(pos, Blocks.DIRT.getDefaultState(), 2);
entity.onEatingGrass(); entity.onEatingGrass();

View file

@ -3,11 +3,12 @@ package com.minelittlepony.unicopia.entity.behaviour;
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell; import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.block.state.StateMaps; import com.minelittlepony.unicopia.block.state.StateMaps;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.WorldEvent;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.mob.SilverfishEntity; import net.minecraft.entity.mob.SilverfishEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldEvents;
public class SilverfishBehaviour extends EntityBehaviour<SilverfishEntity> { public class SilverfishBehaviour extends EntityBehaviour<SilverfishEntity> {
@Override @Override
@ -17,7 +18,7 @@ public class SilverfishBehaviour extends EntityBehaviour<SilverfishEntity> {
BlockState state = entity.world.getBlockState(pos); BlockState state = entity.world.getBlockState(pos);
if (StateMaps.SILVERFISH_AFFECTED.convert(entity.world, pos)) { if (StateMaps.SILVERFISH_AFFECTED.convert(entity.world, pos)) {
WorldEvent.play(WorldEvent.DESTROY_BLOCK, entity.world, pos, state); entity.world.syncWorldEvent(WorldEvents.BLOCK_BROKEN, pos, Block.getRawIdFromState(state));
} }
} }
} }

View file

@ -2,8 +2,8 @@ package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.entity.IItemEntity; import com.minelittlepony.unicopia.entity.IItemEntity;
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity; import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
import com.minelittlepony.unicopia.util.WorldEvent;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.attribute.EntityAttributeInstance; import net.minecraft.entity.attribute.EntityAttributeInstance;
@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.world.WorldEvents;
public class FilledJarItem extends JarItem implements ChameleonItem { public class FilledJarItem extends JarItem implements ChameleonItem {
@ -52,7 +53,7 @@ public class FilledJarItem extends JarItem implements ChameleonItem {
ItemStack stack = getAppearanceStack(projectile.getStack()); ItemStack stack = getAppearanceStack(projectile.getStack());
stack.damage(1, projectile.world.random, null); stack.damage(1, projectile.world.random, null);
projectile.dropStack(stack); projectile.dropStack(stack);
WorldEvent.play(WorldEvent.DESTROY_BLOCK, projectile.world, projectile.getBlockPos(), Blocks.GLASS.getDefaultState()); projectile.world.syncWorldEvent(WorldEvents.BLOCK_BROKEN, projectile.getBlockPos(), Block.getRawIdFromState(Blocks.GLASS.getDefaultState()));
} }
public ItemStack withContents(ItemStack contents) { public ItemStack withContents(ItemStack contents) {

View file

@ -5,8 +5,8 @@ import com.minelittlepony.unicopia.entity.ItemImpl;
import com.minelittlepony.unicopia.particle.UParticles; import com.minelittlepony.unicopia.particle.UParticles;
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity; import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
import com.minelittlepony.unicopia.projectile.ProjectileDelegate; import com.minelittlepony.unicopia.projectile.ProjectileDelegate;
import com.minelittlepony.unicopia.util.WorldEvent;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -26,6 +26,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult; import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldEvents;
import net.minecraft.world.level.ServerWorldProperties; import net.minecraft.world.level.ServerWorldProperties;
public class JarItem extends Item implements ProjectileDelegate, ItemImpl.TickableItem { public class JarItem extends Item implements ProjectileDelegate, ItemImpl.TickableItem {
@ -139,7 +140,7 @@ public class JarItem extends Item implements ProjectileDelegate, ItemImpl.Tickab
} }
if (rain || thunder) { if (rain || thunder) {
projectile.world.syncWorldEvent(WorldEvent.PROJECTILE_HIT, projectile.getBlockPos(), thunder ? 0x888888 : 0xF8F8F8); projectile.world.syncWorldEvent(WorldEvents.SPLASH_POTION_SPLASHED, projectile.getBlockPos(), thunder ? 0x888888 : 0xF8F8F8);
for (int i = projectile.world.random.nextInt(3) + 1; i >= 0; i--) { for (int i = projectile.world.random.nextInt(3) + 1; i >= 0; i--) {
projectile.world.addParticle(UParticles.CLOUDS_ESCAPING, true, projectile.world.addParticle(UParticles.CLOUDS_ESCAPING, true,
@ -151,6 +152,6 @@ public class JarItem extends Item implements ProjectileDelegate, ItemImpl.Tickab
} }
} }
WorldEvent.play(WorldEvent.DESTROY_BLOCK, projectile.world, projectile.getBlockPos(), Blocks.GLASS.getDefaultState()); projectile.world.syncWorldEvent(WorldEvents.BLOCK_BROKEN, projectile.getBlockPos(), Block.getRawIdFromState(Blocks.GLASS.getDefaultState()));
} }
} }

View file

@ -1,84 +0,0 @@
package com.minelittlepony.unicopia.util;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess;
/**
* All of the Auxiliary effects used in minecraft for World.playGlobalEvent
*/
public interface WorldEvent {
int
DISPENSER_SUCCESS = 1000,
DISPENSER_FAIL = 1001,
DISPENSER_LAUNCH = 1002,
ENDER_EYE_LAUNCH = 1003,
FIREWORKS_ROCKET_SHOOT = 1004,
IRON_DOOR_OPEN = 1005,
WOODEN_DOOR_OPEN = 1006,
WOODEN_TRAPDOOR_OPEN = 1007,
FENCE_GATE_OPEN = 1008,
FIRE_EXTINGUISH = 1009,
MUSIC_DISC_PLAY = 1010,
IRON_DOOR_CLOSE = 1011,
WOODEN_DOOR_CLOSE = 1012,
WOODEN_TRAPDOOR_CLOSE = 1013,
FENCE_GATE_CLOSE = 1014,
GHAST_WARN = 1015,
GHAST_SHOOT = 1016,
ENDER_DRAGON_SHOOT = 1017,
BLAZE_SHOOT = 1018,
ZOMBIE_ATTACK_WOODEN_DOOR = 1019,
ZOMBIE_ATTACK_IRON_DOOR = 1020,
ZOMBIE_BREAK_WOODEN_DOOR = 1021,
WITHER_BREAK_BLOCK = 1022,
WITHER_SHOOT = 1024,
BAT_TAKEOFF = 1025,
ZOMBIE_INFECT = 1026,
ZOMBIE_VILLAGER_CONVERTED = 1027,
ANVIL_DESTROY = 1029,
ANVIL_USE = 1030,
ANVIL_LAND = 1031,
PORTAL_TRAVEL = 1032,
CHORUS_FLOWER_GROW = 1033,
CHORUS_FLOWER_DEATH = 1034,
BREWING_STAND_BREW = 1035,
IRON_TRAPDOOR_CLOSE = 1036,
IRON_TRAPDOOR_OPEN = 1037,
PHANTOM_BITE = 1039,
ZOMBIE_CONVERTED_TO_DROWNED = 1040,
HUSK_CONVERTED_TO_ZOMBIE = 1041,
GRINDSTONE_USE = 1042,
BOOK_PAGE_TURN = 2043,
SMITHING_TABLE_USE = 1044,
COMPOSTER_COMPOST = 1500,
LAVA_EXTINGUISH = 1501,
REDSTONE_TORCH_BURNOUT = 1502,
END_PORTAL_FRAME_FILL = 1503,
DISPENSER_PARTICLES = 2000,
DESTROY_BLOCK = 2001,
XP_POP = 2002, PROJECTILE_HIT = 2002,
EYE_OF_ENDER = 2003,
MOB_SPAWNED = 2004,
BONEMEAL = 2005,
DRAGON_BREATH = 2006,
POTION_INSTANT = 2007,
ENDER_DRAGON_ATTACK = 2008,
SPONGE_SUCK = 2009,
ENDER_DRAGON_DEFEATED = 3000,
ENDER_DRAGON_GROWL = 3001,
UNKNOWN = 0;
static void play(int event, WorldAccess world, BlockPos pos, BlockState state) {
world.syncWorldEvent(event, pos, Block.getRawIdFromState(state));
}
static void play(int event, WorldAccess world, BlockPos pos) {
world.syncWorldEvent(event, pos, 0);
}
}