Skip to content

Commit da592c4

Browse files
committed
fixed some bugs where it would think its burning when its not, made the sound stop, added a new disc burner model
1 parent f6d4612 commit da592c4

File tree

11 files changed

+381
-73
lines changed

11 files changed

+381
-73
lines changed

src/client/java/fn10/musicexpansion/providers/MusicExpandedModelProvider.java

Lines changed: 84 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,55 +18,92 @@
1818

1919
public class MusicExpandedModelProvider extends FabricModelProvider {
2020

21-
public MusicExpandedModelProvider(FabricDataOutput output) {
22-
super(output);
23-
}
21+
public MusicExpandedModelProvider(FabricDataOutput output) {
22+
super(output);
23+
}
2424

25-
@Override
26-
public void generateBlockStateModels(BlockModelGenerators blockStateModelGenerator) {
27-
// Disc Burner
28-
MultiVariant nodisc = BlockModelGenerators
29-
.plainVariant(Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID, "block/disc_burner"));
30-
MultiVariant hasdisc = BlockModelGenerators
31-
.plainVariant(Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID, "block/disc_burner_loaded"));
32-
blockStateModelGenerator.blockStateOutput
33-
.accept(MultiVariantGenerator.dispatch(MusicExpandedBlocks.DISC_BURNER_BLOCK)
34-
.with(PropertyDispatch.initial(DiscBurnerBlock.FACING, DiscBurnerBlock.LOADED)
35-
.select(Direction.NORTH, false, nodisc)
36-
.select(Direction.EAST, false, nodisc.with(BlockModelGenerators.Y_ROT_90))
37-
.select(Direction.SOUTH, false, nodisc.with(BlockModelGenerators.Y_ROT_180))
38-
.select(Direction.WEST, false, nodisc.with(BlockModelGenerators.Y_ROT_270))
39-
.select(Direction.NORTH, true, hasdisc)
40-
.select(Direction.EAST, true, hasdisc.with(BlockModelGenerators.Y_ROT_90))
41-
.select(Direction.SOUTH, true, hasdisc.with(BlockModelGenerators.Y_ROT_180))
42-
.select(Direction.WEST, true, hasdisc.with(BlockModelGenerators.Y_ROT_270))));
43-
blockStateModelGenerator.registerSimpleItemModel(MusicExpandedBlocks.DISC_BURNER_BLOCK,
44-
Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID, "block/disc_burner"));
45-
// Stereo
46-
MultiVariant snodisc = BlockModelGenerators
47-
.plainVariant(Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID, "block/stereo"));
48-
MultiVariant shasdisc = BlockModelGenerators
49-
.plainVariant(Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID, "block/stereo_loaded"));
50-
blockStateModelGenerator.blockStateOutput
51-
.accept(MultiVariantGenerator.dispatch(MusicExpandedBlocks.STEREO_BLOCK)
52-
.with(PropertyDispatch.initial(StereoBlock.FACING, StereoBlock.LOADED)
53-
.select(Direction.NORTH, false, snodisc)
54-
.select(Direction.EAST, false, snodisc.with(BlockModelGenerators.Y_ROT_90))
55-
.select(Direction.SOUTH, false, snodisc.with(BlockModelGenerators.Y_ROT_180))
56-
.select(Direction.WEST, false, snodisc.with(BlockModelGenerators.Y_ROT_270))
57-
.select(Direction.NORTH, true, shasdisc)
58-
.select(Direction.EAST, true, shasdisc.with(BlockModelGenerators.Y_ROT_90))
59-
.select(Direction.SOUTH, true, shasdisc.with(BlockModelGenerators.Y_ROT_180))
60-
.select(Direction.WEST, true, shasdisc.with(BlockModelGenerators.Y_ROT_270))));
61-
blockStateModelGenerator.registerSimpleItemModel(MusicExpandedBlocks.STEREO_BLOCK,
62-
Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID, "block/stereo"));
25+
@Override
26+
public void generateBlockStateModels(BlockModelGenerators blockStateModelGenerator) {
27+
// Disc Burner
28+
MultiVariant nodisc = BlockModelGenerators
29+
.plainVariant(Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID,
30+
"block/disc_burner"));
31+
MultiVariant hasdisc = BlockModelGenerators
32+
.plainVariant(Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID,
33+
"block/disc_burner_loaded"));
34+
MultiVariant spinningdisc = BlockModelGenerators
35+
.plainVariant(Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID,
36+
"block/disc_burner_burning"));
37+
blockStateModelGenerator.blockStateOutput
38+
.accept(MultiVariantGenerator.dispatch(MusicExpandedBlocks.DISC_BURNER_BLOCK)
39+
.with(PropertyDispatch
40+
.initial(DiscBurnerBlock.FACING, DiscBurnerBlock.LOADED, DiscBurnerBlock.BURNING)
41+
/// not burning
42+
.select(Direction.NORTH, false, false, nodisc)
43+
.select(Direction.EAST, false, false, nodisc
44+
.with(BlockModelGenerators.Y_ROT_90))
45+
.select(Direction.SOUTH, false, false, nodisc
46+
.with(BlockModelGenerators.Y_ROT_180))
47+
.select(Direction.WEST, false, false, nodisc
48+
.with(BlockModelGenerators.Y_ROT_270))
49+
// loaded
50+
.select(Direction.NORTH, true, false, hasdisc)
51+
.select(Direction.EAST, true, false, hasdisc
52+
.with(BlockModelGenerators.Y_ROT_90))
53+
.select(Direction.SOUTH, true, false, hasdisc
54+
.with(BlockModelGenerators.Y_ROT_180))
55+
.select(Direction.WEST, true, false, hasdisc.with(
56+
BlockModelGenerators.Y_ROT_270))
57+
/// burning
58+
.select(Direction.NORTH, false, true, spinningdisc)
59+
.select(Direction.EAST, false, true, spinningdisc
60+
.with(BlockModelGenerators.Y_ROT_90))
61+
.select(Direction.SOUTH, false, true, spinningdisc
62+
.with(BlockModelGenerators.Y_ROT_180))
63+
.select(Direction.WEST, false, true, spinningdisc
64+
.with(BlockModelGenerators.Y_ROT_270))
65+
// loaded
66+
.select(Direction.NORTH, true, true, spinningdisc)
67+
.select(Direction.EAST, true, true, spinningdisc
68+
.with(BlockModelGenerators.Y_ROT_90))
69+
.select(Direction.SOUTH, true, true, spinningdisc
70+
.with(BlockModelGenerators.Y_ROT_180))
71+
.select(Direction.WEST, true, true, spinningdisc.with(
72+
BlockModelGenerators.Y_ROT_270))));
73+
blockStateModelGenerator.registerSimpleItemModel(MusicExpandedBlocks.DISC_BURNER_BLOCK,
74+
Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID, "block/disc_burner"));
75+
// Stereo
76+
MultiVariant snodisc = BlockModelGenerators
77+
.plainVariant(Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID, "block/stereo"));
78+
MultiVariant shasdisc = BlockModelGenerators
79+
.plainVariant(Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID,
80+
"block/stereo_loaded"));
81+
blockStateModelGenerator.blockStateOutput
82+
.accept(MultiVariantGenerator.dispatch(MusicExpandedBlocks.STEREO_BLOCK)
83+
.with(PropertyDispatch.initial(StereoBlock.FACING, StereoBlock.LOADED)
84+
.select(Direction.NORTH, false, snodisc)
85+
.select(Direction.EAST, false, snodisc
86+
.with(BlockModelGenerators.Y_ROT_90))
87+
.select(Direction.SOUTH, false, snodisc
88+
.with(BlockModelGenerators.Y_ROT_180))
89+
.select(Direction.WEST, false, snodisc
90+
.with(BlockModelGenerators.Y_ROT_270))
91+
.select(Direction.NORTH, true, shasdisc)
92+
.select(Direction.EAST, true, shasdisc
93+
.with(BlockModelGenerators.Y_ROT_90))
94+
.select(Direction.SOUTH, true, shasdisc
95+
.with(BlockModelGenerators.Y_ROT_180))
96+
.select(Direction.WEST, true, shasdisc.with(
97+
BlockModelGenerators.Y_ROT_270))));
98+
blockStateModelGenerator.registerSimpleItemModel(MusicExpandedBlocks.STEREO_BLOCK,
99+
Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID, "block/stereo"));
63100

