Skip to content

Commit 4be9e90

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 0f9268a + e771d5a commit 4be9e90

Some content is hidden

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

44 files changed

+823
-326
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ dependencies {
6161
modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:${rei_version}")
6262

6363
modCompileOnly "maven.modrinth:yttr:${yttr_version}"
64-
//modLocalRuntime "maven.modrinth:yttr:${yttr_version}"
64+
modLocalRuntime "maven.modrinth:yttr:${yttr_version}"
6565

6666
modImplementation("com.simibubi.create:create-fabric-1.18.2:${create_version}")
6767

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ org.gradle.jvmargs=-Xmx2G
2323

2424
# Development QOL
2525
modmenu_version=3.2.5
26-
rei_version=8.3.588
26+
rei_version=8.3.594
2727

2828
# yttr
2929
yttr_version = 7.626+1.18.2

src/main/java/com/github/ethanicuss/astraladditions/AstralAdditions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.ethanicuss.astraladditions;
22

3+
import com.github.ethanicuss.astraladditions.registry.ModFanProcessingType;
34
import com.github.ethanicuss.astraladditions.registry.ModEntities;
45
import com.github.ethanicuss.astraladditions.registry.ModFluids;
56
import com.github.ethanicuss.astraladditions.registry.ModParticles;
@@ -28,6 +29,7 @@ public void onInitialize() {
2829
ModEffects.registerEffects();
2930
ModParticles.registerParticles();
3031
ModPotion.registerPotions();
32+
ModFanProcessingType.registerFanProcess();
3133
LOGGER.info("Astral Additions is active!");
3234
}
3335
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
package com.github.ethanicuss.astraladditions.compat.create;
2+
3+
import com.github.ethanicuss.astraladditions.registry.ModFluids;
4+
import com.github.ethanicuss.astraladditions.registry.ModParticles;
5+
import com.github.ethanicuss.astraladditions.recipes.TransmuteRecipe;
6+
import com.jozufozu.flywheel.util.Color;
7+
import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
8+
import net.minecraft.entity.Entity;
9+
import net.minecraft.entity.LivingEntity;
10+
import net.minecraft.entity.effect.StatusEffectInstance;
11+
import net.minecraft.entity.effect.StatusEffects;
12+
import net.minecraft.fluid.FluidState;
13+
import net.minecraft.item.ItemStack;
14+
import net.minecraft.particle.ParticleTypes;
15+
import net.minecraft.util.math.BlockPos;
16+
import net.minecraft.util.math.Vec3d;
17+
import net.minecraft.world.World;
18+
import org.jetbrains.annotations.Nullable;
19+
20+
import java.util.ArrayList;
21+
import java.util.List;
22+
import java.util.Optional;
23+
import java.util.Random;
24+
25+
public class ShimmerTransmuteType implements FanProcessingType {
26+
27+
@Override
28+
public int getPriority() {
29+
return 450;
30+
}
31+
32+
@Override
33+
public boolean isValidAt(World world, BlockPos pos) {
34+
FluidState fluid = world.getFluidState(pos);
35+
return fluid.isStill() && fluid.getFluid() == ModFluids.STILL_SHIMMER || fluid.getFluid() == ModFluids.FLOWING_SHIMMER;
36+
}
37+
38+
@Override
39+
public boolean canProcess(ItemStack stack, World world) {
40+
return world.getRecipeManager()
41+
.listAllOfType(TransmuteRecipe.Type.INSTANCE)
42+
.stream()
43+
.map(r -> (TransmuteRecipe) r)
44+
.anyMatch(r -> matchesRecipeInput(stack, r));
45+
}
46+
47+
@Override
48+
@Nullable
49+
public List<ItemStack> process(ItemStack stack, World world) {
50+
Optional<TransmuteRecipe> recipeOpt = world.getRecipeManager()
51+
.listAllOfType(TransmuteRecipe.Type.INSTANCE)
52+
.stream()
53+
.map(r -> (TransmuteRecipe) r)
54+
.filter(r -> matchesRecipeInput(stack, r))
55+
.findFirst();
56+
57+
if (recipeOpt.isEmpty()) return null;
58+
59+
TransmuteRecipe recipe = recipeOpt.get();
60+
ItemStack required = recipe.getInputItem();
61+
62+
int multiplier = 1;
63+
64+
if (!recipe.isIgnoreCount()) {
65+
if (recipe.isSoftIgnoreCount()) {
66+
multiplier = stack.getCount() / required.getCount();
67+
} else {
68+
if (stack.getCount() != required.getCount()) return null;
69+
}
70+
}
71+
72+
List<ItemStack> result = new ArrayList<>();
73+
for (ItemStack output : recipe.getOutputItems()) {
74+
ItemStack out = output.copy();
75+
out.setCount(out.getCount() * multiplier);
76+
result.add(out);
77+
}
78+
79+
return result;
80+
}
81+
82+
private boolean matchesRecipeInput(ItemStack stack, TransmuteRecipe recipe) {
83+
ItemStack required = recipe.getInputItem();
84+
85+
if (recipe.isIgnoreCount()) {
86+
return stack.getItem() == required.getItem();
87+
} else if (recipe.isSoftIgnoreCount()) {
88+
return stack.getItem() == required.getItem()
89+
&& stack.getCount() >= required.getCount();
90+
} else {
91+
return stack.getItem() == required.getItem()
92+
&& stack.getCount() == required.getCount();
93+
}
94+
}
95+
96+
@Override
97+
public void spawnProcessingParticles(World world, Vec3d pos) {
98+
if (world.random.nextInt(6) != 0) return;
99+
world.addParticle(ParticleTypes.ENCHANT, pos.x, pos.y + .3, pos.z, 0, .1, 0);
100+
}
101+
102+
103+
@Override
104+
public void morphAirFlow(AirFlowParticleAccess particleAccess, Random random) {
105+
particleAccess.setColor(Color.mixColors(0xf543bc, 0xf993c5, random.nextFloat()));
106+
particleAccess.setAlpha(0.75f);
107+
if (random.nextFloat() < 1 / 128f)
108+
particleAccess.spawnExtraParticle(ModParticles.SHIMMER_BUBBLE, .125f);
109+
if (random.nextFloat() < 1 / 128f)
110+
particleAccess.spawnExtraParticle(ModParticles.SHIMMER_BUBBLE_POP, .125f);
111+
}
112+
113+
114+
@Override
115+
public void affectEntity(Entity entity, World world) {
116+
if (!(entity instanceof LivingEntity living)) return;
117+
living.addStatusEffect(new StatusEffectInstance(StatusEffects.GLOWING, 60, 0, false, false));
118+
living.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 330, 0, false, false));
119+
120+
121+
}
122+
}

