Skip to content

Commit

Permalink
feat: bump minecraft to 1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jimchen5209 committed Dec 4, 2024
1 parent 9b31ced commit 7ba103e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
// "maven-publish"
kotlin("jvm") version "2.1.0"
id("fabric-loom") version "1.8-SNAPSHOT"
id("fabric-loom") version "1.9-SNAPSHOT"
}

val version = "0.0.1"
val group = "one.oktw"

val fabricVersion = "0.108.0+1.21.3"
val fabricVersion = "0.110.5+1.21.4"
val galaxyLibVersion = "bcf8f61"

repositories {
Expand Down Expand Up @@ -42,8 +42,8 @@ loom {

dependencies {
// Core
minecraft(group = "com.mojang", name = "minecraft", version = "1.21.3")
mappings(group = "net.fabricmc", name = "yarn", version = "1.21.3+build.2", classifier = "v2")
minecraft(group = "com.mojang", name = "minecraft", version = "1.21.4")
mappings(group = "net.fabricmc", name = "yarn", version = "1.21.4+build.1", classifier = "v2")
modImplementation(group = "net.fabricmc", name = "fabric-loader", version = "0.16.9")

// fabric api
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2020
* Copyright (C) 2018-2024
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
Expand All @@ -25,17 +25,17 @@
@Mixin(AbstractFurnaceBlockEntity.class)
public interface AbstractFurnaceBlockEntityAccessor {
@Accessor
int getBurnTime();
int getLitTimeRemaining();

@Accessor
void setBurnTime(int i);
void setLitTimeRemaining(int i);

@Accessor
int getCookTime();
int getCookingTimeSpent();

@Accessor
void setCookTime(int i);
void setCookingTimeSpent(int i);

@Accessor
int getCookTimeTotal();
int getCookingTotalTime();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2021
* Copyright (C) 2018-2024
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
Expand Down Expand Up @@ -57,7 +57,7 @@ public abstract class AbstractFurnaceBlockEntityMixin_RealTime {
@Redirect(method = "tick",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/block/entity/AbstractFurnaceBlockEntity;burnTime:I",
target = "Lnet/minecraft/block/entity/AbstractFurnaceBlockEntity;litTimeRemaining:I",
opcode = Opcodes.PUTFIELD,
ordinal = 0
)
Expand All @@ -66,29 +66,29 @@ public abstract class AbstractFurnaceBlockEntityMixin_RealTime {
final int ticks = (int) ((RealTimeTrackingBridge) self.getWorld()).realTimeBridge$getRealTimeTicks();

AbstractFurnaceBlockEntityAccessor accessor = (AbstractFurnaceBlockEntityAccessor) self;
final int burnTime = accessor.getBurnTime();
final int burnTime = accessor.getLitTimeRemaining();
if (burnTime != 1 && burnTime < ticks) {
accessor.setBurnTime(1); // last cook tick
accessor.setLitTimeRemaining(1); // last cook tick
} else {
accessor.setBurnTime(Math.max(0, burnTime - ticks));
accessor.setLitTimeRemaining(Math.max(0, burnTime - ticks));
}
}

@Redirect(
method = "tick",
at = @At(value = "FIELD", target = "Lnet/minecraft/block/entity/AbstractFurnaceBlockEntity;cookTime:I", opcode = Opcodes.PUTFIELD, ordinal = 0))
at = @At(value = "FIELD", target = "Lnet/minecraft/block/entity/AbstractFurnaceBlockEntity;cookingTimeSpent:I", opcode = Opcodes.PUTFIELD, ordinal = 0))
private static void realTimeImpl$adjustForRealTimeCookTime(final AbstractFurnaceBlockEntity self, final int modifier) {
final int ticks = (int) ((RealTimeTrackingBridge) self.getWorld()).realTimeBridge$getRealTimeTicks();

AbstractFurnaceBlockEntityAccessor accessor = (AbstractFurnaceBlockEntityAccessor) self;
accessor.setCookTime(Math.min(accessor.getCookTimeTotal(), accessor.getCookTime() + ticks));
accessor.setCookingTimeSpent(Math.min(accessor.getCookingTotalTime(), accessor.getCookingTimeSpent() + ticks));
}

@Redirect(
method = "tick",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/block/entity/AbstractFurnaceBlockEntity;cookTime:I",
target = "Lnet/minecraft/block/entity/AbstractFurnaceBlockEntity;cookingTimeSpent:I",
opcode = Opcodes.PUTFIELD
),
slice = @Slice(
Expand All @@ -106,6 +106,6 @@ public abstract class AbstractFurnaceBlockEntityMixin_RealTime {
final int ticks = (int) ((RealTimeTrackingBridge) self.getWorld()).realTimeBridge$getRealTimeTicks();

AbstractFurnaceBlockEntityAccessor accessor = (AbstractFurnaceBlockEntityAccessor) self;
accessor.setCookTime(MathHelper.clamp(accessor.getCookTime() - (2 * ticks), 0, accessor.getCookTimeTotal()));
accessor.setCookingTimeSpent(MathHelper.clamp(accessor.getCookingTimeSpent() - (2 * ticks), 0, accessor.getCookingTotalTime()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ open class ModelCustomBlockEntity(type: BlockEntityType<*>, pos: BlockPos, priva
set(direction) {
if (facing != null && direction != null && direction in allowedFacing) {
field = direction
(world as? ServerWorld)?.getEntity(entityUUID)?.yaw = direction.asRotation()
(world as? ServerWorld)?.getEntity(entityUUID)?.yaw = direction.positiveHorizontalDegrees
}
}
open val allowedFacing: List<Direction> = emptyList()
Expand Down Expand Up @@ -93,7 +93,7 @@ open class ModelCustomBlockEntity(type: BlockEntityType<*>, pos: BlockPos, priva

private fun spawnEntity() {
val entity: ArmorStandEntity = EntityType.getEntityFromNbt(armorStandNbt, world, SpawnReason.COMMAND).get() as ArmorStandEntity
entity.refreshPositionAndAngles(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, facing?.asRotation() ?: 0.0F, 0.0F)
entity.refreshPositionAndAngles(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, facing?.positiveHorizontalDegrees ?: 0.0F, 0.0F)
entity.equipStack(EquipmentSlot.HEAD, modelItem)
entity.addCommandTag("BLOCK")
entity.addCommandTag(getId().toString())
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/one/oktw/galaxy/item/CustomItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package one.oktw.galaxy.item

import net.minecraft.component.DataComponentTypes
import net.minecraft.component.type.AttributeModifiersComponent
import net.minecraft.component.type.CustomModelDataComponent
import net.minecraft.component.type.NbtComponent
import net.minecraft.component.type.UnbreakableComponent
import net.minecraft.item.Item
Expand Down Expand Up @@ -70,7 +69,8 @@ abstract class CustomItem(
if (cacheable && this::cacheItemStack.isInitialized) return cacheItemStack.copy()

return ItemStack(baseItem).apply {
set(DataComponentTypes.CUSTOM_MODEL_DATA, CustomModelDataComponent(modelData))
// FIXME: Change to new item model
// set(DataComponentTypes.CUSTOM_MODEL_DATA, CustomModelDataComponent(modelData))
set(DataComponentTypes.UNBREAKABLE, UnbreakableComponent(false))
set(DataComponentTypes.ATTRIBUTE_MODIFIERS, AttributeModifiersComponent(emptyList(), false))
set(DataComponentTypes.ITEM_NAME, this@CustomItem.getName())
Expand Down

0 comments on commit 7ba103e

Please sign in to comment.