mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 01:49:30 +00:00
fix particles & sounds
This commit is contained in:
@@ -5,6 +5,7 @@ import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
|
||||
import net.momirealms.craftengine.bukkit.plugin.user.BukkitServerPlayer;
|
||||
import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||
import net.momirealms.craftengine.bukkit.util.Reflections;
|
||||
import net.momirealms.craftengine.bukkit.world.BukkitWorld;
|
||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||
@@ -184,8 +185,7 @@ public final class CraftEngineBlocks {
|
||||
world.playBlockSound(vec3d, state.sounds().breakSound());
|
||||
}
|
||||
if (sendParticles) {
|
||||
// TODO Particles. needs world event
|
||||
//ParticleUtils.addBlockBreakParticles(block.getWorld(), LocationUtils.toBlockPos(location), state.customBlockState().handle());
|
||||
FastNMS.INSTANCE.method$Level$levelEvent(world.serverWorld(), 2001, LocationUtils.toBlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), state.customBlockState().registryId());
|
||||
}
|
||||
block.setType(Material.AIR, applyPhysics);
|
||||
return true;
|
||||
|
||||
@@ -63,7 +63,8 @@ public class BushBlockBehavior extends BukkitBlockBehavior {
|
||||
blockPos = args[4];
|
||||
}
|
||||
if (!canSurvive(thisBlock, state, level, blockPos)) {
|
||||
ImmutableBlockState previousState = BukkitBlockManager.instance().getImmutableBlockState(BlockStateUtils.blockStateToId(state));
|
||||
int stateId = BlockStateUtils.blockStateToId(state);
|
||||
ImmutableBlockState previousState = BukkitBlockManager.instance().getImmutableBlockState(stateId);
|
||||
if (previousState != null && !previousState.isEmpty()) {
|
||||
ContextHolder.Builder builder = ContextHolder.builder();
|
||||
BlockPos pos = LocationUtils.fromBlockPos(blockPos);
|
||||
@@ -74,6 +75,8 @@ public class BushBlockBehavior extends BukkitBlockBehavior {
|
||||
for (Item<Object> item : previousState.getDrops(builder, world)) {
|
||||
world.dropItemNaturally(vec3d, item);
|
||||
}
|
||||
world.playBlockSound(vec3d, previousState.sounds().breakSound());
|
||||
FastNMS.INSTANCE.method$Level$levelEvent(level, 2001, blockPos, stateId);
|
||||
}
|
||||
return Reflections.method$Block$defaultBlockState.invoke(Reflections.instance$Blocks$AIR);
|
||||
}
|
||||
|
||||
@@ -55,19 +55,21 @@ public class SugarCaneBlockBehavior extends BushBlockBehavior {
|
||||
Object level = args[1];
|
||||
Object blockPos = args[2];
|
||||
if (!canSurvive(thisBlock, blockState, level, blockPos)) {
|
||||
ImmutableBlockState currentState = BukkitBlockManager.instance().getImmutableBlockState(BlockStateUtils.blockStateToId(blockState));
|
||||
int stateId = BlockStateUtils.blockStateToId(blockState);
|
||||
ImmutableBlockState currentState = BukkitBlockManager.instance().getImmutableBlockState(stateId);
|
||||
if (currentState != null && !currentState.isEmpty()) {
|
||||
// break the sugar cane
|
||||
Reflections.method$Level$removeBlock.invoke(level, blockPos, false);
|
||||
Vec3d vec3d = Vec3d.atCenterOf(LocationUtils.fromBlockPos(blockPos));
|
||||
net.momirealms.craftengine.core.world.World world = new BukkitWorld(FastNMS.INSTANCE.method$Level$getCraftWorld(level));
|
||||
// TODO client side particles?
|
||||
ContextHolder.Builder builder = ContextHolder.builder()
|
||||
.withParameter(LootParameters.LOCATION, vec3d)
|
||||
.withParameter(LootParameters.WORLD, world);
|
||||
for (Item<Object> item : currentState.getDrops(builder, world)) {
|
||||
world.dropItemNaturally(vec3d, item);
|
||||
}
|
||||
world.playBlockSound(vec3d, currentState.sounds().breakSound());
|
||||
FastNMS.INSTANCE.method$Level$levelEvent(level, 2001, blockPos, stateId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ mojang_brigadier_version=1.0.18
|
||||
byte_buddy_version=1.15.11
|
||||
snake_yaml_version=2.3
|
||||
anti_grief_version=0.13
|
||||
nms_helper_version=0.33
|
||||
nms_helper_version=0.34
|
||||
# Ignite Dependencies
|
||||
mixinextras_version=0.4.1
|
||||
mixin_version=0.15.2+mixin.0.8.7
|
||||
|
||||
Reference in New Issue
Block a user