修复雷达同步旋转问题
This commit is contained in:
parent
67b866d8db
commit
2defaacc9a
4 changed files with 36 additions and 17 deletions
|
@ -32,7 +32,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
import software.bernie.geckolib.animatable.GeoBlockEntity;
|
||||
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
||||
import software.bernie.geckolib.animation.AnimatableManager;
|
||||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
@ -218,8 +218,16 @@ public class FuMO25BlockEntity extends BlockEntity implements MenuProvider, GeoB
|
|||
return ClientboundBlockEntityDataPacket.create(this);
|
||||
}
|
||||
|
||||
private PlayState predicate(AnimationState<FuMO25BlockEntity> event) {
|
||||
if (this.getBlockState().getValue(FuMO25Block.POWERED)) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.fumo_25.rot"));
|
||||
}
|
||||
return PlayState.STOP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
|
||||
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
||||
data.add(new AnimationController<>(this, "controller", 0, this::predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,7 +8,7 @@ import software.bernie.geckolib.model.GeoModel;
|
|||
public class FuMO25Model extends GeoModel<FuMO25BlockEntity> {
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(FuMO25BlockEntity animatable) {
|
||||
return null;
|
||||
return Mod.loc("animations/fumo_25.animation.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
package com.atsuishio.superbwarfare.client.renderer.block;
|
||||
|
||||
import com.atsuishio.superbwarfare.block.FuMO25Block;
|
||||
import com.atsuishio.superbwarfare.block.entity.FuMO25BlockEntity;
|
||||
import com.atsuishio.superbwarfare.client.model.block.FuMO25Model;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.renderer.GeoBlockRenderer;
|
||||
|
||||
|
||||
|
@ -32,14 +28,4 @@ public class FuMO25BlockEntityRenderer extends GeoBlockRenderer<FuMO25BlockEntit
|
|||
public int getViewDistance() {
|
||||
return 512;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderRecursively(PoseStack poseStack, FuMO25BlockEntity animatable, GeoBone bone, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int colour) {
|
||||
String name = bone.getName();
|
||||
if (name.equals("mian") && animatable.getBlockState().getValue(FuMO25Block.POWERED)) {
|
||||
bone.setRotY((System.currentTimeMillis() % 36000000) / 1200f);
|
||||
}
|
||||
|
||||
super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, colour);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"format_version": "1.8.0",
|
||||
"animations": {
|
||||
"animation.fumo_25.rot": {
|
||||
"loop": true,
|
||||
"animation_length": 8,
|
||||
"bones": {
|
||||
"mian": {
|
||||
"rotation": {
|
||||
"0.0": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"8.0": [
|
||||
0,
|
||||
360,
|
||||
0
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue