Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
UselessBullets committed Dec 10, 2024
1 parent 7ed1529 commit 41f2083
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/turniplabs/halplibe/helper/BlockBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import turniplabs.halplibe.HalpLibe;
import turniplabs.halplibe.mixin.accessors.BlockAccessor;
import turniplabs.halplibe.mixin.accessors.BlocksAccessor;
import turniplabs.halplibe.util.registry.IdSupplier;
import turniplabs.halplibe.util.registry.RunLengthConfig;
Expand Down Expand Up @@ -569,14 +570,19 @@ public <T extends BlockLogic> Block<T> build(String translationKey, String name,
block.withTags(tags);
}

if (customBlockItem != null) {
block.setBlockItem(() -> customBlockItem.run(block));
}

if (BlocksAccessor.hasInit()) {
block.init();

if (customBlockItem != null) {
Item.itemsList[block.id()] = customBlockItem.run(block);
} else {
Item.itemsList[block.id()] = new ItemBlock<>(block);
Item item = block.blockItemSupplier.get();
if (((BlockAccessor)(Object)block).getStatParent() != null) {
item.setStatParent(((BlockAccessor)(Object)block).getStatParent());
}
Item.itemsList[item.id] = item;


block.getLogic().initializeBlock();
BlocksAccessor.cacheBlock(block);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package turniplabs.halplibe.mixin.accessors;

import net.minecraft.core.block.Block;
import net.minecraft.core.item.IItemConvertible;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.util.function.Supplier;

@Mixin(value = Block.class, remap = false)
public interface BlockAccessor {
@Accessor("statParent")
Supplier<@NotNull IItemConvertible> getStatParent();
}
1 change: 1 addition & 0 deletions src/main/resources/halplibe.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"I18nMixin",
"MinecraftMixin",
"MinecraftServerMixin",
"accessors.BlockAccessor",
"accessors.BlocksAccessor",
"accessors.EntityFireflyFXAccessor",
"accessors.EntityFXAccessor",
Expand Down

0 comments on commit 41f2083

Please sign in to comment.