Remove items stuff / Fix some problem with real instance

This commit is contained in:
2025-08-15 20:03:48 +02:00
parent c6f71a35f3
commit 71465482f9
9 changed files with 27 additions and 129 deletions

2
.gitignore vendored
View File

@@ -23,3 +23,5 @@ src/generated/resources/.cache/
*.patch
*.DS_Store
.factorypath

View File

@@ -169,6 +169,7 @@ tasks.named('processResources', ProcessResources).configure {
loader_version_range: loader_version_range,
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors: mod_authors, mod_description: mod_description,
gtm_version: gtm_version, geckolib_version: geckolib_version,
]
inputs.properties replaceProperties
@@ -195,6 +196,10 @@ tasks.named('jar', Jar).configure {
finalizedBy 'reobfJar'
}
tasks.named('build') {
dependsOn tasks.named('spotlessApply')
}
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing:
// tasks.named('publish').configure {
// dependsOn 'reobfJar'

View File

@@ -22,7 +22,6 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import com.imbgt.ibg.block.ModBlocks;
import com.imbgt.ibg.block.entity.ModBlockEntities;
import com.imbgt.ibg.block.entity.client.AnimatedBlockRenderer;
import com.imbgt.ibg.item.ModItems;
import com.mojang.logging.LogUtils;
import org.slf4j.Logger;
import software.bernie.geckolib.GeckoLib;
@@ -33,10 +32,10 @@ public class IBG {
public static final String MOD_ID = "ibg";
public static final Logger LOGGER = LogUtils.getLogger();
public IBG(FMLJavaModLoadingContext context) {
public IBG() {
var context = FMLJavaModLoadingContext.get();
IEventBus modEventBus = context.getModEventBus();
ModItems.register(modEventBus);
ModBlocks.register(modEventBus);
ModBlockEntities.register(modEventBus);
@@ -66,7 +65,7 @@ public class IBG {
public static void onClientSetup(FMLClientSetupEvent event) {
event.enqueueWork(() -> {
var latheDef = GTRegistries.MACHINES.get(
ResourceLocation.fromNamespaceAndPath("gtceu", "lv_lathe"));
new ResourceLocation("gtceu", "lv_lathe"));
latheDef.setShape(Block.box(-16, 0, 0, 32 - 16, 14, 16));

View File

@@ -10,16 +10,16 @@ public class AnimatedBlockModel<T extends GeoAnimatable> extends GeoModel<T> {
@Override
public ResourceLocation getModelResource(T animatable) {
return ResourceLocation.fromNamespaceAndPath(IBG.MOD_ID, "geo/animated_block.geo.json");
return new ResourceLocation(IBG.MOD_ID, "geo/animated_block.geo.json");
}
@Override
public ResourceLocation getTextureResource(T animatable) {
return ResourceLocation.fromNamespaceAndPath(IBG.MOD_ID, "textures/block/animated_block.png");
return new ResourceLocation(IBG.MOD_ID, "textures/block/animated_block.png");
}
@Override
public ResourceLocation getAnimationResource(T animatable) {
return ResourceLocation.fromNamespaceAndPath(IBG.MOD_ID, "animations/animated_block.animation.json");
return new ResourceLocation(IBG.MOD_ID, "animations/animated_block.animation.json");
}
}

View File

@@ -1,18 +0,0 @@
package com.imbgt.ibg.item;
import net.minecraft.world.item.Item;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import com.imbgt.ibg.IBG;
public class ModItems {
public static final DeferredRegister<Item> ITEMS_REGISTER = DeferredRegister.create(ForgeRegistries.ITEMS,
IBG.MOD_ID);
public static void register(IEventBus eventBus) {
ITEMS_REGISTER.register(eventBus);
}
}

View File

@@ -1,25 +0,0 @@
package com.imbgt.ibg.item.client;
import net.minecraft.resources.ResourceLocation;
import com.imbgt.ibg.IBG;
import com.imbgt.ibg.item.custom.AnimatedBlockItem;
import software.bernie.geckolib.model.GeoModel;
public class AnimatedBlockItemModel extends GeoModel<AnimatedBlockItem> {
@Override
public ResourceLocation getModelResource(AnimatedBlockItem animatable) {
return ResourceLocation.fromNamespaceAndPath(IBG.MOD_ID, "geo/animated_block.geo.json");
}
@Override
public ResourceLocation getTextureResource(AnimatedBlockItem animatable) {
return ResourceLocation.fromNamespaceAndPath(IBG.MOD_ID, "textures/block/animated_block.png");
}
@Override
public ResourceLocation getAnimationResource(AnimatedBlockItem animatable) {
return ResourceLocation.fromNamespaceAndPath(IBG.MOD_ID, "animations/animated_block.animation.json");
}
}

View File

@@ -1,11 +0,0 @@
package com.imbgt.ibg.item.client;
import com.imbgt.ibg.item.custom.AnimatedBlockItem;
import software.bernie.geckolib.renderer.GeoItemRenderer;
public class AnimatedBlockItemRenderer extends GeoItemRenderer<AnimatedBlockItem> {
public AnimatedBlockItemRenderer() {
super(new AnimatedBlockItemModel());
}
}

View File

@@ -1,68 +0,0 @@
package com.imbgt.ibg.item.custom;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import com.imbgt.ibg.item.client.AnimatedBlockItemRenderer;
import software.bernie.geckolib.animatable.GeoItem;
import software.bernie.geckolib.animatable.SingletonGeoAnimatable;
import software.bernie.geckolib.core.animatable.GeoAnimatable;
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.core.animatable.instance.SingletonAnimatableInstanceCache;
import software.bernie.geckolib.core.animation.AnimatableManager;
import software.bernie.geckolib.core.animation.Animation;
import software.bernie.geckolib.core.animation.AnimationController;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.core.animation.RawAnimation;
import software.bernie.geckolib.core.object.PlayState;
import software.bernie.geckolib.util.RenderUtils;
import java.util.function.Consumer;
public class AnimatedBlockItem extends BlockItem implements GeoItem {
private AnimatableInstanceCache cache = new SingletonAnimatableInstanceCache(this);
public AnimatedBlockItem(Block block, Properties properties) {
super(block, properties);
SingletonGeoAnimatable.registerSyncedAnimatable(this);
}
@Override
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
consumer.accept(new IClientItemExtensions() {
private AnimatedBlockItemRenderer renderer;
@Override
public BlockEntityWithoutLevelRenderer getCustomRenderer() {
if (this.renderer == null)
this.renderer = new AnimatedBlockItemRenderer();
return this.renderer;
}
});
}
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) {
controllerRegistrar.add(new AnimationController<>(this, "controller", 0, this::predicate));
}
private <T extends GeoAnimatable> PlayState predicate(AnimationState<T> tAnimationState) {
tAnimationState.getController().setAnimation(RawAnimation.begin().then("idle", Animation.LoopType.LOOP));
return PlayState.CONTINUE;
}
@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return cache;
}
@Override
public double getTick(Object itemStack) {
return RenderUtils.getCurrentTick();
}
}

View File

@@ -66,6 +66,20 @@ description='''${mod_description}'''
ordering="NONE"
side="BOTH"
[[dependencies.${mod_id}]]
modId = "geckolib"
mandatory = true
versionRange = "[${geckolib_version},)" # adjust according to what you need
ordering = "NONE"
side = "BOTH"
[[dependencies.${mod_id}]]
modId = "gtceu"
mandatory = true
versionRange = "[${gtm_version},)"
ordering = "AFTER"
side = "BOTH"
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
# stop your mod loading on the server for example.