64-
}
101+
}
65102

66-
@Override
67-
public void generateItemModels(ItemModelGenerators itemModelGenerator) {
68-
itemModelGenerator.generateFlatItem(MusicExpandedItems.GLASS_DUST, ModelTemplates.FLAT_ITEM);
69-
itemModelGenerator.generateFlatItem(MusicExpandedItems.CD, ModelTemplates.FLAT_ITEM);
70-
}
103+
@Override
104+
public void generateItemModels(ItemModelGenerators itemModelGenerator) {
105+
itemModelGenerator.generateFlatItem(MusicExpandedItems.GLASS_DUST, ModelTemplates.FLAT_ITEM);
106+
itemModelGenerator.generateFlatItem(MusicExpandedItems.CD, ModelTemplates.FLAT_ITEM);
107+
}
71108

72109
}

src/client/java/fn10/musicexpansion/screens/DiscBurnerScreen.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ public class DiscBurnerScreen extends AbstractContainerScreen<DiscBurnerMenu> {
1313

1414
private final Identifier BG = Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID,
1515
"textures/gui/container/disc_burner.png");
16-
private final Identifier PROGRESS_SPRITE = Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID,
16+
private final Identifier PROGRESS_SPRITE = Identifier.fromNamespaceAndPath(MusicExpanded.MOD_ID,
1717
"container/disc_burner/progress");
1818
private final int bgWidth = 176;
1919
private final int bgHeight = 161;
20+
private final DiscBurnerMenu menu;
2021

