Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dependencies {
modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:${rei_version}")

modCompileOnly "maven.modrinth:yttr:${yttr_version}"
//modLocalRuntime "maven.modrinth:yttr:${yttr_version}"
modLocalRuntime "maven.modrinth:yttr:${yttr_version}"

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

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ org.gradle.jvmargs=-Xmx2G

# Development QOL
modmenu_version=3.2.5
rei_version=8.3.588
rei_version=8.3.594

# yttr
yttr_version = 7.626+1.18.2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.ethanicuss.astraladditions;

import com.github.ethanicuss.astraladditions.registry.ModFanProcessingType;
import com.github.ethanicuss.astraladditions.registry.ModEntities;
import com.github.ethanicuss.astraladditions.registry.ModFluids;
import com.github.ethanicuss.astraladditions.registry.ModParticles;
Expand Down Expand Up @@ -28,6 +29,7 @@ public void onInitialize() {
ModEffects.registerEffects();
ModParticles.registerParticles();
ModPotion.registerPotions();
ModFanProcessingType.registerFanProcess();
LOGGER.info("Astral Additions is active!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package com.github.ethanicuss.astraladditions.compat.create;

import com.github.ethanicuss.astraladditions.registry.ModFluids;
import com.github.ethanicuss.astraladditions.registry.ModParticles;
import com.github.ethanicuss.astraladditions.recipes.TransmuteRecipe;
import com.jozufozu.flywheel.util.Color;
import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.fluid.FluidState;
import net.minecraft.item.ItemStack;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Random;

public class ShimmerTransmuteType implements FanProcessingType {

@Override
public int getPriority() {
return 450;
}

@Override
public boolean isValidAt(World world, BlockPos pos) {
FluidState fluid = world.getFluidState(pos);
return fluid.isStill() && fluid.getFluid() == ModFluids.STILL_SHIMMER || fluid.getFluid() == ModFluids.FLOWING_SHIMMER;
}

@Override
public boolean canProcess(ItemStack stack, World world) {
return world.getRecipeManager()
.listAllOfType(TransmuteRecipe.Type.INSTANCE)
.stream()
.map(r -> (TransmuteRecipe) r)
.anyMatch(r -> matchesRecipeInput(stack, r));
}

@Override
@Nullable
public List<ItemStack> process(ItemStack stack, World world) {
Optional<TransmuteRecipe> recipeOpt = world.getRecipeManager()
.listAllOfType(TransmuteRecipe.Type.INSTANCE)
.stream()
.map(r -> (TransmuteRecipe) r)
.filter(r -> matchesRecipeInput(stack, r))
.findFirst();

if (recipeOpt.isEmpty()) return null;

TransmuteRecipe recipe = recipeOpt.get();
ItemStack required = recipe.getInputItem();

int multiplier = 1;

if (!recipe.isIgnoreCount()) {
if (recipe.isSoftIgnoreCount()) {
multiplier = stack.getCount() / required.getCount();
} else {
if (stack.getCount() != required.getCount()) return null;
}
}

List<ItemStack> result = new ArrayList<>();
for (ItemStack output : recipe.getOutputItems()) {
ItemStack out = output.copy();
out.setCount(out.getCount() * multiplier);
result.add(out);
}

return result;
}

private boolean matchesRecipeInput(ItemStack stack, TransmuteRecipe recipe) {
ItemStack required = recipe.getInputItem();

if (recipe.isIgnoreCount()) {
return stack.getItem() == required.getItem();
} else if (recipe.isSoftIgnoreCount()) {
return stack.getItem() == required.getItem()
&& stack.getCount() >= required.getCount();
} else {
return stack.getItem() == required.getItem()
&& stack.getCount() == required.getCount();
}
}

@Override
public void spawnProcessingParticles(World world, Vec3d pos) {
if (world.random.nextInt(6) != 0) return;
world.addParticle(ParticleTypes.ENCHANT, pos.x, pos.y + .3, pos.z, 0, .1, 0);
}


@Override
public void morphAirFlow(AirFlowParticleAccess particleAccess, Random random) {
particleAccess.setColor(Color.mixColors(0xf543bc, 0xf993c5, random.nextFloat()));
particleAccess.setAlpha(0.75f);
if (random.nextFloat() < 1 / 128f)
particleAccess.spawnExtraParticle(ModParticles.SHIMMER_BUBBLE, .125f);
if (random.nextFloat() < 1 / 128f)
particleAccess.spawnExtraParticle(ModParticles.SHIMMER_BUBBLE_POP, .125f);
}


@Override
public void affectEntity(Entity entity, World world) {
if (!(entity instanceof LivingEntity living)) return;
living.addStatusEffect(new StatusEffectInstance(StatusEffects.GLOWING, 60, 0, false, false));
living.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 330, 0, false, false));


}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.ethanicuss.astraladditions.compat.rei;


import com.github.ethanicuss.astraladditions.AstralAdditions;
import com.github.ethanicuss.astraladditions.compat.rei.create.BulkShimmeringCategory;
import com.github.ethanicuss.astraladditions.compat.rei.desizer.DesizerCategory;
import com.github.ethanicuss.astraladditions.compat.rei.desizer.DesizerDisplay;
import com.github.ethanicuss.astraladditions.compat.rei.transmute.TransmuteCategory;
Expand All @@ -24,6 +24,13 @@
import com.github.ethanicuss.astraladditions.recipes.ChromaticVacuumRecipe;
import com.github.ethanicuss.astraladditions.registry.ModBlocks;
import com.github.ethanicuss.astraladditions.registry.ModItems;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.compat.rei.DoubleItemIcon;
import com.simibubi.create.compat.rei.EmptyBackground;
import com.simibubi.create.compat.rei.category.CreateRecipeCategory;
import com.simibubi.create.compat.rei.display.CreateDisplay;
import com.unascribed.yttr.crafting.*;
import com.unascribed.yttr.init.YEnchantments;
import com.unascribed.yttr.init.YItems;
import com.unascribed.yttr.init.YRecipeTypes;
Expand All @@ -33,24 +40,27 @@
import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.util.EntryStacks;
import net.minecraft.client.MinecraftClient;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.NbtString;
import net.minecraft.recipe.RecipeManager;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.StonecuttingRecipe;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;

import java.util.Collections;
import java.util.List;
import java.util.Map;

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

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

//* Create
public static final CategoryIdentifier<CreateDisplay<TransmuteRecipe>> BULK_SHIMMERING = CategoryIdentifier.of(new Identifier(AstralAdditions.MOD_ID, "bulk_shimmering"));

@Override
public void registerCategories(CategoryRegistry registry) {
registry.add(new DesizerCategory());
Expand Down Expand Up @@ -103,53 +116,70 @@ public void registerCategories(CategoryRegistry registry) {

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

CreateRecipeCategory.Info<TransmuteRecipe> shimmerInfo = new CreateRecipeCategory.Info<>(BULK_SHIMMERING, new TranslatableText("category.astraladditions.bulk_shimmering"), new EmptyBackground(178, 110),
new DoubleItemIcon(() -> new ItemStack(AllItems.PROPELLER.get()), () -> new ItemStack(ModFluids.SHIMMER_BUCKET)),
Collections::emptyList,
List.of(() -> new ItemStack(AllItems.PROPELLER.get()), () -> new ItemStack(ModFluids.SHIMMER_BUCKET)),
178, 110, recipe -> new CreateDisplay<>(recipe, BULK_SHIMMERING));

BulkShimmeringCategory bulkShimmeringCategory = new BulkShimmeringCategory(shimmerInfo);
registry.add(bulkShimmeringCategory);

registry.addWorkstations(BULK_SHIMMERING, EntryStacks.of(AllBlocks.ENCASED_FAN.get()));
}

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

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

List<TransmuteDisplay> transmuteRecipes = recipeManager.listAllOfType(TransmuteRecipe.Type.INSTANCE).stream().map(TransmuteDisplay::of).toList();
transmuteRecipes.forEach(registry::add);

registry.registerFiller(ChromaticVacuumRecipe.class, VacuumDisplay::of);
registry.registerRecipeFiller(ChromaticVacuumRecipe.class, ChromaticVacuumRecipe.Type.INSTANCE, VacuumDisplay::of);

//* YTTR
List<CentrifugeDisplay> centrifugeRecipes = recipeManager.listAllOfType(YRecipeTypes.CENTRIFUGING).stream().map(CentrifugeDisplay::of).toList();
centrifugeRecipes.forEach(registry::add);

List<PistonSmashingDisplay> pistonSmashingRecipes = recipeManager.listAllOfType(YRecipeTypes.PISTON_SMASHING).stream().map(PistonSmashingDisplay::of).toList();
pistonSmashingRecipes.forEach(registry::add);

List<SoakingDisplay> soakingRecipes = recipeManager.listAllOfType(YRecipeTypes.SOAKING).stream().map(SoakingDisplay::of).toList();
soakingRecipes.forEach(registry::add);

List<VoidFilteringDisplay> voidFilteringRecipe = recipeManager.listAllOfType(YRecipeTypes.VOID_FILTERING).stream().map(VoidFilteringDisplay::of).toList();
voidFilteringRecipe.forEach(registry::add);

//Shattering stuff
List<ShatteringDisplay> shatteringRecipes = recipeManager.listAllOfType(YRecipeTypes.SHATTERING).stream()
.map(ShatteringDisplay::of)
.toList();
shatteringRecipes.forEach(registry::add);

List<ShatteringDisplay> shatteringstonecuttingRecipes = recipeManager.listAllOfType(RecipeType.STONECUTTING).stream()
.filter(r -> r.getOutput().getCount() == 1 && !r.getIngredients().isEmpty())
.map(ShatteringDisplay::of)
.toList();
shatteringstonecuttingRecipes.forEach(registry::add);

List<ShatteringDisplay> shatteringoneByOneCraftingRecipes = recipeManager.listAllOfType(RecipeType.CRAFTING).stream()
.filter(r -> r.fits(1, 1) && !r.getIngredients().isEmpty())
.map(ShatteringDisplay::of)
.toList();
shatteringoneByOneCraftingRecipes.forEach(registry::add);
registry.registerRecipeFiller(CentrifugingRecipe.class, YRecipeTypes.CENTRIFUGING, CentrifugeDisplay::of);

registry.registerRecipeFiller(PistonSmashingRecipe.class, YRecipeTypes.PISTON_SMASHING, PistonSmashingDisplay::of);

registry.registerRecipeFiller(SoakingRecipe.class, YRecipeTypes.SOAKING, SoakingDisplay::of);

registry.registerRecipeFiller(VoidFilteringRecipe.class, YRecipeTypes.VOID_FILTERING, VoidFilteringDisplay::of);

registry.registerRecipeFiller(ShatteringRecipe.class, YRecipeTypes.SHATTERING, ShatteringDisplay::of);

registry.registerRecipeFiller(StonecuttingRecipe.class, RecipeType.STONECUTTING, ShatteringDisplay::ofStonecutting);

registry.registerRecipeFiller(
net.minecraft.recipe.CraftingRecipe.class,
RecipeType.CRAFTING,
recipe -> {
if (recipe instanceof ShatteringRecipe) return null;

if (recipe.getIngredients().size() != 1) return null;
if (recipe.getIngredients().get(0).isEmpty()) return null;

ItemStack out = recipe.getOutput();
if (out.isEmpty()) return null;

return ShatteringDisplay.ofWrappedCrafting(recipe);
}
);

registry.registerRecipeFiller(
TransmuteRecipe.class,
TransmuteRecipe.Type.INSTANCE,
recipe -> {
ItemStack out = recipe.getOutput();
if (out == null || out.isEmpty()) {
return null;
}
return new CreateDisplay<>(recipe, BULK_SHIMMERING);
}
);
}



@Override
public void registerScreens(ScreenRegistry registry) {
REIClientPlugin.super.registerScreens(registry);
Expand Down
Loading
Loading