Use the enum! It makes it clearer

This commit is contained in:
Sollace 2019-02-07 13:38:42 +02:00
parent cfa36497b7
commit 91109ba8bb
5 changed files with 18 additions and 7 deletions

View file

@ -62,12 +62,12 @@ public class BlockCloudAnvil extends BlockAnvil implements ICloudBlock {
@Override @Override
public void onEndFalling(World world, BlockPos pos, IBlockState fallingState, IBlockState hitState) { public void onEndFalling(World world, BlockPos pos, IBlockState fallingState, IBlockState hitState) {
WorldEvent.ENTITY_TAKEOFF.play(world, pos, 0); WorldEvent.ENTITY_TAKEOFF.play(world, pos);
} }
@Override @Override
public void onBroken(World world, BlockPos pos) { public void onBroken(World world, BlockPos pos) {
WorldEvent.ENTITY_TAKEOFF.play(world, pos, 0); WorldEvent.ENTITY_TAKEOFF.play(world, pos);
} }
@Override @Override

View file

@ -86,10 +86,10 @@ public class PowerGrow implements IPower<Location> {
if (g.canGrow(w, pos, state, w.isRemote) && g.canUseBonemeal(w, w.rand, pos, state)) { if (g.canGrow(w, pos, state, w.isRemote) && g.canUseBonemeal(w, w.rand, pos, state)) {
if (ItemDye.applyBonemeal(new ItemStack(Items.DYE, 1), w, pos)) { if (ItemDye.applyBonemeal(new ItemStack(Items.DYE, 1), w, pos)) {
WorldEvent.BONEMEAL.play(w, pos, 0); WorldEvent.BONEMEAL.play(w, pos);
if (g instanceof BlockDoublePlant) { if (g instanceof BlockDoublePlant) {
WorldEvent.BONEMEAL.play(w, pos.up(), 0); WorldEvent.BONEMEAL.play(w, pos.up());
} }
} }

View file

@ -15,6 +15,7 @@ import com.minelittlepony.unicopia.player.PlayerSpeciesList;
import com.minelittlepony.unicopia.power.data.Location; import com.minelittlepony.unicopia.power.data.Location;
import com.minelittlepony.util.MagicalDamageSource; import com.minelittlepony.util.MagicalDamageSource;
import com.minelittlepony.util.PosHelper; import com.minelittlepony.util.PosHelper;
import com.minelittlepony.util.WorldEvent;
import com.minelittlepony.util.shape.IShape; import com.minelittlepony.util.shape.IShape;
import com.minelittlepony.util.shape.Sphere; import com.minelittlepony.util.shape.Sphere;
import com.minelittlepony.util.vector.VecHelper; import com.minelittlepony.util.vector.VecHelper;
@ -181,7 +182,7 @@ public class PowerStomp implements IPower<PowerStomp.Data> {
if (state.getBlock() != Blocks.AIR) { if (state.getBlock() != Blocks.AIR) {
if (w.getBlockState(pos.up()).getBlock() == Blocks.AIR) { if (w.getBlockState(pos.up()).getBlock() == Blocks.AIR) {
w.playEvent(2001, pos, Block.getStateId(state)); WorldEvent.DESTROY_BLOCK.play(w, pos, state);
} }
} }
} }
@ -317,7 +318,7 @@ public class PowerStomp implements IPower<PowerStomp.Data> {
IBlockState state = w.getBlockState(pos); IBlockState state = w.getBlockState(pos);
if (state.getBlock() instanceof BlockLeaves && w.getBlockState(pos.down()).getMaterial() == Material.AIR) { if (state.getBlock() instanceof BlockLeaves && w.getBlockState(pos.down()).getMaterial() == Material.AIR) {
w.playEvent(2001, pos, Block.getStateId(state)); WorldEvent.DESTROY_BLOCK.play(w, pos, state);
EntityItem item = new EntityItem(w); EntityItem item = new EntityItem(w);
item.setPosition(pos.getX() + 0.5, pos.getY() - 0.5, pos.getZ() + 0.5); item.setPosition(pos.getX() + 0.5, pos.getY() - 0.5, pos.getZ() + 0.5);

View file

@ -96,7 +96,7 @@ public class SpellNecromancy extends AbstractSpell.RangedAreaSpell {
} }
zombie.motionY += 0.3F; zombie.motionY += 0.3F;
source.getWorld().playEvent(WorldEvent.DOOR_BROKEN.getId(), zombie.getPosition(), 0); WorldEvent.DOOR_BROKEN.play(source.getWorld(), zombie.getPosition());
source.getWorld().spawnEntity(zombie); source.getWorld().spawnEntity(zombie);
} }

View file

@ -1,5 +1,7 @@
package com.minelittlepony.util; package com.minelittlepony.util;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -72,6 +74,14 @@ public enum WorldEvent {
return id; return id;
} }
public void play(World world, BlockPos pos, IBlockState state) {
play(world, pos, Block.getStateId(state));
}
public void play(World world, BlockPos pos) {
play(world, pos, 0);
}
public void play(World world, BlockPos pos, int data) { public void play(World world, BlockPos pos, int data) {
world.playEvent(getId(), pos, data); world.playEvent(getId(), pos, data);
} }