Skip to content

Commit 5035a7b

Browse files
committed
增加方块(WIP)
1 parent 7084361 commit 5035a7b

File tree

13 files changed

+194
-33
lines changed

13 files changed

+194
-33
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package io.github.mxpea.fadingshadow.block;
2+
3+
import com.mojang.serialization.MapCodec;
4+
import net.minecraft.core.BlockPos;
5+
import net.minecraft.world.level.block.BaseEntityBlock;
6+
import net.minecraft.world.level.block.RenderShape;
7+
import net.minecraft.world.level.block.entity.BlockEntity;
8+
import net.minecraft.world.level.block.state.BlockState;
9+
import org.jetbrains.annotations.Nullable;
10+
11+
public class AnimatedBlock extends BaseEntityBlock {
12+
public AnimatedBlock(Properties properties) {
13+
super(properties);
14+
}
15+
16+
@Override
17+
protected MapCodec<? extends BaseEntityBlock> codec() {
18+
return null;
19+
}
20+
21+
@Override
22+
public @Nullable BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
23+
return null;
24+
}
25+
26+
27+
@Override
28+
protected RenderShape getRenderShape(BlockState state) {
29+
return RenderShape.ENTITYBLOCK_ANIMATED;
30+
}
31+
}

src/main/java/io/github/mxpea/fadingshadow/block/ModBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class ModBlock {
2121
DeferredRegister.createBlocks(FadingShadow.MODID);
2222

2323
public static final DeferredBlock<Block> scranton_reality_anchors =
24-
registerBlocks("scranton_reality_anchors", () -> new Block(BlockBehaviour.Properties.ofFullCopy(Blocks.STONE)));
24+
registerBlocks("scranton_reality_anchors", () -> new Block(BlockBehaviour.Properties.ofFullCopy(Blocks.STONE).noCollission()));
2525
public static final DeferredBlock<Block> netherreactor =
2626
registerBlocks("netherreactor", () -> new Block(BlockBehaviour.Properties.ofFullCopy(Blocks.STONE)));
2727

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package io.github.mxpea.fadingshadow.block.entity.client;
2+
3+
import net.minecraft.core.BlockPos;
4+
import net.minecraft.world.level.block.BaseEntityBlock;
5+
import net.minecraft.world.level.block.GameMasterBlock;
6+
import net.minecraft.world.level.block.entity.BlockEntity;
7+
import net.minecraft.world.level.block.entity.BlockEntityType;
8+
import net.minecraft.world.level.block.state.BlockState;
9+
import software.bernie.geckolib.animatable.GeoAnimatable;
10+
import software.bernie.geckolib.animatable.GeoBlockEntity;
11+
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
12+
import software.bernie.geckolib.animatable.instance.SingletonAnimatableInstanceCache;
13+
import software.bernie.geckolib.animation.*;
14+
import software.bernie.geckolib.util.RenderUtil;
15+
16+
/*
17+
public class AnimatedBlockEntity extends BlockEntity implements GeoBlockEntity {
18+
private AnimatableInstanceCache cache = new SingletonAnimatableInstanceCache(this);
19+
20+
public AnimatedBlockEntity(BlockPos pos, BlockState blockState) {
21+
super(ModBlockEntities, pos, blockState);
22+
}
23+
24+
25+
@Override
26+
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
27+
controllers.add(new AnimationController<>(this, "controller", 0, this::predicate));
28+
}
29+
30+
private <T extends GeoAnimatable> PlayState predicate(AnimationState<T> tAnimationState){
31+
tAnimationState.getController().setAnimation(RawAnimation.begin().then("idle", Animation.LoopType.LOOP);
32+
return PlayState.CONTINUE;
33+
}
34+
35+
36+
37+
38+
@Override
39+
public AnimatableInstanceCache getAnimatableInstanceCache() {
40+
return cache;
41+
}
42+
43+
@Override
44+
public double getTick(Object blockEntity) {
45+
return RenderUtil.getCurrentTick();
46+
}
47+
}
48+
49+
*/
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package io.github.mxpea.fadingshadow.block.entity.client;
2+
3+
import io.github.mxpea.fadingshadow.FadingShadow;
4+
import io.github.mxpea.fadingshadow.block.ModBlock;
5+
import net.minecraft.core.registries.Registries;
6+
import net.minecraft.world.level.block.entity.BlockEntityType;
7+
import net.neoforged.bus.api.IEventBus;
8+
import net.neoforged.neoforge.registries.DeferredHolder;
9+
import net.neoforged.neoforge.registries.DeferredRegister;
10+
import net.neoforged.neoforge.registries.NeoForgeRegistries;
11+
12+
import java.util.function.Supplier;
13+
14+
/*
15+
public class ModBlockEntities {
16+
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES =
17+
DeferredRegister.create(Registries.BLOCK_ENTITY_TYPE, FadingShadow.MODID);
18+
19+
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<AnimatedBlockEntity>> ANIMATED_BLOCK_ENTITY =
20+
BLOCK_ENTITIES.register("animated_block_entity", () ->
21+
BlockEntityType.Builder.of(AnimatedBlockEntity::new,
22+
ModBlock.ANIMATED_BLOCK.get()).build(null));
23+
}
24+
25+
26+
*/
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"format_version": "1.8.0",
3+
"animations": {
4+
"animation.scranton_reality_anchors.new": {
5+
"loop": true,
6+
"animation_length": 10,
7+
"bones": {
8+
"bone": {
9+
"rotation": {
10+
"0.0": {
11+
"vector": [0, 0, 0]
12+
},
13+
"10.0": {
14+
"vector": [0, 0, 360]
15+
}
16+
},
17+
"position": {
18+
"vector": [0, 0, 0]
19+
}
20+
},
21+
"bone2": {
22+
"position": {
23+
"0.0": {
24+
"vector": [0, 1, 0]
25+
},
26+
"2.5": {
27+
"vector": [0, 0, 0],
28+
"easing": "easeInCubic"
29+
},
30+
"5.0": {
31+
"vector": [0, -2, 0],
32+
"easing": "easeOutCubic"
33+
},
34+
"7.5": {
35+
"vector": [0, 0, 0],
36+
"easing": "easeInCubic"
37+
},
38+
"10.0": {
39+
"vector": [0, 1, 0],
40+
"easing": "easeOutCubic"
41+
}
42+
},
43+
"scale": {
44+
"vector": [1, 1, 1]
45+
}
46+
}
47+
}
48+
}
49+
},
50+
"geckolib_format_version": 2
51+
}

