mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-02-23 02:51:34 +01:00
Fixed mining speeds in <= 1.4.7
This commit is contained in:
parent
5d1f034182
commit
a8282d7b45
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/MrLookAtMe (EnZaXD) and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.block;
|
||||
|
||||
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(AbstractBlock.class)
|
||||
public class MixinAbstractBlock {
|
||||
|
||||
@Inject(method = "calcBlockBreakingDelta", at = @At("HEAD"), cancellable = true)
|
||||
public void fixLegacyMiningSpeed(BlockState state, PlayerEntity player, BlockView world, BlockPos pos, CallbackInfoReturnable<Float> cir) {
|
||||
if (DebugSettings.getClassWrapper().legacyMiningSpeeds.getValue()) {
|
||||
final float hardness = state.getHardness(world, pos);
|
||||
if (hardness == -1.0F) {
|
||||
cir.setReturnValue(0.0F);
|
||||
} else {
|
||||
if (!player.canHarvest(state)) {
|
||||
cir.setReturnValue(1.0F / hardness / 100F);
|
||||
} else {
|
||||
cir.setReturnValue(player.getBlockBreakingSpeed(state) / hardness / 30F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -48,6 +48,9 @@ public class DebugSettings extends SettingGroup {
|
||||
public final ProtocolSyncBooleanSetting replaceSneaking = new ProtocolSyncBooleanSetting(this, "Replace sneaking", ProtocolRange.andOlder(ProtocolVersion.v1_7_6));
|
||||
public final ProtocolSyncBooleanSetting longSneaking = new ProtocolSyncBooleanSetting(this, "Long sneaking", ProtocolRange.andOlder(ProtocolVersion.v1_7_6));
|
||||
|
||||
// r1_5tor1_5_1 -> r1_4_6tor1_4_7
|
||||
public final ProtocolSyncBooleanSetting legacyMiningSpeeds = new ProtocolSyncBooleanSetting(this, "Legacy mining speeds", ProtocolRange.andOlder(LegacyProtocolVersion.r1_4_6tor1_4_7));
|
||||
|
||||
public DebugSettings() {
|
||||
super("Debug");
|
||||
}
|
||||
|
@ -69,6 +69,7 @@
|
||||
"fixes.entity.MixinPlayerEntity",
|
||||
"fixes.entity.MixinSquidEntity",
|
||||
"fixes.entity.MixinVexEntity",
|
||||
"fixes.entity.MixinWolfEntity",
|
||||
"fixes.input.MixinKeyboard",
|
||||
"fixes.input.MixinKeyboardInput",
|
||||
"fixes.input.MixinMouse",
|
||||
@ -138,10 +139,12 @@
|
||||
"fixes.viaversion.protocol1_9to1_8.MixinEntityTracker1_9",
|
||||
"fixes.viaversion.protocol1_9to1_8.MixinMetadataRewriter1_9To1_8",
|
||||
"fixes.viaversion.protocol1_9to1_8.MixinMovementTracker",
|
||||
"fixes.viaversion.protocol1_9to1_8.MixinViaIdleThread",
|
||||
"fixes.entity.MixinWolfEntity"
|
||||
"fixes.viaversion.protocol1_9to1_8.MixinViaIdleThread"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
},
|
||||
"mixins": [
|
||||
"fixes.block.MixinAbstractBlock"
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user