Lv lathe model replaced
This commit is contained in:
30
build.gradle
30
build.gradle
@@ -13,6 +13,8 @@ plugins {
|
||||
id 'org.spongepowered.mixin' version '0.7.+'
|
||||
}
|
||||
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
version = mod_version
|
||||
group = mod_group_id
|
||||
|
||||
@@ -68,7 +70,8 @@ minecraft {
|
||||
// You can set various levels here.
|
||||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
|
||||
mods {
|
||||
"${mod_id}" {
|
||||
source sourceSets.main
|
||||
@@ -79,10 +82,14 @@ minecraft {
|
||||
client {
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
|
||||
// arg "-mixin.config=${mod_id}.mixin.json"
|
||||
|
||||
}
|
||||
|
||||
server {
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
// arg "-mixin.config=${mod_id}.mixin.json"
|
||||
args '--nogui'
|
||||
}
|
||||
|
||||
@@ -122,14 +129,20 @@ repositories {
|
||||
includeGroup 'com.gregtechceu.gtceu'
|
||||
}
|
||||
}
|
||||
maven {
|
||||
|
||||
maven {
|
||||
name = 'GeckoLib'
|
||||
url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
|
||||
content {
|
||||
includeGroupByRegex("software\\.bernie.*")
|
||||
includeGroup("com.eliotlash.mclib")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
maven { // LDLib, Shimmer
|
||||
name = "FirstDarkDev Maven"
|
||||
url = "https://maven.firstdarkdev.xyz/snapshots"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -157,12 +170,21 @@ dependencies {
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
|
||||
implementation fg.deobf("com.gregtechceu.gtceu:gtceu-${minecraft_version}:${gtm_version}")
|
||||
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
|
||||
testAnnotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
|
||||
|
||||
implementation fg.deobf("com.lowdragmc.ldlib:ldlib-forge-${minecraft_version}:${ldlib_version}") { transitive = false }
|
||||
implementation fg.deobf("com.gregtechceu.gtceu:gtceu-${minecraft_version}:${gtm_version}") {transitive = false}
|
||||
|
||||
implementation fg.deobf("software.bernie.geckolib:geckolib-forge-${minecraft_version}:${geckolib_version}")
|
||||
implementation("com.eliotlash.mclib:mclib:20")
|
||||
}
|
||||
|
||||
mixin {
|
||||
add sourceSets.main, "${mod_id}.refmap.json"
|
||||
config "${mod_id}.mixin.json"
|
||||
}
|
||||
|
||||
// This block of code expands all declared replace properties in the specified resource targets.
|
||||
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
|
||||
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
|
||||
|
||||
@@ -62,3 +62,4 @@ mod_description=Example mod description.\nNewline characters can be used and wil
|
||||
## Deps Properties
|
||||
gtm_version=7.0.0
|
||||
geckolib_version=4.7.3
|
||||
ldlib_version=1.0.40.b
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package com.imbgt.ibg;
|
||||
|
||||
import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity;
|
||||
import com.gregtechceu.gtceu.api.registry.GTRegistries;
|
||||
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 net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
@@ -27,7 +32,7 @@ import org.slf4j.Logger;
|
||||
@Mod(IBG.MOD_ID)
|
||||
public class IBG {
|
||||
public static final String MOD_ID = "ibg";
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
public IBG(FMLJavaModLoadingContext context) {
|
||||
IEventBus modEventBus = context.getModEventBus();
|
||||
@@ -69,7 +74,23 @@ public class IBG {
|
||||
public static class ClientModEvents {
|
||||
@SubscribeEvent
|
||||
public static void onClientSetup(FMLClientSetupEvent event) {
|
||||
BlockEntityRenderers.register(ModBlockEntities.ANIMATED_BLOCK_ENTITY.get(), AnimatedBlockRenderer::new);
|
||||
BlockEntityRenderers.register(ModBlockEntities.ANIMATED_BLOCK_ENTITY.get(),
|
||||
AnimatedBlockRenderer::new);
|
||||
|
||||
event.enqueueWork(() -> {
|
||||
var latheDef = GTRegistries.MACHINES.get(
|
||||
ResourceLocation.fromNamespaceAndPath("gtceu", "lv_lathe"));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
BlockEntityType<MetaMachineBlockEntity> latheBE = (BlockEntityType<MetaMachineBlockEntity>) latheDef
|
||||
.getBlockEntityType();
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
BlockEntityRendererProvider<BlockEntity> provider = (BlockEntityRendererProvider) (ctx -> new AnimatedBlockRenderer<>(
|
||||
ctx));
|
||||
|
||||
BlockEntityRenderers.register(latheBE, provider);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
package com.imbgt.ibg.block.entity.client;
|
||||
|
||||
import com.imbgt.ibg.IBG;
|
||||
import com.imbgt.ibg.block.entity.AnimatedBlockEntity;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.core.animatable.GeoAnimatable;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class AnimatedBlockModel extends GeoModel<AnimatedBlockEntity> {
|
||||
public class AnimatedBlockModel<T extends GeoAnimatable> extends GeoModel<T> {
|
||||
@Override
|
||||
public ResourceLocation getModelResource(AnimatedBlockEntity animatable) {
|
||||
public ResourceLocation getModelResource(T animatable) {
|
||||
return ResourceLocation.fromNamespaceAndPath(IBG.MOD_ID, "geo/animated_block.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(AnimatedBlockEntity animatable) {
|
||||
public ResourceLocation getTextureResource(T animatable) {
|
||||
return ResourceLocation.fromNamespaceAndPath(IBG.MOD_ID, "textures/block/animated_block.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(AnimatedBlockEntity animatable) {
|
||||
public ResourceLocation getAnimationResource(T animatable) {
|
||||
return ResourceLocation.fromNamespaceAndPath(IBG.MOD_ID, "animations/animated_block.animation.json");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.imbgt.ibg.block.entity.client;
|
||||
|
||||
import com.imbgt.ibg.block.entity.AnimatedBlockEntity;
|
||||
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import software.bernie.geckolib.core.animatable.GeoAnimatable;
|
||||
import software.bernie.geckolib.renderer.GeoBlockRenderer;
|
||||
|
||||
public class AnimatedBlockRenderer extends GeoBlockRenderer<AnimatedBlockEntity> {
|
||||
public class AnimatedBlockRenderer <T extends BlockEntity & GeoAnimatable>
|
||||
extends GeoBlockRenderer<T> {
|
||||
public AnimatedBlockRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(new AnimatedBlockModel());
|
||||
super(new AnimatedBlockModel<T>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package com.imbgt.ibg.item.client;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
@@ -8,15 +9,16 @@ import com.imbgt.ibg.item.custom.AnimatedBlockItem;
|
||||
public class AnimatedBlockItemModel extends GeoModel<AnimatedBlockItem> {
|
||||
@Override
|
||||
public ResourceLocation getModelResource(AnimatedBlockItem animatable) {
|
||||
return new ResourceLocation(IBG.MOD_ID, "geo/animated_block.geo.json"); }
|
||||
return ResourceLocation.fromNamespaceAndPath(IBG.MOD_ID, "geo/animated_block.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(AnimatedBlockItem animatable) {
|
||||
return new ResourceLocation(IBG.MOD_ID, "textures/block/animated_block.png");
|
||||
return ResourceLocation.fromNamespaceAndPath(IBG.MOD_ID, "textures/block/animated_block.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(AnimatedBlockItem animatable) {
|
||||
return new ResourceLocation(IBG.MOD_ID, "animations/animated_block.animation.json");
|
||||
return ResourceLocation.fromNamespaceAndPath(IBG.MOD_ID, "animations/animated_block.animation.json");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.imbgt.ibg.mixin;
|
||||
|
||||
import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity;
|
||||
import com.gregtechceu.gtceu.api.machine.MetaMachine;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import software.bernie.geckolib.animatable.GeoBlockEntity;
|
||||
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.*;
|
||||
import software.bernie.geckolib.core.object.PlayState;
|
||||
import software.bernie.geckolib.util.RenderUtils;
|
||||
|
||||
@Mixin(MetaMachineBlockEntity.class)
|
||||
public abstract class MetaMachineBlockEntityGeoMixin implements GeoBlockEntity {
|
||||
@Unique private final AnimatableInstanceCache ibg$cache = new SingletonAnimatableInstanceCache(this);
|
||||
|
||||
@Shadow public abstract MetaMachine getMetaMachine();
|
||||
|
||||
@Override
|
||||
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
|
||||
controllers.add(new AnimationController<>(this, "controller", 0, this::ibg$predicate));
|
||||
}
|
||||
|
||||
@Unique
|
||||
private <T extends GeoAnimatable> PlayState ibg$predicate(AnimationState<T> state) {
|
||||
// Example: animate only for LV Lathe
|
||||
var defId = getMetaMachine().getDefinition().getId();
|
||||
if ("gtceu".equals(defId.getNamespace()) && "lv_lathe".equals(defId.getPath())) {
|
||||
state.getController().setAnimation(RawAnimation.begin().then("idle", Animation.LoopType.LOOP));
|
||||
} else {
|
||||
state.getController().forceAnimationReset();
|
||||
}
|
||||
return PlayState.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimatableInstanceCache getAnimatableInstanceCache() {
|
||||
return ibg$cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTick(Object blockEntity) {
|
||||
return RenderUtils.getCurrentTick();
|
||||
}
|
||||
}
|
||||
|
||||
30
src/main/java/com/imbgt/ibg/mixin/MetaMachineBlockMixin.java
Normal file
30
src/main/java/com/imbgt/ibg/mixin/MetaMachineBlockMixin.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.imbgt.ibg.mixin;
|
||||
|
||||
import com.gregtechceu.gtceu.api.block.MetaMachineBlock;
|
||||
import com.gregtechceu.gtceu.api.machine.MachineDefinition;
|
||||
import com.imbgt.ibg.IBG;
|
||||
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MetaMachineBlock.class)
|
||||
public abstract class MetaMachineBlockMixin {
|
||||
|
||||
@Shadow
|
||||
public abstract MachineDefinition getDefinition();
|
||||
|
||||
@Inject(method = "getRenderShape", at = @At("HEAD"), cancellable = true)
|
||||
private void gtceu$forceAnimatedRender(BlockState state, CallbackInfoReturnable<RenderShape> cir) {
|
||||
|
||||
// Whitelist: only override for the LV lathe
|
||||
if (getDefinition().getId().toString().equals("gtceu:lv_lathe")) {
|
||||
IBG.LOGGER.info("MIXING IT IN");
|
||||
cir.setReturnValue(RenderShape.ENTITYBLOCK_ANIMATED);
|
||||
}
|
||||
}
|
||||
}
|
||||
14
src/main/resources/ibg.mixin.json
Normal file
14
src/main/resources/ibg.mixin.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "com.imbgt.ibg.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins":[],
|
||||
"client": [
|
||||
"MetaMachineBlockMixin",
|
||||
"MetaMachineBlockEntityGeoMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"refmap": "ibg.refmap.json"
|
||||
}
|
||||
Reference in New Issue
Block a user