Skip to content

Commit ca0010a

Browse files
committed
[PORT] Fixes for Forge 1.19.2
1 parent 863d56f commit ca0010a

16 files changed

Lines changed: 191 additions & 23 deletions

src/main/java/com/bokmcdok/butterflies/client/gui/screens/ButterflyTextFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public static FormattedText getFormattedButterflyData(int butterflyIndex) {
118118
component.append("\n");
119119
component.append(Component.translatable("gui.butterflies.preferred_flower"));
120120

121-
Item value = ForgeRegistries.ITEMS.getValue(entry.getFoodSourceItem();
121+
Item value = ForgeRegistries.ITEMS.getValue(entry.getFoodSourceItem());
122122
if (value != null) {
123123
Component description = value.getDescription();
124124
component.append(description);

src/main/java/com/bokmcdok/butterflies/data/loot/ModEntityLootSubProvider.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.bokmcdok.butterflies.registries.ButterflyEntityTypeRegistry;
66
import com.bokmcdok.butterflies.registries.EntityTypeRegistry;
77
import com.bokmcdok.butterflies.registries.ItemRegistry;
8-
import com.bokmcdok.butterflies.butterfly_data.ButterflyData;
98
import net.minecraft.data.loot.EntityLoot;
109
import net.minecraft.world.entity.EntityType;
1110
import net.minecraft.world.item.Items;
@@ -37,8 +36,6 @@ public class ModEntityLootSubProvider extends EntityLoot {
3736
* Construction.
3837
*/
3938
public ModEntityLootSubProvider() {
40-
super(FeatureFlags.REGISTRY.allFlags());
41-
4239
this.silkChrysalises = ButterflyRegistry.getButterflyDataCollection().stream()
4340
.filter(data -> data.hasTrait(ButterflyTrait.SILK))
4441
.map(data -> ButterflyEntityTypeRegistry.CHRYSALISES.get(data.butterflyIndex()).get())
@@ -54,7 +51,7 @@ public ModEntityLootSubProvider() {
5451
* Entry point.
5552
*/
5653
@Override
57-
public void generate() {
54+
public void addTables() {
5855
silkChrysalises.forEach(this::addChrysalisSilkLoot);
5956
add(EntityTypeRegistry.BUTTERFLY_GOLEM.get(), createButterflyGolemLoot());
6057
}
@@ -66,7 +63,7 @@ public void generate() {
6663
*/
6764
@Override
6865
protected boolean isNonLiving(@NotNull EntityType<?> entityType) {
69-
return !knownEntityTypes.contains(entityType) || super.isNonLiving(entityType);
66+
return !knownEntityTypes.contains(entityType) && super.isNonLiving(entityType);
7067
}
7168

7269
/**
@@ -75,8 +72,8 @@ protected boolean isNonLiving(@NotNull EntityType<?> entityType) {
7572
*/
7673
@NotNull
7774
@Override
78-
protected Stream<EntityType<?>> getKnownEntities() {
79-
return knownEntityTypes.stream();
75+
protected Iterable<EntityType<?>> getKnownEntities() {
76+
return knownEntityTypes.stream().toList();
8077
}
8178

8279
/**

src/main/java/com/bokmcdok/butterflies/world/entity/ai/ButterflyConsumeGoal.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.bokmcdok.butterflies.butterfly_data.ButterflyRegistry;
55
import com.bokmcdok.butterflies.world.entity.animal.Butterfly;
66
import net.minecraft.core.BlockPos;
7-
import net.minecraft.core.registries.BuiltInRegistries;
87
import net.minecraft.world.entity.ai.goal.MoveToBlockGoal;
98
import net.minecraft.world.level.Level;
109
import net.minecraft.world.level.LevelReader;
@@ -13,6 +12,7 @@
1312
import net.minecraft.world.level.block.state.properties.IntegerProperty;
1413
import net.minecraft.world.level.block.state.properties.Property;
1514
import net.minecraft.world.phys.Vec3;
15+
import net.minecraftforge.registries.ForgeRegistries;
1616
import org.jetbrains.annotations.NotNull;
1717
import org.jetbrains.annotations.Nullable;
1818

@@ -42,7 +42,6 @@ public class ButterflyConsumeGoal extends MoveToBlockGoal {
4242
* @param searchRange The range to search for blocks.
4343
* @param verticalSearchRange The vertical range to search for blocks.
4444
*/
45-
@SuppressWarnings("deprecation")
4645
public ButterflyConsumeGoal(Butterfly mob,
4746
double speedModifier,
4847
int searchRange,
@@ -52,7 +51,7 @@ public ButterflyConsumeGoal(Butterfly mob,
5251

5352
ButterflyData data = ButterflyRegistry.getEntry(butterfly.getButterflyIndex());
5453
if (data != null) {
55-
foodSource = BuiltInRegistries.BLOCK.get(data.foodSource());
54+
foodSource = ForgeRegistries.BLOCKS.getValue(data.foodSource());
5655
}
5756
}
5857

@@ -118,7 +117,7 @@ public void tick() {
118117
butterfly.setDeltaMovement(0.0, delta.y, 0.0);
119118

120119
if (!hasTried) {
121-
Level level = mob.level();
120+
Level level = mob.level;
122121
BlockState state = level.getBlockState(blockPos);
123122

124123
if (tryEatTarget(level, state)) {

src/main/java/com/bokmcdok/butterflies/world/entity/ai/ButterflyFeedAndPollinateGoal.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.bokmcdok.butterflies.world.block.entity.ButterflyFeederEntity;
77
import com.bokmcdok.butterflies.world.entity.animal.Butterfly;
88
import net.minecraft.core.BlockPos;
9-
import net.minecraft.core.registries.BuiltInRegistries;
109
import net.minecraft.tags.BlockTags;
1110
import net.minecraft.util.RandomSource;
1211
import net.minecraft.world.entity.ai.goal.MoveToBlockGoal;
@@ -17,6 +16,7 @@
1716
import net.minecraft.world.level.block.Blocks;
1817
import net.minecraft.world.level.block.state.BlockState;
1918
import net.minecraft.world.phys.Vec3;
19+
import net.minecraftforge.registries.ForgeRegistries;
2020
import org.jetbrains.annotations.NotNull;
2121

2222
import java.util.Map;
@@ -42,7 +42,6 @@ public class ButterflyFeedAndPollinateGoal extends MoveToBlockGoal {
4242
Map.entry(Blocks.PINK_TULIP, BlockRegistry.PINK_TULIP_BUD),
4343
Map.entry(Blocks.POPPY, BlockRegistry.POPPY_BUD),
4444
Map.entry(Blocks.RED_TULIP, BlockRegistry.RED_TULIP_BUD),
45-
Map.entry(Blocks.TORCHFLOWER, () -> Blocks.TORCHFLOWER_CROP),
4645
Map.entry(Blocks.WHITE_TULIP, BlockRegistry.WHITE_TULIP_BUD),
4746
Map.entry(Blocks.WITHER_ROSE, BlockRegistry.WITHER_ROSE_BUD),
4847
Map.entry(Blocks.SWEET_BERRY_BUSH, () -> Blocks.SWEET_BERRY_BUSH)
@@ -79,8 +78,8 @@ public ButterflyFeedAndPollinateGoal(Butterfly mob,
7978

8079
ButterflyData data = ButterflyRegistry.getEntry(butterfly.getButterflyIndex());
8180
if (data != null) {
82-
foodSourceBlock = BuiltInRegistries.BLOCK.get(data.foodSource());
83-
foodSourceItem = BuiltInRegistries.ITEM.get(data.getFoodSourceItem());
81+
foodSourceBlock = ForgeRegistries.BLOCKS.getValue(data.foodSource());
82+
foodSourceItem = ForgeRegistries.ITEMS.getValue(data.getFoodSourceItem());
8483
} else {
8584
foodSourceBlock = null;
8685
foodSourceItem = null;
@@ -233,11 +232,7 @@ private BlockPos findNearestFlowerSpot() {
233232

234233
// Torchflowers require farmland.
235234
Block requiredBlock = Blocks.GRASS_BLOCK;
236-
Level level = mob.level();
237-
if (level.getBlockState(blockPos).is(Blocks.TORCHFLOWER)) {
238-
requiredBlock = Blocks.FARMLAND;
239-
}
240-
235+
Level level = mob.level;
241236
if (level.getBlockState(mutableBlockPos).isAir() &&
242237
level.getBlockState(mutableBlockPos.below()).is(requiredBlock)) {
243238

@@ -255,7 +250,7 @@ private BlockPos findNearestFlowerSpot() {
255250
* Attempt to eat from a butterfly feeder.
256251
*/
257252
private void tryEatFromFeeder() {
258-
Level level = butterfly.level();
253+
Level level = butterfly.level;
259254
if (!(level.getBlockEntity(blockPos) instanceof ButterflyFeederEntity feeder)) {
260255
return;
261256
}
@@ -272,7 +267,7 @@ private void tryEatFromFeeder() {
272267
* Attempt to pollinate a flower.
273268
*/
274269
private void tryPollinateFlower() {
275-
Level level = butterfly.level();
270+
Level level = butterfly.level;
276271
BlockState blockState = level.getBlockState(blockPos);
277272
Block flowerBlock = blockState.getBlock();
278273
if (!FLOWER_BUDS.containsKey(flowerBlock)) {

src/main/resources/data/butterflies/advancements/butterfly/bottle_all_larvae.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@
144144
},
145145
"trigger": "minecraft:inventory_changed"
146146
},
147+
"orizaba": {
148+
"conditions": {
149+
"items": [
150+
{
151+
"items": [
152+
"butterflies:bottled_caterpillar_orizaba"
153+
]
154+
}
155+
]
156+
},
157+
"trigger": "minecraft:inventory_changed"
158+
},
147159
"peppered": {
148160
"conditions": {
149161
"items": [
@@ -234,6 +246,9 @@
234246
[
235247
"oak-silk"
236248
],
249+
[
250+
"orizaba"
251+
],
237252
[
238253
"peppered"
239254
],

src/main/resources/data/butterflies/advancements/butterfly/bottle_all_moths.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@
144144
},
145145
"trigger": "minecraft:inventory_changed"
146146
},
147+
"orizaba": {
148+
"conditions": {
149+
"items": [
150+
{
151+
"items": [
152+
"butterflies:bottled_butterfly_orizaba"
153+
]
154+
}
155+
]
156+
},
157+
"trigger": "minecraft:inventory_changed"
158+
},
147159
"peppered": {
148160
"conditions": {
149161
"items": [
@@ -246,6 +258,9 @@
246258
[
247259
"oak-silk"
248260
],
261+
[
262+
"orizaba"
263+
],
249264
[
250265
"peppered"
251266
],

src/main/resources/data/butterflies/advancements/butterfly/bottle_larva.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@
144144
},
145145
"trigger": "minecraft:inventory_changed"
146146
},
147+
"orizaba": {
148+
"conditions": {
149+
"items": [
150+
{
151+
"items": [
152+
"butterflies:bottled_caterpillar_orizaba"
153+
]
154+
}
155+
]
156+
},
157+
"trigger": "minecraft:inventory_changed"
158+
},
147159
"peppered": {
148160
"conditions": {
149161
"items": [
@@ -211,6 +223,7 @@
211223
"indianmeal",
212224
"luna",
213225
"oak-silk",
226+
"orizaba",
214227
"peppered",
215228
"spongy",
216229
"white-lined-sphinx"

src/main/resources/data/butterflies/advancements/butterfly/bottle_moth.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@
144144
},
145145
"trigger": "minecraft:inventory_changed"
146146
},
147+
"orizaba": {
148+
"conditions": {
149+
"items": [
150+
{
151+
"items": [
152+
"butterflies:bottled_butterfly_orizaba"
153+
]
154+
}
155+
]
156+
},
157+
"trigger": "minecraft:inventory_changed"
158+
},
147159
"peppered": {
148160
"conditions": {
149161
"items": [
@@ -223,6 +235,7 @@
223235
"indianmeal",
224236
"luna",
225237
"oak-silk",
238+
"orizaba",
226239
"peppered",
227240
"spongy",
228241
"white-lined-sphinx",

src/main/resources/data/butterflies/advancements/butterfly/catch_all_moths.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@
144144
},
145145
"trigger": "minecraft:inventory_changed"
146146
},
147+
"orizaba": {
148+
"conditions": {
149+
"items": [
150+
{
151+
"items": [
152+
"butterflies:butterfly_net_orizaba"
153+
]
154+
}
155+
]
156+
},
157+
"trigger": "minecraft:inventory_changed"
158+
},
147159
"peppered": {
148160
"conditions": {
149161
"items": [
@@ -246,6 +258,9 @@
246258
[
247259
"oak-silk"
248260
],
261+
[
262+
"orizaba"
263+
],
249264
[
250265
"peppered"
251266
],

src/main/resources/data/butterflies/advancements/butterfly/catch_moth.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@
144144
},
145145
"trigger": "minecraft:inventory_changed"
146146
},
147+
"orizaba": {
148+
"conditions": {
149+
"items": [
150+
{
151+
"items": [
152+
"butterflies:butterfly_net_orizaba"
153+
]
154+
}
155+
]
156+
},
157+
"trigger": "minecraft:inventory_changed"
158+
},
147159
"peppered": {
148160
"conditions": {
149161
"items": [
@@ -223,6 +235,7 @@
223235
"indianmeal",
224236
"luna",
225237
"oak-silk",
238+
"orizaba",
226239
"peppered",
227240
"spongy",
228241
"white-lined-sphinx",

0 commit comments

Comments
 (0)