generated from Fabricators-of-Create/create-fabric-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
768 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
src/main/java/com/ghasto/create_so/CreateSandpaperOverhaul.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.ghasto.create_so; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.simibubi.create.AllItems; | ||
import com.simibubi.create.Create; | ||
import com.simibubi.create.foundation.data.CreateRegistrate; | ||
|
||
import net.fabricmc.api.ModInitializer; | ||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; | ||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.CreativeModeTab; | ||
|
||
public class CreateSandpaperOverhaul implements ModInitializer{ | ||
public static final String ID = "create_so"; | ||
public static final String NAME = "Create: Sandpaper Overhaul"; | ||
public static final Logger LOGGER = LoggerFactory.getLogger(NAME); | ||
public static final CreateRegistrate REGISTRATE = CreateRegistrate.create(ID); | ||
public static final CreativeModeTab TAB = FabricItemGroup.builder() | ||
.title(Component.literal(NAME)) | ||
.icon(AllItems.RED_SAND_PAPER::asStack) | ||
.displayItems((c,p) -> { | ||
REGISTRATE.getAll(Registries.ITEM).forEach(e -> { | ||
p.accept(e.get()); | ||
}); | ||
}) | ||
.build(); | ||
|
||
@Override | ||
public void onInitialize() { | ||
ModItems.register(); | ||
ModBlocks.register(); | ||
ModBlockEntities.register(); | ||
ModRecipeTypes.register(); | ||
REGISTRATE.simple("tab", Registries.CREATIVE_MODE_TAB, () -> TAB); | ||
REGISTRATE.register(); | ||
LOGGER.info("{} is loading alongside Create {}!", NAME, Create.VERSION); | ||
} | ||
|
||
public static ResourceLocation id(String path) { | ||
return new ResourceLocation(ID, path); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.ghasto.create_so; | ||
|
||
import static com.ghasto.create_so.CreateSandpaperOverhaul.REGISTRATE; | ||
|
||
import com.ghasto.create_so.content.polishing_wheel.PolishingWheelBlockEntity; | ||
import com.ghasto.create_so.content.polishing_wheel.PolishingWheelControllerBlockEntity; | ||
import com.simibubi.create.content.kinetics.base.CutoutRotatingInstance; | ||
import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; | ||
import com.tterrag.registrate.util.entry.BlockEntityEntry; | ||
|
||
public class ModBlockEntities { | ||
public static final BlockEntityEntry<PolishingWheelBlockEntity> POLISHING_WHEEL = REGISTRATE | ||
.blockEntity("polishing_wheel", PolishingWheelBlockEntity::new) | ||
.instance(() -> CutoutRotatingInstance::new, false) | ||
.validBlocks(ModBlocks.POLISHING_WHEEL) | ||
.renderer(() -> KineticBlockEntityRenderer::new) | ||
.register(); | ||
|
||
public static final BlockEntityEntry<PolishingWheelControllerBlockEntity> POLISHING_WHEEL_CONTROLLER = | ||
REGISTRATE | ||
.blockEntity("crushing_wheel_controller", PolishingWheelControllerBlockEntity::new) | ||
.validBlocks(ModBlocks.POLISHING_WHEEL_CONTROLLER) | ||
// .renderer(() -> renderer) | ||
.register(); | ||
public static void register() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.ghasto.create_so; | ||
|
||
import static com.ghasto.create_so.CreateSandpaperOverhaul.REGISTRATE; | ||
import static com.simibubi.create.foundation.data.ModelGen.customItemModel; | ||
import static com.simibubi.create.foundation.data.TagGen.pickaxeOnly; | ||
|
||
import com.ghasto.create_so.content.polishing_wheel.PolishingWheelBlock; | ||
import com.ghasto.create_so.content.polishing_wheel.PolishingWheelControllerBlock; | ||
import com.simibubi.create.content.kinetics.BlockStressDefaults; | ||
import com.simibubi.create.foundation.data.AssetLookup; | ||
import com.simibubi.create.foundation.data.BlockStateGen; | ||
import com.simibubi.create.foundation.data.SharedProperties; | ||
import com.tterrag.registrate.util.entry.BlockEntry; | ||
|
||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.world.level.block.state.BlockBehaviour; | ||
import net.minecraft.world.level.material.MapColor; | ||
import net.minecraft.world.level.material.PushReaction; | ||
|
||
public class ModBlocks { | ||
public static final BlockEntry<PolishingWheelBlock> POLISHING_WHEEL = | ||
REGISTRATE.block("crushing_wheel", PolishingWheelBlock::new) | ||
.properties(p -> p.mapColor(MapColor.METAL)) | ||
.initialProperties(SharedProperties::stone) | ||
.properties(BlockBehaviour.Properties::noOcclusion) | ||
.transform(pickaxeOnly()) | ||
.blockstate((c, p) -> BlockStateGen.axisBlock(c, p, s -> AssetLookup.partialBaseModel(c, p))) | ||
.addLayer(() -> RenderType::cutoutMipped) | ||
.transform(BlockStressDefaults.setImpact(12.0)) | ||
.item() | ||
.transform(customItemModel()) | ||
.register(); | ||
|
||
public static final BlockEntry<PolishingWheelControllerBlock> POLISHING_WHEEL_CONTROLLER = | ||
REGISTRATE.block("crushing_wheel_controller", PolishingWheelControllerBlock::new) | ||
.properties(p -> p.mapColor(MapColor.STONE) | ||
.noOcclusion() | ||
.noLootTable() | ||
.air() | ||
.noCollission() | ||
.pushReaction(PushReaction.BLOCK)) | ||
.blockstate((c, p) -> p.getVariantBuilder(c.get()) | ||
.forAllStatesExcept(BlockStateGen.mapToAir(p), PolishingWheelControllerBlock.FACING)) | ||
.register(); | ||
public static void register() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.ghasto.create_so; | ||
|
||
public class ModItems { | ||
public static void register() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.ghasto.create_so; | ||
|
||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.function.Supplier; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
import com.ghasto.create_so.content.polishing_wheel.PolishingRecipe; | ||
import com.google.common.collect.ImmutableSet; | ||
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder; | ||
import com.simibubi.create.content.processing.recipe.ProcessingRecipeSerializer; | ||
import com.simibubi.create.foundation.recipe.IRecipeTypeInfo; | ||
import com.simibubi.create.foundation.utility.Lang; | ||
import com.simibubi.create.foundation.utility.RegisteredObjects; | ||
|
||
import net.minecraft.core.Registry; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.Container; | ||
import net.minecraft.world.item.crafting.Recipe; | ||
import net.minecraft.world.item.crafting.RecipeSerializer; | ||
import net.minecraft.world.item.crafting.RecipeType; | ||
import net.minecraft.world.level.Level; | ||
|
||
public enum ModRecipeTypes implements IRecipeTypeInfo { | ||
|
||
POLISHING(PolishingRecipe::new); | ||
|
||
private final ResourceLocation id; | ||
private final RecipeSerializer<?> serializerObject; | ||
@Nullable | ||
private final RecipeType<?> typeObject; | ||
private final Supplier<RecipeType<?>> type; | ||
|
||
ModRecipeTypes(Supplier<RecipeSerializer<?>> serializerSupplier, Supplier<RecipeType<?>> typeSupplier, boolean registerType) { | ||
String name = Lang.asId(name()); | ||
id = CreateSandpaperOverhaul.id(name); | ||
serializerObject = Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, id, serializerSupplier.get()); | ||
if (registerType) { | ||
typeObject = typeSupplier.get(); | ||
Registry.register(BuiltInRegistries.RECIPE_TYPE, id, typeObject); | ||
type = typeSupplier; | ||
} else { | ||
typeObject = null; | ||
type = typeSupplier; | ||
} | ||
} | ||
|
||
ModRecipeTypes(Supplier<RecipeSerializer<?>> serializerSupplier) { | ||
String name = Lang.asId(name()); | ||
id = CreateSandpaperOverhaul.id(name); | ||
serializerObject = Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, id, serializerSupplier.get()); | ||
typeObject = simpleType(id); | ||
Registry.register(BuiltInRegistries.RECIPE_TYPE, id, typeObject); | ||
type = () -> typeObject; | ||
} | ||
|
||
ModRecipeTypes(ProcessingRecipeBuilder.ProcessingRecipeFactory<?> processingFactory) { | ||
this(() -> new ProcessingRecipeSerializer<>(processingFactory)); | ||
} | ||
|
||
public static <T extends Recipe<?>> RecipeType<T> simpleType(ResourceLocation id) { | ||
String stringId = id.toString(); | ||
return new RecipeType<T>() { | ||
@Override | ||
public String toString() { | ||
return stringId; | ||
} | ||
}; | ||
} | ||
|
||
public static void register() { | ||
} | ||
|
||
@Override | ||
public ResourceLocation getId() { | ||
return id; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public <T extends RecipeSerializer<?>> T getSerializer() { | ||
return (T) serializerObject; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public <T extends RecipeType<?>> T getType() { | ||
return (T) type.get(); | ||
} | ||
|
||
public <C extends Container, T extends Recipe<C>> Optional<T> find(C inv, Level world) { | ||
return world.getRecipeManager() | ||
.getRecipeFor(getType(), inv, world); | ||
} | ||
|
||
public static final Set<ResourceLocation> RECIPE_DENY_SET = | ||
ImmutableSet.of(new ResourceLocation("occultism", "spirit_trade"), new ResourceLocation("occultism", "ritual")); | ||
|
||
public static boolean shouldIgnoreInAutomation(Recipe<?> recipe) { | ||
RecipeSerializer<?> serializer = recipe.getSerializer(); | ||
if (serializer != null && RECIPE_DENY_SET.contains(RegisteredObjects.getKeyOrThrow(serializer))) | ||
return true; | ||
return recipe.getId() | ||
.getPath() | ||
.endsWith("_manual_only"); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/ghasto/create_so/content/polishing_wheel/PolishingRecipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.ghasto.create_so.content.polishing_wheel; | ||
|
||
import com.ghasto.create_so.ModRecipeTypes; | ||
import com.simibubi.create.content.kinetics.crusher.AbstractCrushingRecipe; | ||
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder; | ||
|
||
import net.minecraft.world.Container; | ||
import net.minecraft.world.level.Level; | ||
|
||
public class PolishingRecipe extends AbstractCrushingRecipe { | ||
public PolishingRecipe(ProcessingRecipeBuilder.ProcessingRecipeParams params) { | ||
super(ModRecipeTypes.POLISHING, params); | ||
} | ||
@Override | ||
public boolean matches(Container inv, Level worldIn) { | ||
if (inv.isEmpty()) | ||
return false; | ||
return ingredients.get(0) | ||
.test(inv.getItem(0)); | ||
} | ||
|
||
@Override | ||
protected int getMaxOutputCount() { | ||
return 64; | ||
} | ||
} |
Oops, something went wrong.