@Mixin(targets = "com.trongthang.bettercampfires.mixin.CampfireBlockEntityMixin")
public interface CampfireBlockEntityAccessor {
@Accessor(value = "campfireBurntime", remap = false)
int getCampfireBurntime();
@Accessor(value = "campfireBurntime", remap = false)
void setCampfireBurntime(int burnTime);
}
< /code>
Ich versuche, auf die @Unique-Fiels des CampfireBlockEntityMixin zuzugreifen.@Mixin(CampfireBlockEntity.class)
class CampfireBlockEntityMixin {
private int buffCheckCounter = 0;
private static int buffRadius = ModConfig.getInstance().buffRadius;
// Add a custom burn time field
@Unique
private int campfireBurntime = 0;
}
< /code>
Hier versuche ich, den Accessor zu verwenden. Ich möchte, dass Spieler das Lagerfeuer tanken können, indem sie mit ihm interagieren: < /p>
@Mixin(CampfireBlock.class)
public class CampfireBlockFuel {
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
public void onPlayerInteract(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) {
// Only proceed if it's not a client-side interaction and the campfire is lit
if (!world.isClient && state.get(CampfireBlock.LIT) && !ModConfig.getInstance().campfireFuels.isEmpty() && ModConfig.getInstance().campfiresCanBurnOut) {
ItemStack heldItem = player.getStackInHand(hand);
String fuelId = heldItem.getItem().getTranslationKey();
// Normalize the translation key for block or item
String itemId = fuelId.replace("item.minecraft.", "minecraft:").replace("block.minecraft.", "minecraft:");
boolean fuelFound = false; // Flag to track if we found the fuel
for (ModConfig.CampfireFuels fuel : ModConfig.getInstance().campfireFuels) {
if (fuel.fuelId.equals(itemId)) {
fuelFound = true;
if (heldItem.getCount() > 0) {
heldItem.decrement(1);
int fuelTime = fuel.addBurnTime;
// Update the campfire's cooldown list
campfiresList.computeIfPresent(pos, (p, cooldown) -> {
cooldown.timeLeft += fuelTime;
return cooldown;
});
// Get the campfire BlockEntity
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof CampfireBlockEntity) {
CampfireBlockEntityAccessor campfireBlockEntityAccessor = (CampfireBlockEntityAccessor) blockEntity;
int currentBurnTime = campfireBlockEntityAccessor.getCampfireBurntime();
campfireBlockEntityAccessor.setCampfireBurntime(currentBurnTime + fuelTime);
LOGGER.info("BURN TIME: " + campfireBlockEntityAccessor.getCampfireBurntime());
}
// Send network packet if needed
ServerPlayNetworking.send(player.getServer().getPlayerManager().getPlayer(player.getUuid()), PLAY_BLOCK_LAVA_EXTINGUISH, PacketByteBufs.empty());
// Set the return value to indicate success
cir.setReturnValue(ActionResult.SUCCESS);
cir.cancel();
}
break; // Exit the loop once the fuel is found
}
}
}
}
}
< /code>
Hier ist der Fehler, den ich immer wieder erhalte: < /p>
[13:41:22] [Server thread/ERROR]: Failed to handle packet net.minecraft.class_2885@2f1a1d1d, suppressing error
java.lang.RuntimeException: Mixin transformation of com.trongthang.bettercampfires.mixin.CampfireBlockEntityAccessor failed
at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.getPostMixinClassByteArray(KnotClassDelegate.java:427) ~[fabric-loader-0.16.10.jar:?]
at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.tryLoadClass(KnotClassDelegate.java:323) ~[fabric-loader-0.16.10.jar:?]
at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.loadClass(KnotClassDelegate.java:218) ~[fabric-loader-0.16.10.jar:?]
at net.fabricmc.loader.impl.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:119) ~[fabric-loader-0.16.10.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[?:?]
at net.minecraft.class_3922.handler$zdd000$bettercampfires$onPlayerInteract(class_3922.java:556) ~[client-intermediary.jar:?]
at net.minecraft.class_3922.method_9534(class_3922.java) ~[client-intermediary.jar:?]
at net.minecraft.class_4970$class_4971.method_26174(class_4970.java:1133) ~[client-intermediary.jar:?]
at net.minecraft.class_3225.method_14262(class_3225.java:343) ~[client-intermediary.jar:?]
at net.minecraft.class_3244.method_12046(class_3244.java:1140) ~[client-intermediary.jar:?]
at net.minecraft.class_2885.method_12547(class_2885.java:34) ~[client-intermediary.jar:?]
at net.minecraft.class_2885.method_11054(class_2885.java:8) ~[client-intermediary.jar:?]
at net.minecraft.class_2600.method_11072(class_2600.java:22) ~[client-intermediary.jar:?]
at net.minecraft.class_3738.run(class_3738.java:18) ~[client-intermediary.jar:?]
at net.minecraft.class_1255.method_18859(class_1255.java:156) ~[client-intermediary.jar:?]
at net.minecraft.class_4093.method_18859(class_4093.java:23) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_24306(MinecraftServer.java:782) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_18859(MinecraftServer.java:164) ~[client-intermediary.jar:?]
at net.minecraft.class_1255.method_16075(class_1255.java:130) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_20415(MinecraftServer.java:764) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_16075(MinecraftServer.java:758) ~[client-intermediary.jar:?]
at net.minecraft.class_1255.method_5383(class_1255.java:115) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_16208(MinecraftServer.java:742) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:675) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:265) ~[client-intermediary.jar:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: org.spongepowered.asm.mixin.transformer.throwables.IllegalClassLoadError: Illegal classload request for accessor mixin com.trongthang.bettercampfires.mixin.CampfireBlockEntityAccessor. The mixin is missing from bettercampfires.mixins.json which owns package com.trongthang.bettercampfires.mixin.* and the mixin has not been applied.
at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:334) ~[sponge-mixin-0.15.4+mixin.0.8.7.jar:0.15.4+mixin.0.8.7]
at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:234) ~[sponge-mixin-0.15.4+mixin.0.8.7.jar:0.15.4+mixin.0.8.7]
at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClassBytes(MixinTransformer.java:202) ~[sponge-mixin-0.15.4+mixin.0.8.7.jar:0.15.4+mixin.0.8.7]
at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.getPostMixinClassByteArray(KnotClassDelegate.java:422) ~[fabric-loader-0.16.10.jar:?]
... 25 more
Ich hoffe wirklich, dass mir jemand dabei helfen kann, ich habe es seit ein paar Wochen versucht, aber ich konnte die Antwort nicht finden.
Hier ist mein Accessor: < /p> [code]@Mixin(targets = "com.trongthang.bettercampfires.mixin.CampfireBlockEntityMixin") public interface CampfireBlockEntityAccessor {
@Accessor(value = "campfireBurntime", remap = false) int getCampfireBurntime();
@Accessor(value = "campfireBurntime", remap = false) void setCampfireBurntime(int burnTime); } < /code> Ich versuche, auf die @Unique-Fiels des CampfireBlockEntityMixin zuzugreifen.@Mixin(CampfireBlockEntity.class) class CampfireBlockEntityMixin {
private int buffCheckCounter = 0; private static int buffRadius = ModConfig.getInstance().buffRadius;
// Add a custom burn time field @Unique private int campfireBurntime = 0; } < /code> Hier versuche ich, den Accessor zu verwenden. Ich möchte, dass Spieler das Lagerfeuer tanken können, indem sie mit ihm interagieren: < /p> @Mixin(CampfireBlock.class) public class CampfireBlockFuel { @Inject(method = "onUse", at = @At("HEAD"), cancellable = true) public void onPlayerInteract(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { // Only proceed if it's not a client-side interaction and the campfire is lit if (!world.isClient && state.get(CampfireBlock.LIT) && !ModConfig.getInstance().campfireFuels.isEmpty() && ModConfig.getInstance().campfiresCanBurnOut) { ItemStack heldItem = player.getStackInHand(hand); String fuelId = heldItem.getItem().getTranslationKey();
// Normalize the translation key for block or item String itemId = fuelId.replace("item.minecraft.", "minecraft:").replace("block.minecraft.", "minecraft:");
boolean fuelFound = false; // Flag to track if we found the fuel for (ModConfig.CampfireFuels fuel : ModConfig.getInstance().campfireFuels) { if (fuel.fuelId.equals(itemId)) { fuelFound = true;
if (heldItem.getCount() > 0) { heldItem.decrement(1);
int fuelTime = fuel.addBurnTime;
// Update the campfire's cooldown list campfiresList.computeIfPresent(pos, (p, cooldown) -> { cooldown.timeLeft += fuelTime; return cooldown; });
// Get the campfire BlockEntity BlockEntity blockEntity = world.getBlockEntity(pos); if (blockEntity instanceof CampfireBlockEntity) {
// Send network packet if needed ServerPlayNetworking.send(player.getServer().getPlayerManager().getPlayer(player.getUuid()), PLAY_BLOCK_LAVA_EXTINGUISH, PacketByteBufs.empty());
// Set the return value to indicate success cir.setReturnValue(ActionResult.SUCCESS); cir.cancel(); } break; // Exit the loop once the fuel is found } } } } } < /code> Hier ist der Fehler, den ich immer wieder erhalte: < /p> [13:41:22] [Server thread/ERROR]: Failed to handle packet net.minecraft.class_2885@2f1a1d1d, suppressing error java.lang.RuntimeException: Mixin transformation of com.trongthang.bettercampfires.mixin.CampfireBlockEntityAccessor failed at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.getPostMixinClassByteArray(KnotClassDelegate.java:427) ~[fabric-loader-0.16.10.jar:?] at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.tryLoadClass(KnotClassDelegate.java:323) ~[fabric-loader-0.16.10.jar:?] at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.loadClass(KnotClassDelegate.java:218) ~[fabric-loader-0.16.10.jar:?] at net.fabricmc.loader.impl.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:119) ~[fabric-loader-0.16.10.jar:?] at java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[?:?] at net.minecraft.class_3922.handler$zdd000$bettercampfires$onPlayerInteract(class_3922.java:556) ~[client-intermediary.jar:?] at net.minecraft.class_3922.method_9534(class_3922.java) ~[client-intermediary.jar:?] at net.minecraft.class_4970$class_4971.method_26174(class_4970.java:1133) ~[client-intermediary.jar:?] at net.minecraft.class_3225.method_14262(class_3225.java:343) ~[client-intermediary.jar:?] at net.minecraft.class_3244.method_12046(class_3244.java:1140) ~[client-intermediary.jar:?] at net.minecraft.class_2885.method_12547(class_2885.java:34) ~[client-intermediary.jar:?] at net.minecraft.class_2885.method_11054(class_2885.java:8) ~[client-intermediary.jar:?] at net.minecraft.class_2600.method_11072(class_2600.java:22) ~[client-intermediary.jar:?] at net.minecraft.class_3738.run(class_3738.java:18) ~[client-intermediary.jar:?] at net.minecraft.class_1255.method_18859(class_1255.java:156) ~[client-intermediary.jar:?] at net.minecraft.class_4093.method_18859(class_4093.java:23) ~[client-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_24306(MinecraftServer.java:782) ~[client-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_18859(MinecraftServer.java:164) ~[client-intermediary.jar:?] at net.minecraft.class_1255.method_16075(class_1255.java:130) ~[client-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_20415(MinecraftServer.java:764) ~[client-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_16075(MinecraftServer.java:758) ~[client-intermediary.jar:?] at net.minecraft.class_1255.method_5383(class_1255.java:115) ~[client-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_16208(MinecraftServer.java:742) ~[client-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:675) ~[client-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:265) ~[client-intermediary.jar:?] at java.lang.Thread.run(Thread.java:833) ~[?:?] Caused by: org.spongepowered.asm.mixin.transformer.throwables.IllegalClassLoadError: Illegal classload request for accessor mixin com.trongthang.bettercampfires.mixin.CampfireBlockEntityAccessor. The mixin is missing from bettercampfires.mixins.json which owns package com.trongthang.bettercampfires.mixin.* and the mixin has not been applied. at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:334) ~[sponge-mixin-0.15.4+mixin.0.8.7.jar:0.15.4+mixin.0.8.7] at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:234) ~[sponge-mixin-0.15.4+mixin.0.8.7.jar:0.15.4+mixin.0.8.7] at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClassBytes(MixinTransformer.java:202) ~[sponge-mixin-0.15.4+mixin.0.8.7.jar:0.15.4+mixin.0.8.7] at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.getPostMixinClassByteArray(KnotClassDelegate.java:422) ~[fabric-loader-0.16.10.jar:?] ... 25 more
[/code] Ich hoffe wirklich, dass mir jemand dabei helfen kann, ich habe es seit ein paar Wochen versucht, aber ich konnte die Antwort nicht finden.
Wenn ich meinen Minecraft -Mod kompiliere, funktioniert es gut, aber wenn ich Minecraft betreibe, stürzt es ab:
Time: 2025-02-27 15:21:02
Description: Rendering overlay...
Ich bin neu in Minecraft Mod und Java Development und ich habe Chatgpt verwendet, um es zu lernen. Ich versuche, einen Mod zu bauen, der einen Kompass bietet, der auf den nächsten Diamanterzblock...
Ich habe diesen Accessor unten, der ein String-Ergebnis zurückgibt (Beispiel: „Ready“ oder „Ongoing“ ...):
public function getMinimumStatusAttribute()
{
$statusIds = [];
$tasks =...
Ich habe 3 Tabellen ProdVariant, Variant, VariantValues.
ProductVariant
----------------------------
ProductVariantID PK
ProductID FK NOT NULL
VariantID FK NULL
VariantValuesID FK NULL
In Hibernate wie man Mieterfilter auf Onetomany Feld zum Beispiel annehme
@Entity
@Table(name = \ user\ )
class User(
@Column(nullable = false)
@Id
@GeneratedValue(strategy = GenerationType.UUID)...