src/main/resources/assets/fadingshadow/animations/scranton_reality_anchors.animation.json

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"variants": {
3+
"": {
4+
"model": "fadingshadow:block/scranton_reality_anchors."
5+
}
6+
}
7+
}

src/main/resources/assets/fadingshadow/models/scranton_reality_anchors.geo.json renamed to src/main/resources/assets/fadingshadow/geo/scranton_reality_anchors.geo.json

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,23 @@
2222
},
2323
{
2424
"name": "bone",
25-
"pivot": [0, 9.5, -5],
25+
"pivot": [0, 9.5, -5.75],
2626
"cubes": [
27-
{"origin": [-2, 7, -5], "size": [4, 1, 1], "pivot": [0, 9.5, -4.5], "rotation": [0, 0, 90], "uv": [51, 0]},
28-
{"origin": [-2, 11, -5], "size": [4, 1, 1], "pivot": [0, 9.5, -4.5], "rotation": [0, 0, 90], "uv": [51, 0]},
29-
{"origin": [-2, 7, -5], "size": [4, 1, 1], "uv": [51, 0]},
30-
{"origin": [-2, 11, -5], "size": [4, 1, 1], "uv": [51, 0]}
27+
{"origin": [-2, 7, -5.75], "size": [4, 1, 1], "pivot": [0, 9.5, -5.25], "rotation": [0, 0, 90], "uv": [52, 8]},
28+
{"origin": [-2, 11, -5.75], "size": [4, 1, 1], "pivot": [0, 9.5, -5.25], "rotation": [0, 0, 90], "uv": [53, 1]},
29+
{"origin": [-2, 7, -5.75], "size": [4, 1, 1], "uv": [53, 1]},
30+
{"origin": [-2, 11, -5.75], "size": [4, 1, 1], "uv": [53, 1]}
3131
],
3232
"locators": {
33-
"locator": [0, 9.5, -5]
33+
"locator": [0, 9.5, -5.75]
3434
}
35+
},
36+
{
37+
"name": "bone2",
38+
"pivot": [0, 0, 0],
39+
"cubes": [
40+
{"origin": [-1, 6, -1], "size": [2, 6, 2], "uv": [40, 0]}
41+
]
3542
}
3643
]
3744
}

src/main/resources/assets/fadingshadow/lang/en_us.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"item.minecraft.splash_potion.effect.red_chili_juice":"splash chili water",
88
"item.minecraft.lingering_potion.effect.red_chili_juice":"lingering chili water",
99

10-
"block.fadingshadow.scranton_reality_anchors": "Scranton Reality Anchors",
10+
"block.fadingshadow.scranton_reality_anchors": "Scranton Reality Anchors (WIP)",
1111
"block.fadingshadow.netherreactor": "Nether reactor",
1212

1313
"itemGroup.fs_tab": "{Fading Shadow}",

src/main/resources/assets/fadingshadow/lang/zh_cn.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"item.minecraft.splash_potion.effect.red_chili_juice":"喷溅辣椒水",
88
"item.minecraft.lingering_potion.effect.red_chili_juice":"喷溅辣椒水",
99

10-
"block.fadingshadow.scranton_reality_anchors": "斯克兰顿现实稳定锚",
10+
"block.fadingshadow.scranton_reality_anchors": "斯克兰顿现实稳定锚 (WIP)",
1111
"block.fadingshadow.netherreactor": "下界反应核",
1212

1313
"itemGroup.fs_tab": "{消逝之影}",

0 commit comments

Comments
 (0)