21-
public DiscBurnerScreen(DiscBurnerMenu abstractContainerMenu, Inventory inventory, Component component) {
22-
super(abstractContainerMenu, inventory, component);
22+
public DiscBurnerScreen(DiscBurnerMenu menu, Inventory inventory, Component component) {
23+
super(menu, inventory, component);
24+
this.menu = menu;
2325
}
2426

2527
@Override
@@ -30,10 +32,21 @@ protected void renderBg(GuiGraphics guiGraphics, float f, int i, int j) {
3032
guiGraphics.blit(RenderPipelines.GUI_TEXTURED, BG, bgX, bgY, 0, 0, bgWidth, bgHeight, 256, 256);
3133
}
3234

35+
public void renderProgressSprite(GuiGraphics guiGraphics) {
36+
int burnTime = 700 - menu.data.get(0);
37+
int maxTime = 700;
38+
float progress = (float) burnTime / (float) maxTime;
39+
int bgX = (width - bgWidth) / 2;
40+
int bgY = (height - bgHeight) / 2;
41+
guiGraphics.blitSprite(RenderPipelines.GUI_TEXTURED, PROGRESS_SPRITE, 20, 41, 0, 0, bgX + 78, bgY + 69, 20,
42+
Math.round(41 * progress));
43+
}
44+
3345
@Override
3446
public void render(GuiGraphics guiGraphics, int i, int j, float f) {
3547
super.render(guiGraphics, i, j, f);
36-
this.renderTooltip(guiGraphics, i, j);
48+
renderTooltip(guiGraphics, i, j);
49+
renderProgressSprite(guiGraphics);
3750
}
3851

3952
}

