mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-17 16:38:07 +01:00
Better belt breaking
This commit is contained in:
parent
f6937ffb0c
commit
916b187aa8
4 changed files with 62 additions and 11 deletions
|
@ -474,6 +474,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
||||||
BlockPos currentPos = nextSegmentPosition(state, pos, forward);
|
BlockPos currentPos = nextSegmentPosition(state, pos, forward);
|
||||||
if (currentPos == null)
|
if (currentPos == null)
|
||||||
continue;
|
continue;
|
||||||
|
world.sendBlockBreakProgress(currentPos.hashCode(), currentPos, -1);
|
||||||
BlockState currentState = world.getBlockState(currentPos);
|
BlockState currentState = world.getBlockState(currentPos);
|
||||||
if (!AllBlocks.BELT.has(currentState))
|
if (!AllBlocks.BELT.has(currentState))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.simibubi.create.foundation;
|
||||||
|
|
||||||
|
import com.simibubi.create.AllBlocks;
|
||||||
|
import com.simibubi.create.content.contraptions.relays.belt.BeltBlock;
|
||||||
|
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.WorldRenderer;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
public class BreakProgressHook {
|
||||||
|
|
||||||
|
public static void whenBreaking(ClientWorld world, WorldRenderer renderer, int playerEntityId, BlockPos pos, int progress) {
|
||||||
|
if (AllBlocks.BELT.has(world.getBlockState(pos))) {
|
||||||
|
BeltTileEntity belt = (BeltTileEntity) world.getTileEntity(pos);
|
||||||
|
|
||||||
|
for (BlockPos beltPos : BeltBlock.getBeltChain(world, belt.getController())) {
|
||||||
|
renderer.sendBlockBreakProgress(beltPos.hashCode(), beltPos, progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.simibubi.create.foundation.mixin;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.BreakProgressHook;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.WorldRenderer;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
@Mixin(ClientWorld.class)
|
||||||
|
public class BreakProgressMixin {
|
||||||
|
@Shadow
|
||||||
|
@Final
|
||||||
|
private WorldRenderer worldRenderer;
|
||||||
|
private final ClientWorld self = (ClientWorld) (Object) this;
|
||||||
|
|
||||||
|
@Inject(at = @At("HEAD"), method = "sendBlockBreakProgress")
|
||||||
|
private void onBreakProgress(int playerEntityId, BlockPos pos, int progress, CallbackInfo ci) {
|
||||||
|
BreakProgressHook.whenBreaking(self, this.worldRenderer, playerEntityId, pos, progress);
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,16 +5,17 @@
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"refmap": "create.refmap.json",
|
"refmap": "create.refmap.json",
|
||||||
"client": [
|
"client": [
|
||||||
"TileWorldHookMixin",
|
"BreakProgressMixin",
|
||||||
"CancelTileEntityRenderMixin",
|
"CancelTileEntityRenderMixin",
|
||||||
|
"EntityContraptionInteractionMixin",
|
||||||
"FogColorTrackerMixin",
|
"FogColorTrackerMixin",
|
||||||
"LightUpdateMixin",
|
"LightUpdateMixin",
|
||||||
"NetworkLightUpdateMixin",
|
"NetworkLightUpdateMixin",
|
||||||
"RenderHooksMixin",
|
"RenderHooksMixin",
|
||||||
"ShaderCloseMixin",
|
"ShaderCloseMixin",
|
||||||
|
"StoreProjectionMatrixMixin",
|
||||||
"TileRemoveMixin",
|
"TileRemoveMixin",
|
||||||
"EntityContraptionInteractionMixin",
|
"TileWorldHookMixin"
|
||||||
"StoreProjectionMatrixMixin"
|
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|
Loading…
Reference in a new issue