src/main/java/com/github/ethanicuss/astraladditions/compat/rei/AstralAdditionsREIClientPlugin.java

Lines changed: 69 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.github.ethanicuss.astraladditions.compat.rei;
22

3-
43
import com.github.ethanicuss.astraladditions.AstralAdditions;
4+
import com.github.ethanicuss.astraladditions.compat.rei.create.BulkShimmeringCategory;
55
import com.github.ethanicuss.astraladditions.compat.rei.desizer.DesizerCategory;
66
import com.github.ethanicuss.astraladditions.compat.rei.desizer.DesizerDisplay;
77
import com.github.ethanicuss.astraladditions.compat.rei.transmute.TransmuteCategory;
@@ -24,6 +24,13 @@
2424
import com.github.ethanicuss.astraladditions.recipes.ChromaticVacuumRecipe;
2525
import com.github.ethanicuss.astraladditions.registry.ModBlocks;
2626
import com.github.ethanicuss.astraladditions.registry.ModItems;
27+
import com.simibubi.create.AllBlocks;
28+
import com.simibubi.create.AllItems;
29+
import com.simibubi.create.compat.rei.DoubleItemIcon;
30+
import com.simibubi.create.compat.rei.EmptyBackground;
31+
import com.simibubi.create.compat.rei.category.CreateRecipeCategory;
32+
import com.simibubi.create.compat.rei.display.CreateDisplay;
33+
import com.unascribed.yttr.crafting.*;
2734
import com.unascribed.yttr.init.YEnchantments;
2835
import com.unascribed.yttr.init.YItems;
2936
import com.unascribed.yttr.init.YRecipeTypes;
@@ -33,24 +40,27 @@
3340
import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry;
3441
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
3542
import me.shedaniel.rei.api.common.util.EntryStacks;
36-
import net.minecraft.client.MinecraftClient;
43+
import net.fabricmc.api.EnvType;
44+
import net.fabricmc.api.Environment;
3745
import net.minecraft.enchantment.EnchantmentHelper;
3846
import net.minecraft.item.ItemStack;
3947
import net.minecraft.item.Items;
4048
import net.minecraft.nbt.NbtCompound;
4149
import net.minecraft.nbt.NbtList;
4250
import net.minecraft.nbt.NbtString;
43-
import net.minecraft.recipe.RecipeManager;
4451
import net.minecraft.recipe.RecipeType;
52+
import net.minecraft.recipe.StonecuttingRecipe;
4553
import net.minecraft.text.Style;
4654
import net.minecraft.text.Text;
4755
import net.minecraft.text.TranslatableText;
4856
import net.minecraft.util.Formatting;
4957
import net.minecraft.util.Identifier;
5058