src/main/generated/.cache/2fbf86ff4149eee6b9e08a0f457798e7a5fdf460

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// 1.21.11 -999999999-01-01T00:00:00 Compact Discs/Model Definitions
2-
ad0431593969498adf5853a2f86435123cd48221 assets/compactdiscs/blockstates/disc_burner.json
2+
02817251a41644766a20ebc4ab215e2dc2f8b383 assets/compactdiscs/blockstates/disc_burner.json
33
af0e04484b2413f909262673f0ae5a2658d170fb assets/compactdiscs/blockstates/stereo.json
44
8992f88c013726b4bf1b9ff417bf12e3b61cd436 assets/compactdiscs/items/compact_disc.json
55
d576ad8cd6569e6aac06a71159d22196e667d55f assets/compactdiscs/items/disc_burner.json
Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,64 @@
11
{
22
"variants": {
3-
"facing=east,loaded=false": {
3+
"burning=false,facing=east,loaded=false": {
44
"model": "compactdiscs:block/disc_burner",
55
"y": 90
66
},
7-
"facing=east,loaded=true": {
7+
"burning=false,facing=east,loaded=true": {
88
"model": "compactdiscs:block/disc_burner_loaded",
99
"y": 90
1010
},
11-
"facing=north,loaded=false": {
11+
"burning=false,facing=north,loaded=false": {
1212
"model": "compactdiscs:block/disc_burner"
1313
},
14-
"facing=north,loaded=true": {
14+
"burning=false,facing=north,loaded=true": {
1515
"model": "compactdiscs:block/disc_burner_loaded"
1616
},
17-
"facing=south,loaded=false": {
17+
"burning=false,facing=south,loaded=false": {
1818
"model": "compactdiscs:block/disc_burner",
1919
"y": 180
2020
},
21-
"facing=south,loaded=true": {
21+
"burning=false,facing=south,loaded=true": {
2222
"model": "compactdiscs:block/disc_burner_loaded",
2323
"y": 180
2424
},
25-
"facing=west,loaded=false": {
25+
"burning=false,facing=west,loaded=false": {
2626
"model": "compactdiscs:block/disc_burner",
2727
"y": 270
2828
},
29-
"facing=west,loaded=true": {
29+
"burning=false,facing=west,loaded=true": {
3030
"model": "compactdiscs:block/disc_burner_loaded",
3131
"y": 270
32+
},
33+
"burning=true,facing=east,loaded=false": {
34+
"model": "compactdiscs:block/disc_burner_burning",
35+
"y": 90
36+
},
37+
"burning=true,facing=east,loaded=true": {
38+
"model": "compactdiscs:block/disc_burner_burning",
39+
"y": 90
40+
},
41+
"burning=true,facing=north,loaded=false": {
42+
"model": "compactdiscs:block/disc_burner_burning"
43+
},
44+
"burning=true,facing=north,loaded=true": {
45+
"model": "compactdiscs:block/disc_burner_burning"
46+
},
47+
"burning=true,facing=south,loaded=false": {
48+
"model": "compactdiscs:block/disc_burner_burning",
49+
"y": 180
50+
},
51+
"burning=true,facing=south,loaded=true": {
52+
"model": "compactdiscs:block/disc_burner_burning",
53+
"y": 180
54+
},
55+
"burning=true,facing=west,loaded=false": {
56+
"model": "compactdiscs:block/disc_burner_burning",
57+
"y": 270
58+
},
59+
"burning=true,facing=west,loaded=true": {
60+
"model": "compactdiscs:block/disc_burner_burning",
61+
"y": 270
3262
}
3363
}
3464
}

src/main/java/fn10/musicexpansion/blocks/DiscBurnerBlock.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@
3434
public class DiscBurnerBlock extends RotatedBaseEntityBlock {
3535

3636
public static final BooleanProperty LOADED = BooleanProperty.create("loaded");
37+
public static final BooleanProperty BURNING = BooleanProperty.create("burning");
3738

3839
public DiscBurnerBlock(Properties properties) {
3940
super(properties.noOcclusion());
40-
registerDefaultState(defaultBlockState().setValue(FACING, Direction.NORTH).setValue(LOADED, false));
41+
registerDefaultState(defaultBlockState().setValue(FACING, Direction.NORTH).setValue(LOADED, false).setValue(BURNING, false));
4142
}
4243

4344
@Override
@@ -101,6 +102,7 @@ public BlockState getBaseStateForPlacement(BlockPlaceContext blockPlaceContext)
101102
@Override
102103
public Builder<Block, BlockState> addBlockStateDefinitions(Builder<Block, BlockState> builder) {
103104
builder.add(LOADED);
105+
builder.add(BURNING);
104106
return builder;
105107
}
106108
}

0 commit comments

Comments
 (0)