Skip to content

Commit

Permalink
Finalizing some things
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Jan 24, 2024
1 parent 55eb34b commit c31637c
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static Vector3f getMountedHeightOffset(final Entity entity, final Entity
}

if (entity instanceof AbstractHorseEntity abstractHorseEntity) {
if (abstractHorseEntity.lastAngryAnimationProgress > 0.0f) {
if (abstractHorseEntity.lastAngryAnimationProgress > 0.0F) {
return new Vector3f(0, yOffset + 0.15F * abstractHorseEntity.lastAngryAnimationProgress, -0.7F * abstractHorseEntity.lastAngryAnimationProgress);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ private boolean modifyIsSolidBlock(BlockState instance, BlockView blockView, Blo
return false;
}
}

return instance.isSideSolidFullSquare(blockView, blockPos, direction);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public MixinAnvilBlock(Settings settings) {
private boolean viaFabricPlus$requireOriginalShape;

@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
public void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (viaFabricPlus$requireOriginalShape) {
viaFabricPlus$requireOriginalShape = false;
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public MixinEndPortalFrameBlock(Settings settings) {
}

@Inject(method = "getOutlineShape", at = @At(value = "HEAD"), cancellable = true)
private void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
cir.setReturnValue(FRAME_SHAPE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public MixinHopperBlock(Settings settings) {
}

@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
public void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (viaFabricPlus$requireOriginalShape) {
viaFabricPlus$requireOriginalShape = false;
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
Expand All @@ -59,7 +59,7 @@ public void changeOutlineShape(BlockState state, BlockView world, BlockPos pos,
}

@Inject(method = "getRaycastShape", at = @At("HEAD"), cancellable = true)
public void changeRaycastShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir) {
private void changeRaycastShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
cir.setReturnValue(viaFabricPlus$inside_shape_r1_12_2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void updatePassengerPosition(Entity passenger, PositionUpdater positio
final float passengerYaw = passenger.getYaw();

final float deltaDegrees = MathHelper.wrapDegrees(passengerYaw - this.getYaw());
final float clampedDelta = MathHelper.clamp(deltaDegrees, -160.0f, 160.0f);
final float clampedDelta = MathHelper.clamp(deltaDegrees, -160.0F, 160.0F);
passenger.prevYaw += clampedDelta - deltaDegrees;

final float newYaw = passengerYaw + clampedDelta - deltaDegrees;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private boolean disableSprintSneak(Input input) {
@Redirect(method = "tickMovement",
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z")),
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSwimming()Z", ordinal = 0))
private boolean redirectIsSneakingWhileSwimming(ClientPlayerEntity instance) {
private boolean dontAllowSneakingWhileSwimming(ClientPlayerEntity instance) {
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_14_1) && instance.isSwimming();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ private boolean allowInfiniteValues(float f) {
private static double fixVelocityEpsilon(double epsilon) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
return 1E-4;
} else {
return epsilon;
}
return epsilon;
}

@Inject(method = "getRotationVector(FF)Lnet/minecraft/util/math/Vec3d;", at = @At("HEAD"), cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ public abstract class MixinEntityRenderDispatcher {
@Unique
private BoatRenderer1_8 viaFabricPlus$boatRenderer;

@Inject(method = "reload", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
private void createBoatRenderer1_8(ResourceManager manager, CallbackInfo ci, EntityRendererFactory.Context context) {
viaFabricPlus$boatRenderer = new BoatRenderer1_8(context);
}

@SuppressWarnings("unchecked")
@Inject(method = "getRenderer", at = @At("HEAD"), cancellable = true)
private <T extends Entity> void onGetRenderer(T entity, CallbackInfoReturnable<EntityRenderer<? super T>> ci) {
private <T extends Entity> void useBoatRenderer1_8(T entity, CallbackInfoReturnable<EntityRenderer<? super T>> ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && entity instanceof BoatEntity) {
ci.setReturnValue((EntityRenderer<? super T>) viaFabricPlus$boatRenderer);
}
}

@Inject(method = "reload", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
private void onReload(ResourceManager manager, CallbackInfo ci, EntityRendererFactory.Context context) {
viaFabricPlus$boatRenderer = new BoatRenderer1_8(context);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void modifySleepingOffset(AbstractClientPlayerEntity player, float delta
@Redirect(method = "getPositionOffset(Lnet/minecraft/client/network/AbstractClientPlayerEntity;F)Lnet/minecraft/util/math/Vec3d;",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;isInSneakingPose()Z"))
private boolean disableSneakPositionOffset(AbstractClientPlayerEntity player) {
return (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_11_1to1_11_2)) && player.isInSneakingPose();
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_11_1to1_11_2) && player.isInSneakingPose();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@

package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import de.florianmichael.viafabricplus.fixes.data.ItemRegistryDiff;
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.registry.Registries;
import net.minecraft.resource.featuretoggle.FeatureSet;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -39,17 +42,18 @@ public abstract class MixinItemGroup_EntriesImpl {
@Final
private ItemGroup group;

@Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;isEnabled(Lnet/minecraft/resource/featuretoggle/FeatureSet;)Z"))
private boolean removeUnknownItems(Item instance, FeatureSet featureSet) {
@WrapOperation(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;isEnabled(Lnet/minecraft/resource/featuretoggle/FeatureSet;)Z"))
private boolean removeUnknownItems(Item instance, FeatureSet featureSet, Operation<Boolean> original) {
final boolean originalValue = original.call(instance, featureSet);
final int index = GeneralSettings.global().removeNotAvailableItemsFromCreativeTab.getIndex();

if (index == 2 || MinecraftClient.getInstance().isInSingleplayer()) return instance.isEnabled(featureSet);
if (index == 1 && !Registries.ITEM_GROUP.getId(this.group).getNamespace().equals("minecraft")) return instance.isEnabled(featureSet);

if (ItemRegistryDiff.keepItem(instance)) {
return instance.isEnabled(featureSet);
if (index == 2 /* Off */ || MinecraftClient.getInstance().isInSingleplayer()) {
return originalValue;
} else if (index == 1 /* Vanilla only */ && !Registries.ITEM_GROUP.getId(this.group).getNamespace().equals(Identifier.DEFAULT_NAMESPACE)) {
return originalValue;
} else {
return ItemRegistryDiff.keepItem(instance) && originalValue;
}
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public MixinItemPlacementContext(PlayerEntity player, Hand hand, BlockHitResult
}

@Inject(method = "getPlayerLookDirection", at = @At("HEAD"), cancellable = true)
private void getLookDirection1_12_2(CallbackInfoReturnable<Direction> cir) {
private void getPlayerLookDirection1_12_2(CallbackInfoReturnable<Direction> cir) {
final ItemPlacementContext self = (ItemPlacementContext) (Object) this;
final PlayerEntity player = self.getPlayer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ private void copyViaFabricPlusData(CallbackInfoReturnable<ItemStack> cir) {
return OptionalDouble.of(3 + materialBonus);
}
}

return OptionalDouble.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ private List<ItemStack> captureOldItems(List<ItemStack> oldItems) {
private boolean handleWindowClick1_16_5(ClientPlayNetworkHandler instance, Packet<?> packet) throws Exception {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5) && packet instanceof ClickSlotC2SPacket clickSlot) {
ItemStack slotItemBeforeModification;

if (this.viaFabricPlus$shouldBeEmpty(clickSlot.getActionType(), clickSlot.getSlot()))
if (this.viaFabricPlus$shouldBeEmpty(clickSlot.getActionType(), clickSlot.getSlot())) {
slotItemBeforeModification = ItemStack.EMPTY;
else if (clickSlot.getSlot() < 0 || clickSlot.getSlot() >= viaFabricPlus$oldItems.size())
} else if (clickSlot.getSlot() < 0 || clickSlot.getSlot() >= viaFabricPlus$oldItems.size()) {
slotItemBeforeModification = viaFabricPlus$oldCursorStack;
else
} else {
slotItemBeforeModification = viaFabricPlus$oldItems.get(clickSlot.getSlot());
}

final PacketWrapper clickWindowPacket = PacketWrapper.create(ServerboundPackets1_16_2.CLICK_WINDOW, ((IClientConnection) networkHandler.getConnection()).viaFabricPlus$getUserConnection());
clickWindowPacket.write(Type.UNSIGNED_BYTE, (short) clickSlot.getSyncId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@
public abstract class MixinBookEditScreen {

@ModifyConstant(method = "method_27596", constant = @Constant(intValue = 1024))
private int modifyPageLength(int oldVal) {
private int modifyPageLength(int constant) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
return 256;
} else {
return oldVal;
return constant;
}
}

@ModifyConstant(method = "appendNewPage", constant = @Constant(intValue = 100))
private int modifyPageCount(int oldVal) {
private int modifyPageCount(int constant) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
return 50;
} else {
return oldVal;
return constant;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public abstract class MixinAbstractFurnaceScreenHandler {

@Redirect(method = "quickMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/screen/AbstractFurnaceScreenHandler;isSmeltable(Lnet/minecraft/item/ItemStack;)Z"))
private boolean disableShiftClickSmeltingSlot(AbstractFurnaceScreenHandler instance, ItemStack itemStack) {
return this.isSmeltable(itemStack) && !ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_2_1tor1_2_3);
return this.isSmeltable(itemStack) && ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_2_1tor1_2_3);
}

@Redirect(method = "quickMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/screen/AbstractFurnaceScreenHandler;isFuel(Lnet/minecraft/item/ItemStack;)Z"))
private boolean disableShiftClickFuelSlot(AbstractFurnaceScreenHandler instance, ItemStack itemStack) {
return this.isFuel(itemStack) && !ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_2_1tor1_2_3);
return this.isFuel(itemStack) && ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_2_1tor1_2_3);
}

}

0 comments on commit c31637c

Please sign in to comment.