mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-20 03:44:23 +01:00
Destruction states will now reset when breaking/replacing the block
This commit is contained in:
parent
24cd6a9a3b
commit
543fd7aee0
3 changed files with 31 additions and 0 deletions
|
@ -5,6 +5,7 @@ import com.minelittlepony.unicopia.network.MsgBlockDestruction;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -49,6 +50,12 @@ public class BlockDestructionManager {
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onBlockChanged(BlockPos pos, BlockState oldState, BlockState newstate) {
|
||||||
|
if (oldState.getBlock() != newstate.getBlock()) {
|
||||||
|
clearBlockDestruction(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void tick() {
|
public void tick() {
|
||||||
synchronized (locker) {
|
synchronized (locker) {
|
||||||
destructions.long2ObjectEntrySet().removeIf(entry -> entry.getValue().tick());
|
destructions.long2ObjectEntrySet().removeIf(entry -> entry.getValue().tick());
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.minelittlepony.unicopia.mixin;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.BlockDestructionManager;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@Mixin(ServerWorld.class)
|
||||||
|
abstract class MixinServerWorld extends World implements StructureWorldAccess {
|
||||||
|
private MixinServerWorld() {super(null, null, null, null, false, false, 0);}
|
||||||
|
|
||||||
|
@Inject(method = "onBlockChanged", at = @At("HEAD"))
|
||||||
|
private void onOnBlockChanged(BlockPos pos, BlockState oldState, BlockState newState, CallbackInfo info) {
|
||||||
|
((BlockDestructionManager.Source)this).getDestructionManager().onBlockChanged(pos, oldState, newState);
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,7 @@
|
||||||
"MixinPlayerEntity",
|
"MixinPlayerEntity",
|
||||||
"MixinProjectileEntity",
|
"MixinProjectileEntity",
|
||||||
"MixinServerPlayerEntity",
|
"MixinServerPlayerEntity",
|
||||||
|
"MixinServerWorld",
|
||||||
"MixinSheepEntity",
|
"MixinSheepEntity",
|
||||||
"MixinShulkerEntity",
|
"MixinShulkerEntity",
|
||||||
"MixinTargetPredicate",
|
"MixinTargetPredicate",
|
||||||
|
|
Loading…
Reference in a new issue