Skip to content

Commit

Permalink
Start update to 1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Oct 22, 2024
1 parent 2cb50a1 commit 9fc55d6
Show file tree
Hide file tree
Showing 37 changed files with 146 additions and 186 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ maven_version=3.4.9-SNAPSHOT
maven_description=Fabric mod to connect to EVERY Minecraft server version (Release, Beta, Alpha, Classic, Snapshots, Bedrock) with QoL fixes to the gameplay

# Minecraft/Fabric
minecraft_version=1.21.1
yarn_version=1.21.1+build.3
minecraft_version=1.21.2
yarn_version=1.21.2+build.1
loader_version=0.16.7
fabric_api_version=0.105.0+1.21.1
fabric_api_version=0.106.1+1.21.2

# Set to empty to use the Minecraft version above
supported_versions=>=1.21 <=1.21.1
supported_versions=1.21.2
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ EntityType.OCELOT, linkedHashMap(
ProtocolVersion.v1_7_6, EntityDimensionsBuilder.create(EntityType.OCELOT).withChangingDimensions(0.6F, 0.8F).build(),
ProtocolVersion.v1_8, EntityType.OCELOT.getDimensions()
),
EntityType.BOAT, linkedHashMap(
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.BOAT).withChangingDimensions(1.5F, 0.6F).build(),
ProtocolVersion.v1_9, EntityType.BOAT.getDimensions()
EntityType.OAK_BOAT, linkedHashMap(
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.OAK_BOAT).withChangingDimensions(1.5F, 0.6F).build(),
ProtocolVersion.v1_9, EntityType.OAK_BOAT.getDimensions()
),
EntityType.CREEPER, linkedHashMap(
ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.CREEPER).withChangingDimensions(0.6F, 1.8F).build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.SpecialCraftingRecipe;
import net.minecraft.recipe.SpecialRecipeSerializer;
import net.minecraft.recipe.book.CraftingRecipeCategory;
import net.minecraft.recipe.input.CraftingRecipeInput;
import net.minecraft.registry.RegistryKeys;
Expand All @@ -48,7 +47,7 @@ public AddBannerPatternRecipe(CraftingRecipeCategory craftingRecipeCategory) {
@Override
public boolean matches(CraftingRecipeInput inv, World world) {
boolean foundBanner = false;
for (int i = 0; i < inv.getSize(); i++) {
for (int i = 0; i < inv.size(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (stack.getItem() instanceof BannerItem) {
if (foundBanner)
Expand All @@ -65,7 +64,7 @@ public boolean matches(CraftingRecipeInput inv, World world) {
public ItemStack craft(CraftingRecipeInput inv, RegistryWrapper.WrapperLookup lookup) {
ItemStack result = ItemStack.EMPTY;

for (int i = 0; i < inv.getSize(); i++) {
for (int i = 0; i < inv.size(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (!stack.isEmpty() && stack.getItem() instanceof BannerItem) {
result = stack.copy();
Expand All @@ -76,9 +75,9 @@ public ItemStack craft(CraftingRecipeInput inv, RegistryWrapper.WrapperLookup lo

final BannerPattern_1_13_2 pattern = getBannerPattern(inv);
if (pattern != null) {
final var patternKey = lookup.getWrapperOrThrow(RegistryKeys.BANNER_PATTERN).getOrThrow(pattern.getKey());
final var patternKey = lookup.getOrThrow(RegistryKeys.BANNER_PATTERN).getOrThrow(pattern.getKey());
DyeColor color = ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2) ? DyeColor.BLACK : DyeColor.WHITE;
for (int i = 0; i < inv.getSize(); i++) {
for (int i = 0; i < inv.size(); i++) {
Item item = inv.getStackInSlot(i).getItem();
if (item instanceof DyeItem dyeItem) {
color = dyeItem.getColor();
Expand All @@ -96,11 +95,6 @@ public ItemStack craft(CraftingRecipeInput inv, RegistryWrapper.WrapperLookup lo
return result;
}

@Override
public boolean fits(int width, int height) {
return width >= 3 && height >= 3;
}

@Override
public RecipeSerializer<AddBannerPatternRecipe> getSerializer() {
return SERIALIZER;
Expand All @@ -115,7 +109,7 @@ private static BannerPattern_1_13_2 getBannerPattern(CraftingRecipeInput inv) {
if (pattern.hasBaseStack()) {
boolean foundBaseItem = false;
boolean foundDye = false;
for (int i = 0; i < inv.getSize(); i++) {
for (int i = 0; i < inv.size(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (!stack.isEmpty() && !(stack.getItem() instanceof BannerItem)) {
if (stack.getItem() instanceof DyeItem) {
Expand All @@ -134,9 +128,9 @@ private static BannerPattern_1_13_2 getBannerPattern(CraftingRecipeInput inv) {
}
}
if (!foundBaseItem || (!foundDye && ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_10))) matches = false;
} else if (inv.getSize() == pattern.getRecipePattern().length * pattern.getRecipePattern()[0].length()) {
} else if (inv.size() == pattern.getRecipePattern().length * pattern.getRecipePattern()[0].length()) {
DyeColor patternColor = null;
for (int i = 0; i < inv.getSize(); i++) {
for (int i = 0; i < inv.size(); i++) {
int row = i / 3;
int col = i % 3;
ItemStack stack = inv.getStackInSlot(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,21 @@

package de.florianmichael.viafabricplus.fixes.versioned.visual;

import com.google.common.collect.ImmutableList;
import net.minecraft.client.model.*;
import net.minecraft.client.render.entity.model.CompositeEntityModel;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.client.render.entity.state.BoatEntityRenderState;
import net.minecraft.util.Identifier;

/**
* Model for boats in 1.8 and lower.
*/
public class BoatModel1_8 extends CompositeEntityModel<BoatEntity> {
public class BoatModel1_8 extends EntityModel<BoatEntityRenderState> {

public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(Identifier.of("viafabricplus", "boat1_8"), "main");
private final ImmutableList<ModelPart> parts;

public BoatModel1_8(ModelPart root) {
this.parts = ImmutableList.of(root.getChild("bottom"), root.getChild("back"), root.getChild("front"), root.getChild("right"), root.getChild("left"));
super(root);
}

public static TexturedModelData getTexturedModelData() {
Expand All @@ -54,12 +52,7 @@ public static TexturedModelData getTexturedModelData() {
}

@Override
public Iterable<ModelPart> getParts() {
return parts;
}

@Override
public void setAngles(BoatEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
public void setAngles(BoatEntityRenderState state) {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@
package de.florianmichael.viafabricplus.fixes.versioned.visual;

import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.AbstractBoatEntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.state.BoatEntityRenderState;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;

/**
* Renderer for boats in 1.8 and lower.
*/
public class BoatRenderer1_8 extends EntityRenderer<BoatEntity> {
public class BoatRenderer1_8 extends AbstractBoatEntityRenderer {

private static final Identifier TEXTURE = Identifier.of("viafabricplus", "textures/boat1_8.png");
private final BoatModel1_8 model;
Expand All @@ -45,33 +47,32 @@ public BoatRenderer1_8(EntityRendererFactory.Context ctx) {
}

@Override
public Identifier getTexture(BoatEntity entity) {
return TEXTURE;
protected EntityModel<BoatEntityRenderState> getModel() {
return this.model;
}

@Override
public void render(BoatEntity entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
protected RenderLayer getRenderLayer() {
return this.model.getLayer(TEXTURE);
}

@Override
public void render(BoatEntityRenderState state, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
matrices.push();
matrices.translate(0, 0.25, 0);
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180 - yaw));
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180 - state.yaw));

float damageWobbleTicks = entity.getDamageWobbleTicks() - tickDelta;
float damageWobbleStrength = entity.getDamageWobbleStrength() - tickDelta;

if (damageWobbleStrength < 0) {
damageWobbleStrength = 0;
}
if (damageWobbleTicks > 0) {
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(MathHelper.sin(damageWobbleTicks) * damageWobbleTicks * damageWobbleStrength / 10 * entity.getDamageWobbleSide()));
if (state.damageWobbleTicks > 0) {
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(MathHelper.sin(state.damageWobbleTicks) * state.damageWobbleTicks * state.damageWobbleStrength / 10 * state.damageWobbleSide));
}

matrices.scale(-1, -1, 1);
model.setAngles(entity, tickDelta, 0, -0.1f, 0, 0);
model.setAngles(state);
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(model.getLayer(TEXTURE));
model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);

matrices.pop();
super.render(entity, yaw, tickDelta, matrices, vertexConsumers, light);
super.render(state, matrices, vertexConsumers, light);
}

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

package de.florianmichael.viafabricplus.fixes.versioned.visual;

import net.minecraft.client.font.BakedGlyph;
import net.minecraft.client.font.Glyph;
import net.minecraft.client.font.GlyphRenderer;
import net.minecraft.client.font.RenderableGlyph;

import java.util.function.Function;
Expand All @@ -41,7 +41,7 @@ public float getAdvance() {
}

@Override
public GlyphRenderer bake(Function<RenderableGlyph, GlyphRenderer> glyphRendererGetter) {
public BakedGlyph bake(Function<RenderableGlyph, BakedGlyph> glyphRendererGetter) {
return glyphRendererGetter.apply(new RenderableGlyph() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
import de.florianmichael.viafabricplus.fixes.versioned.PendingUpdateManager1_18_2;
import de.florianmichael.viafabricplus.injection.access.IEntity;
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.PendingUpdateManager;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
Expand All @@ -33,7 +31,7 @@
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.util.profiler.Profilers;
import net.minecraft.world.EntityList;
import net.minecraft.world.MutableWorldProperties;
import net.minecraft.world.World;
Expand All @@ -43,8 +41,6 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.function.Supplier;

@Mixin(value = ClientWorld.class, priority = 900)
public abstract class MixinClientWorld extends World {

Expand All @@ -57,12 +53,12 @@ public abstract class MixinClientWorld extends World {
@Final
private PendingUpdateManager pendingUpdateManager;

protected MixinClientWorld(MutableWorldProperties properties, RegistryKey<World> registryRef, DynamicRegistryManager registryManager, RegistryEntry<DimensionType> dimensionEntry, Supplier<Profiler> profiler, boolean isClient, boolean debugWorld, long biomeAccess, int maxChainedNeighborUpdates) {
super(properties, registryRef, registryManager, dimensionEntry, profiler, isClient, debugWorld, biomeAccess, maxChainedNeighborUpdates);
protected MixinClientWorld(MutableWorldProperties properties, RegistryKey<World> registryRef, DynamicRegistryManager registryManager, RegistryEntry<DimensionType> dimensionEntry, boolean isClient, boolean debugWorld, long seed, int maxChainedNeighborUpdates) {
super(properties, registryRef, registryManager, dimensionEntry, isClient, debugWorld, seed, maxChainedNeighborUpdates);
}

@Inject(method = "<init>", at = @At("RETURN"))
private void removePendingUpdateManager(ClientPlayNetworkHandler networkHandler, ClientWorld.Properties properties, RegistryKey<World> registryRef, RegistryEntry<DimensionType> dimensionTypeEntry, int loadDistance, int simulationDistance, Supplier<Profiler> profiler, WorldRenderer worldRenderer, boolean debugWorld, long seed, CallbackInfo ci) {
private void removePendingUpdateManager(CallbackInfo ci) {
if (DebugSettings.global().disableSequencing.isEnabled()) {
this.pendingUpdateManager = new PendingUpdateManager1_18_2();
}
Expand All @@ -78,9 +74,9 @@ public void tickEntity(Entity entity) {
final IEntity mixinEntity = (IEntity) entity;
if (mixinEntity.viaFabricPlus$isInLoadedChunkAndShouldTick() || entity.isSpectator()) {
entity.age++;
this.getProfiler().push(() -> Registries.ENTITY_TYPE.getId(entity.getType()).toString());
Profilers.get().push(() -> Registries.ENTITY_TYPE.getId(entity.getType()).toString());
entity.tick();
this.getProfiler().pop();
Profilers.get().pop();
}
this.viaFabricPlus$checkChunk(entity);

Expand Down Expand Up @@ -120,7 +116,6 @@ private void tickPassenger(Entity entity, Entity passenger) {

@Unique
private void viaFabricPlus$checkChunk(Entity entity) {
this.getProfiler().push("chunkCheck");
final IEntity mixinEntity = (IEntity) entity;
final int chunkX = MathHelper.floor(entity.getX() / 16.0D);
final int chunkZ = MathHelper.floor(entity.getZ() / 16.0D);
Expand All @@ -129,7 +124,6 @@ private void tickPassenger(Entity entity, Entity passenger) {
mixinEntity.viaFabricPlus$setInLoadedChunkAndShouldTick(true);
}
}
this.getProfiler().pop();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public abstract class MixinGameRenderer {

@Shadow
@Final
MinecraftClient client;
private MinecraftClient client;

@ModifyExpressionValue(method = "findCrosshairTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;raycast(DFZ)Lnet/minecraft/util/hit/HitResult;"))
private HitResult bedrockReachAroundRaycast(HitResult hitResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -42,22 +42,22 @@
public abstract class MixinAbstractSignBlock {

@Inject(method = "onUseWithItem", at = @At("HEAD"), cancellable = true)
private void changeInteractionCalculation(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ItemActionResult> cir) {
private void changeInteractionCalculation(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
if (!world.isClient) {
return;
}

if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
// <= 1.14.4 doesn't have any sign interactions.
cir.setReturnValue(ItemActionResult.SUCCESS);
cir.setReturnValue(ActionResult.SUCCESS);
} else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_4)) {
// Removes the isWaxed() condition and reverts the interaction changes from 1.19.4 -> 1.20 when signs
// got a front and back side.
final ItemStack itemStack = player.getStackInHand(hand);
final Item item = itemStack.getItem();
final boolean isSuccess = (item instanceof DyeItem || itemStack.isOf(Items.GLOW_INK_SAC) || itemStack.isOf(Items.INK_SAC)) && player.canModifyBlocks();

cir.setReturnValue(isSuccess ? ItemActionResult.SUCCESS : ItemActionResult.CONSUME);
cir.setReturnValue(isSuccess ? ActionResult.SUCCESS : ActionResult.CONSUME);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin;
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
import net.minecraft.block.*;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
Expand All @@ -47,7 +47,7 @@ public abstract class MixinAnvilBlock extends FallingBlock {

@Shadow
@Final
public static DirectionProperty FACING;
public static EnumProperty<Direction> FACING;

public MixinAnvilBlock(Settings settings) {
super(settings);
Expand All @@ -66,11 +66,11 @@ private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos,
}

@Override
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
protected VoxelShape getCullingShape(BlockState state) {
// Workaround for https://github.com/ViaVersion/ViaFabricPlus/issues/246
// MoreCulling is caching the culling shape and doesn't reload it, so we have to force vanilla's shape here.
viaFabricPlus$requireOriginalShape = true;
return super.getCullingShape(state, world, pos);
return super.getCullingShape(state);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ private void cancelEntityBounce(Entity entity, CallbackInfo ci) {
}

@Override
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
public VoxelShape getCullingShape(BlockState state) {
// Workaround for https://github.com/ViaVersion/ViaFabricPlus/issues/246
// MoreCulling is caching the culling shape and doesn't reload it, so we have to force vanilla's shape here.
viaFabricPlus$requireOriginalShape = true;
return super.getCullingShape(state, world, pos);
return super.getCullingShape(state);
}

}
Loading

0 comments on commit 9fc55d6

Please sign in to comment.