Skip to content

Commit

Permalink
Added block/item.nameKey for modification events
Browse files Browse the repository at this point in the history
  • Loading branch information
LatvianModder committed Nov 29, 2023
1 parent a60e3e9 commit a802b01
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public interface BlockKJS extends BlockBuilderProvider {
throw new NoMixinException();
}

default void kjs$setNameKey(String key) {
throw new NoMixinException();
}

default void kjs$setDestroySpeed(float v) {
for (var state : kjs$getBlockStates()) {
state.kjs$setDestroySpeed(v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ public interface ItemKJS extends IngredientSupplierKJS {
return ImmutableList.copyOf(attributes.get(attribute));
}

default void kjs$setNameKey(String key) {
throw new NoMixinException();
}

default ItemStackKey kjs$getTypeItemStackKey() {
throw new NoMixinException();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package dev.latvian.mods.kubejs.core.mixin.common;

import dev.latvian.mods.rhino.util.RemapPrefixForJS;
import net.minecraft.world.level.block.Block;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(Block.class)
@RemapPrefixForJS("kjs$")
public abstract class BlockMixin extends BlockBehaviourMixin {
@Override
@Accessor("descriptionId")
@Mutable
public abstract void kjs$setNameKey(String key);
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ private void releaseUsing(ItemStack itemStack, Level level, LivingEntity livingE
return kjs$asIngredient;
}

@Override
@Accessor("descriptionId")
@Mutable
public abstract void kjs$setNameKey(String key);

@Override
public ItemStackKey kjs$getTypeItemStackKey() {
if (kjs$typeItemStackKey == null) {
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/kubejs-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"BlockBehaviourMixin",
"BlockMixin",
"BlockStateBaseMixin",
"ContainerMixin",
"CraftingContainerMixin",
Expand Down

0 comments on commit a802b01

Please sign in to comment.