59+
import java.util.Collections;
5160
import java.util.List;
5261
import java.util.Map;
5362

63+
@Environment(EnvType.CLIENT)
5464
public class AstralAdditionsREIClientPlugin implements REIClientPlugin {
5565
public static final CategoryIdentifier<DesizerDisplay> DESIZER = CategoryIdentifier.of(new Identifier(AstralAdditions.MOD_ID, "desizer"));
5666

@@ -65,6 +75,9 @@ public class AstralAdditionsREIClientPlugin implements REIClientPlugin {
6575
public static final CategoryIdentifier<VoidFilteringDisplay> VOID_FILTERING = CategoryIdentifier.of(new Identifier(AstralAdditions.MOD_ID, "void_filtering"));
6676
public static final CategoryIdentifier<ShatteringDisplay> SHATTERING = CategoryIdentifier.of(new Identifier(AstralAdditions.MOD_ID, "shattering"));
6777

78+
//* Create
79+
public static final CategoryIdentifier<CreateDisplay<TransmuteRecipe>> BULK_SHIMMERING = CategoryIdentifier.of(new Identifier(AstralAdditions.MOD_ID, "bulk_shimmering"));
80+
6881
@Override
6982
public void registerCategories(CategoryRegistry registry) {
7083
registry.add(new DesizerCategory());
@@ -103,53 +116,70 @@ public void registerCategories(CategoryRegistry registry) {
103116

104117
registry.addWorkstations(SHATTERING, EntryStacks.of(shatteringBook));
105118

119+
CreateRecipeCategory.Info<TransmuteRecipe> shimmerInfo = new CreateRecipeCategory.Info<>(BULK_SHIMMERING, new TranslatableText("category.astraladditions.bulk_shimmering"), new EmptyBackground(178, 110),
120+
new DoubleItemIcon(() -> new ItemStack(AllItems.PROPELLER.get()), () -> new ItemStack(ModFluids.SHIMMER_BUCKET)),
121+
Collections::emptyList,
122+
List.of(() -> new ItemStack(AllItems.PROPELLER.get()), () -> new ItemStack(ModFluids.SHIMMER_BUCKET)),
123+
178, 110, recipe -> new CreateDisplay<>(recipe, BULK_SHIMMERING));
124+
125+
BulkShimmeringCategory bulkShimmeringCategory = new BulkShimmeringCategory(shimmerInfo);
126+
registry.add(bulkShimmeringCategory);
127+
128+
registry.addWorkstations(BULK_SHIMMERING, EntryStacks.of(AllBlocks.ENCASED_FAN.get()));
106129
}
107130

108131
@Override
109132
public void registerDisplays(DisplayRegistry registry) {
110-
RecipeManager recipeManager = MinecraftClient.getInstance().world.getRecipeManager();
133+
registry.registerRecipeFiller(DesizerRecipe.class, DesizerRecipe.Type.INSTANCE, DesizerDisplay::of);
111134

112-
List<DesizerDisplay> desizerRecipes = recipeManager.listAllOfType(DesizerRecipe.Type.INSTANCE).stream().map(DesizerDisplay::of).toList();
113-
desizerRecipes.forEach(registry::add);
135+
registry.registerRecipeFiller(TransmuteRecipe.class, TransmuteRecipe.Type.INSTANCE, TransmuteDisplay::of);
114136

115-
List<TransmuteDisplay> transmuteRecipes = recipeManager.listAllOfType(TransmuteRecipe.Type.INSTANCE).stream().map(TransmuteDisplay::of).toList();
116-
transmuteRecipes.forEach(registry::add);
117-
118-
registry.registerFiller(ChromaticVacuumRecipe.class, VacuumDisplay::of);
137+
registry.registerRecipeFiller(ChromaticVacuumRecipe.class, ChromaticVacuumRecipe.Type.INSTANCE, VacuumDisplay::of);
119138

120139
//* YTTR
121-
List<CentrifugeDisplay> centrifugeRecipes = recipeManager.listAllOfType(YRecipeTypes.CENTRIFUGING).stream().map(CentrifugeDisplay::of).toList();
122-
centrifugeRecipes.forEach(registry::add);
123-
124-
List<PistonSmashingDisplay> pistonSmashingRecipes = recipeManager.listAllOfType(YRecipeTypes.PISTON_SMASHING).stream().map(PistonSmashingDisplay::of).toList();
125-
pistonSmashingRecipes.forEach(registry::add);
126-
127-
List<SoakingDisplay> soakingRecipes = recipeManager.listAllOfType(YRecipeTypes.SOAKING).stream().map(SoakingDisplay::of).toList();
128-
soakingRecipes.forEach(registry::add);
129-
130-
List<VoidFilteringDisplay> voidFilteringRecipe = recipeManager.listAllOfType(YRecipeTypes.VOID_FILTERING).stream().map(VoidFilteringDisplay::of).toList();
131-
voidFilteringRecipe.forEach(registry::add);
132-
133-
//Shattering stuff
134-
List<ShatteringDisplay> shatteringRecipes = recipeManager.listAllOfType(YRecipeTypes.SHATTERING).stream()
135-
.map(ShatteringDisplay::of)
136-
.toList();
137-
shatteringRecipes.forEach(registry::add);
138-
139-
List<ShatteringDisplay> shatteringstonecuttingRecipes = recipeManager.listAllOfType(RecipeType.STONECUTTING).stream()
140-
.filter(r -> r.getOutput().getCount() == 1 && !r.getIngredients().isEmpty())
141-
.map(ShatteringDisplay::of)
142-
.toList();
143-
shatteringstonecuttingRecipes.forEach(registry::add);
144-
145-
List<ShatteringDisplay> shatteringoneByOneCraftingRecipes = recipeManager.listAllOfType(RecipeType.CRAFTING).stream()
146-
.filter(r -> r.fits(1, 1) && !r.getIngredients().isEmpty())
147-
.map(ShatteringDisplay::of)
148-
.toList();
149-
shatteringoneByOneCraftingRecipes.forEach(registry::add);
140+
registry.registerRecipeFiller(CentrifugingRecipe.class, YRecipeTypes.CENTRIFUGING, CentrifugeDisplay::of);
141+
142+
registry.registerRecipeFiller(PistonSmashingRecipe.class, YRecipeTypes.PISTON_SMASHING, PistonSmashingDisplay::of);
143+
144+
registry.registerRecipeFiller(SoakingRecipe.class, YRecipeTypes.SOAKING, SoakingDisplay::of);
145+
146+
registry.registerRecipeFiller(VoidFilteringRecipe.class, YRecipeTypes.VOID_FILTERING, VoidFilteringDisplay::of);
147+
148+
registry.registerRecipeFiller(ShatteringRecipe.class, YRecipeTypes.SHATTERING, ShatteringDisplay::of);
149+
150+
registry.registerRecipeFiller(StonecuttingRecipe.class, RecipeType.STONECUTTING, ShatteringDisplay::ofStonecutting);
151+
152+
registry.registerRecipeFiller(
153+
net.minecraft.recipe.CraftingRecipe.class,
154+
RecipeType.CRAFTING,
155+
recipe -> {
156+
if (recipe instanceof ShatteringRecipe) return null;
157+
158+
if (recipe.getIngredients().size() != 1) return null;
159+
if (recipe.getIngredients().get(0).isEmpty()) return null;
160+
161+
ItemStack out = recipe.getOutput();
162+
if (out.isEmpty()) return null;
163+
164+
return ShatteringDisplay.ofWrappedCrafting(recipe);
165+
}
166+
);
167+
168+
registry.registerRecipeFiller(
169+
TransmuteRecipe.class,
170+
TransmuteRecipe.Type.INSTANCE,
171+
recipe -> {
172+
ItemStack out = recipe.getOutput();
173+
if (out == null || out.isEmpty()) {
174+
return null;
175+
}
176+
return new CreateDisplay<>(recipe, BULK_SHIMMERING);
177+
}
178+
);
150179
}
151180

152181

182+
153183
@Override
154184
public void registerScreens(ScreenRegistry registry) {
155185
REIClientPlugin.super.registerScreens(registry);

0 commit comments

Comments
 (0)