Skip to content

Commit 0f644ee

Browse files
committed
Merge branch 'Minecraft-1.20.1' into Minecraft-1.19.2
2 parents 897228b + 6913b5e commit 0f644ee

1,817 files changed

Lines changed: 2378 additions & 41455 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@ jobs: #The place where you actually
3030
if: ${{ runner.os != 'Windows' }}
3131
run: chmod +x ./gradlew
3232

33+
- name: Build Data
34+
run: ./gradlew runData
35+
3336
- name: Build
3437
run: ./gradlew clean build --info

.github/workflows/publish.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ jobs:
116116
restore-keys: |
117117
${{ runner.os }}-gradle-
118118
119+
# Build the data using datagen
120+
- name: Build Data
121+
run: ./gradlew runData
122+
119123
# Build the project using Gradle clean and build tasks
120124
- name: Build
121125
run: ./gradlew clean build

.github/workflows/qodana_code_quality.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ forge*changelog.txt
3232
*.bbmodel
3333

3434
# Python
35-
__pycache__
35+
__pycache__
36+
37+
# Files from data generation
38+
run-data
39+
/src/generated/

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
## Changelog
22

3+
### 7.7.2 (2026-06-28)
4+
- No longer a need to commit generated resources.
5+
6+
### 7.7.1 (2026-06-28)
7+
- Fixed Bottled Peacemaker Butterflies not actually being bottled.
8+
9+
### 7.7.0 (2026-06-19)
10+
- Mod now uses data generation properly.
11+
312
### 7.6.0 (2026-06-04)
413
- Added the Smile Butterfly.
514

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ mod_name=Butterfly Mod
4848
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
4949
mod_license=All Rights Reserved
5050
# The mod version. See https://semver.org/
51-
mod_version=7.6.0
51+
mod_version=7.7.2
5252
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
5353
# This should match the base package used for the mod sources.
5454
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
package com.bokmcdok.butterflies.client.model.generators;
2+
3+
import com.bokmcdok.butterflies.ButterfliesMod;
4+
import com.bokmcdok.butterflies.registries.BlockRegistry;
5+
import com.bokmcdok.butterflies.world.block.ButterflyOrigamiBlock;
6+
import com.bokmcdok.butterflies.world.block.FlowerCropBlock;
7+
import net.minecraft.core.FrontAndTop;
8+
import net.minecraft.data.PackOutput;
9+
import net.minecraft.resources.ResourceLocation;
10+
import net.minecraft.world.level.block.Block;
11+
import net.minecraft.world.level.block.CropBlock;
12+
import net.minecraft.world.level.block.state.BlockState;
13+
import net.minecraftforge.client.model.generators.BlockStateProvider;
14+
import net.minecraftforge.client.model.generators.ConfiguredModel;
15+
import net.minecraftforge.client.model.generators.ModelFile;
16+
import net.minecraftforge.common.data.ExistingFileHelper;
17+
import net.minecraftforge.registries.RegistryObject;
18+
19+
import java.util.List;
20+
import java.util.function.Function;
21+
22+
/**
23+
* Registers block states.
24+
*/
25+
public class ModBlockStateProvider extends BlockStateProvider {
26+
27+
/**
28+
* Construction.
29+
* @param output The pack to output data to.
30+
* @param existingFileHelper Helper to access existing files.
31+
*/
32+
public ModBlockStateProvider(PackOutput output,
33+
ExistingFileHelper existingFileHelper) {
34+
super(output, ButterfliesMod.MOD_ID, existingFileHelper);
35+
}
36+
37+
/**
38+
* Entry point.
39+
*/
40+
@Override
41+
protected void registerStatesAndModels() {
42+
43+
// Bottled items
44+
for (int i = 0; i < BlockRegistry.BOTTLED_BUTTERFLY_BLOCKS.size(); i++) {
45+
registerBottledButterfly(i);
46+
registerBottledCaterpillar(i);
47+
}
48+
49+
// Flower buds
50+
registerFlowerBud(BlockRegistry.ALLIUM_BUD);
51+
registerFlowerBud(BlockRegistry.AZURE_BLUET_BUD);
52+
registerFlowerBud(BlockRegistry.BLUE_ORCHID_BUD);
53+
registerFlowerBud(BlockRegistry.CORNFLOWER_BUD);
54+
registerFlowerBud(BlockRegistry.DANDELION_BUD);
55+
registerFlowerBud(BlockRegistry.LILY_OF_THE_VALLEY_BUD);
56+
registerFlowerBud(BlockRegistry.ORANGE_TULIP_BUD);
57+
registerFlowerBud(BlockRegistry.OXEYE_DAISY_BUD);
58+
registerFlowerBud(BlockRegistry.PINK_TULIP_BUD);
59+
registerFlowerBud(BlockRegistry.POPPY_BUD);
60+
registerFlowerBud(BlockRegistry.RED_TULIP_BUD);
61+
registerFlowerBud(BlockRegistry.WHITE_TULIP_BUD);
62+
registerFlowerBud(BlockRegistry.WITHER_ROSE_BUD);
63+
64+
// Functional Blocks
65+
simpleBlockWithItem(BlockRegistry.BUTTERFLY_FEEDER.get(), models().getExistingFile(BlockRegistry.BUTTERFLY_FEEDER.getId()));
66+
simpleBlockWithItem(BlockRegistry.BUTTERFLY_MICROSCOPE.get(), models().getExistingFile(BlockRegistry.BUTTERFLY_MICROSCOPE.getId()));
67+
68+
// Origami
69+
for(RegistryObject<Block> origami : BlockRegistry.BUTTERFLY_ORIGAMI) {
70+
registerButterflyOrigami(origami);
71+
}
72+
}
73+
74+
/**
75+
* Registers a bottled butterfly.
76+
* @param index The butterfly index.
77+
*/
78+
private void registerBottledButterfly(int index) {
79+
registerBottledEntity(index, BlockRegistry.BOTTLED_BUTTERFLY_BLOCKS);
80+
}
81+
82+
/**
83+
* Registers a bottled caterpillar.
84+
* @param index The butterfly index.
85+
*/
86+
private void registerBottledCaterpillar(int index) {
87+
registerBottledEntity(index, BlockRegistry.BOTTLED_CATERPILLAR_BLOCKS);
88+
}
89+
90+
/**
91+
* Registers a bottled entity.
92+
* @param index The butterfly index.
93+
* @param blocks The block list to register from.
94+
*/
95+
private void registerBottledEntity(int index,
96+
List<RegistryObject<Block>> blocks) {
97+
final ModelFile bottleModel = models().getExistingFile(new ResourceLocation(ButterfliesMod.MOD_ID, "bottle"));
98+
simpleBlock(blocks.get(index).get(), bottleModel);
99+
}
100+
101+
/**
102+
* Registers a flower bud block state.
103+
* @param block The block to create a block state for.
104+
*/
105+
private void registerFlowerBud(RegistryObject<Block> block) {
106+
107+
if (block.get() instanceof FlowerCropBlock flowerBud) {
108+
109+
// This should never be null.
110+
assert block.getId() != null;
111+
112+
String textureName = block.getId().getPath().substring(4);
113+
114+
Function<BlockState, ConfiguredModel[]> function =
115+
state -> generateCropState(state, flowerBud, textureName);
116+
117+
getVariantBuilder(flowerBud).forAllStates(function);
118+
}
119+
}
120+
121+
private void registerButterflyOrigami(RegistryObject<Block> block) {
122+
123+
Function<BlockState, ConfiguredModel[]> function =
124+
state -> generateOrientationState(state, block);
125+
126+
getVariantBuilder(block.get()).forAllStates(function);
127+
}
128+
129+
/**
130+
* Generates a block state variant for a specific age.
131+
* @param state The current block state.
132+
* @param block The block to generate.
133+
* @param textureName The name of the texture to use.
134+
* @return A new variant of the block state.
135+
*/
136+
private ConfiguredModel[] generateCropState(BlockState state,
137+
CropBlock block,
138+
String textureName) {
139+
ConfiguredModel[] models = new ConfiguredModel[1];
140+
int age = Math.min(state.getValue(((FlowerCropBlock) block).getAgeProperty()), 6);
141+
if (age < 5 && textureName.contains("tulip")) {
142+
textureName = "tulip";
143+
}
144+
145+
models[0] = new ConfiguredModel(models().cross("block/flower_buds/" + textureName +"_stage" + age,
146+
new ResourceLocation(ButterfliesMod.MOD_ID, "block/flower_bud/" + textureName +"_stage" + age)).renderType("cutout"));
147+
148+
return models;
149+
}
150+
151+
/**
152+
* Generates a block state variant based on orientation.
153+
* @param state The current block state.
154+
* @param block The block to generate.
155+
* @return A new variant of the block state.
156+
*/
157+
private ConfiguredModel[] generateOrientationState(BlockState state,
158+
RegistryObject<Block> block) {
159+
ConfiguredModel[] models = new ConfiguredModel[1];
160+
FrontAndTop orientation = state.getValue(ButterflyOrigamiBlock.ORIENTATION);
161+
int x = 0;
162+
int y = 0;
163+
switch (orientation) {
164+
case DOWN_EAST:
165+
x = 180;
166+
y = 270;
167+
break;
168+
169+
case DOWN_NORTH:
170+
x = 180;
171+
y = 180;
172+
break;
173+
174+
case DOWN_SOUTH:
175+
x = 180;
176+
break;
177+
178+
case DOWN_WEST:
179+
x = 180;
180+
y = 90;
181+
break;
182+
183+
case EAST_UP:
184+
x = 270;
185+
y = 270;
186+
break;
187+
188+
case NORTH_UP:
189+
x = 270;
190+
y = 180;
191+
break;
192+
193+
case SOUTH_UP:
194+
x = 270;
195+
break;
196+
197+
case UP_EAST:
198+
y = 270;
199+
break;
200+
201+
case UP_NORTH:
202+
y = 180;
203+
break;
204+
205+
case UP_SOUTH:
206+
break;
207+
208+
case UP_WEST:
209+
y = 90;
210+
break;
211+
212+
case WEST_UP:
213+
x = 270;
214+
y = 90;
215+
break;
216+
}
217+
218+
// This should never be null.
219+
assert block.getId() != null;
220+
221+
final ResourceLocation parent = new ResourceLocation(ButterfliesMod.MOD_ID, "block/butterfly_origami");
222+
String path = block.getId().getPath();
223+
models[0] = new ConfiguredModel(
224+
models().withExistingParent("block/" + path, parent).texture("all", new ResourceLocation("block/" + path.substring(18) + "_wool")),
225+
x, y, false);
226+
227+
simpleBlockItem(block.get(), models[0].model);
228+
229+
return models;
230+
}
231+
}

0 commit comments

Comments
 (0)