Merge pull request #1895 from kotakotik22/mc1.16/dev

changes to make it easier for addons
This commit is contained in:
simibubi 2021-07-06 02:58:00 +02:00 committed by GitHub
commit 5becf40b60
Failed to generate hash of commit
4 changed files with 46 additions and 27 deletions

View file

@ -240,57 +240,57 @@ public class AllShapes {
return Block.makeCuboidShape(x1, y1, z1, x2, y2, z2);
}
private static class Builder {
public static class Builder {
VoxelShape shape;
public Builder(VoxelShape shape) {
this.shape = shape;
}
Builder add(VoxelShape shape) {
public Builder add(VoxelShape shape) {
this.shape = VoxelShapes.or(this.shape, shape);
return this;
}
Builder add(double x1, double y1, double z1, double x2, double y2, double z2) {
public Builder add(double x1, double y1, double z1, double x2, double y2, double z2) {
return add(cuboid(x1, y1, z1, x2, y2, z2));
}
Builder erase(double x1, double y1, double z1, double x2, double y2, double z2) {
public Builder erase(double x1, double y1, double z1, double x2, double y2, double z2) {
this.shape =
VoxelShapes.combineAndSimplify(shape, cuboid(x1, y1, z1, x2, y2, z2), IBooleanFunction.ONLY_FIRST);
return this;
}
VoxelShape build() {
public VoxelShape build() {
return shape;
}
VoxelShaper build(BiFunction<VoxelShape, Direction, VoxelShaper> factory, Direction direction) {
public VoxelShaper build(BiFunction<VoxelShape, Direction, VoxelShaper> factory, Direction direction) {
return factory.apply(shape, direction);
}
VoxelShaper build(BiFunction<VoxelShape, Axis, VoxelShaper> factory, Axis axis) {
public VoxelShaper build(BiFunction<VoxelShape, Axis, VoxelShaper> factory, Axis axis) {
return factory.apply(shape, axis);
}
VoxelShaper forDirectional(Direction direction) {
public VoxelShaper forDirectional(Direction direction) {
return build(VoxelShaper::forDirectional, direction);
}
VoxelShaper forAxis() {
public VoxelShaper forAxis() {
return build(VoxelShaper::forAxis, Axis.Y);
}
VoxelShaper forHorizontalAxis() {
public VoxelShaper forHorizontalAxis() {
return build(VoxelShaper::forHorizontalAxis, Axis.Z);
}
VoxelShaper forHorizontal(Direction direction) {
public VoxelShaper forHorizontal(Direction direction) {
return build(VoxelShaper::forHorizontal, direction);
}
VoxelShaper forDirectional() {
public VoxelShaper forDirectional() {
return forDirectional(UP);
}

View file

@ -230,8 +230,8 @@ public class ProcessingRecipeBuilder<T extends ProcessingRecipe<?>> {
if (!(recipeType.serializer instanceof ProcessingRecipeSerializer))
throw new IllegalStateException("Cannot datagen ProcessingRecipe of type: " + typeName);
this.id = Create.asResource(typeName + "/" + recipe.getId()
.getPath());
this.id = new ResourceLocation(recipe.getId().getNamespace(),
typeName + "/" + recipe.getId().getPath());
this.serializer = (ProcessingRecipeSerializer<S>) recipe.getSerializer();
}

View file

@ -33,7 +33,7 @@ public abstract class CreateRecipeProvider extends RecipeProvider {
}
@FunctionalInterface
interface GeneratedRecipe {
public interface GeneratedRecipe {
void register(Consumer<IFinishedRecipe> consumer);
}

View file

@ -17,6 +17,7 @@ import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IDataProvider;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidAttributes;
public abstract class ProcessingRecipeGen extends CreateRecipeProvider {
@ -37,14 +38,14 @@ public abstract class ProcessingRecipeGen extends CreateRecipeProvider {
generators.add(new PressingRecipeGen(gen));
generators.add(new FillingRecipeGen(gen));
generators.add(new EmptyingRecipeGen(gen));
gen.addProvider(new IDataProvider() {
@Override
public String getName() {
return "Create's Processing Recipes";
}
@Override
public void act(DirectoryCache dc) throws IOException {
generators.forEach(g -> {
@ -57,22 +58,22 @@ public abstract class ProcessingRecipeGen extends CreateRecipeProvider {
}
});
}
public ProcessingRecipeGen(DataGenerator p_i48262_1_) {
super(p_i48262_1_);
}
/**
* Create a processing recipe with a single itemstack ingredient, using its id
* as the name of the recipe
*/
protected <T extends ProcessingRecipe<?>> GeneratedRecipe create(Supplier<IItemProvider> singleIngredient,
protected <T extends ProcessingRecipe<?>> GeneratedRecipe create(String namespace, Supplier<IItemProvider> singleIngredient,
UnaryOperator<ProcessingRecipeBuilder<T>> transform) {
ProcessingRecipeSerializer<T> serializer = getSerializer();
GeneratedRecipe generatedRecipe = c -> {
IItemProvider iItemProvider = singleIngredient.get();
transform
.apply(new ProcessingRecipeBuilder<>(serializer.getFactory(), Create.asResource(iItemProvider.asItem()
.apply(new ProcessingRecipeBuilder<>(serializer.getFactory(), new ResourceLocation(namespace, iItemProvider.asItem()
.getRegistryName()
.getPath())).withItemIngredients(Ingredient.fromItems(iItemProvider)))
.build(c);
@ -81,22 +82,40 @@ public abstract class ProcessingRecipeGen extends CreateRecipeProvider {
return generatedRecipe;
}
/**
* Create a processing recipe with a single itemstack ingredient, using its id
* as the name of the recipe
*/
protected <T extends ProcessingRecipe<?>> GeneratedRecipe create(Supplier<IItemProvider> singleIngredient,
UnaryOperator<ProcessingRecipeBuilder<T>> transform) {
return create(Create.ID, singleIngredient, transform);
}
/**
* Create a new processing recipe, with recipe definitions provided by the
* function
*/
protected <T extends ProcessingRecipe<?>> GeneratedRecipe create(String name,
UnaryOperator<ProcessingRecipeBuilder<T>> transform) {
protected <T extends ProcessingRecipe<?>> GeneratedRecipe create(ResourceLocation name,
UnaryOperator<ProcessingRecipeBuilder<T>> transform) {
ProcessingRecipeSerializer<T> serializer = getSerializer();
GeneratedRecipe generatedRecipe =
c -> transform.apply(new ProcessingRecipeBuilder<>(serializer.getFactory(), Create.asResource(name)))
c -> transform.apply(new ProcessingRecipeBuilder<>(serializer.getFactory(), name))
.build(c);
all.add(generatedRecipe);
return generatedRecipe;
}
/**
* Create a new processing recipe, with recipe definitions provided by the
* function
*/
protected <T extends ProcessingRecipe<?>> GeneratedRecipe create(String name,
UnaryOperator<ProcessingRecipeBuilder<T>> transform) {
return create(Create.asResource(name), transform);
}
@SuppressWarnings("unchecked")
private <T extends ProcessingRecipe<?>> ProcessingRecipeSerializer<T> getSerializer() {
protected <T extends ProcessingRecipe<?>> ProcessingRecipeSerializer<T> getSerializer() {
ProcessingRecipeSerializer<T> serializer = (ProcessingRecipeSerializer<T>) getRecipeType().serializer;
return serializer;
}
@ -105,7 +124,7 @@ public abstract class ProcessingRecipeGen extends CreateRecipeProvider {
public final String getName() {
return "Create's Processing Recipes: " + getRecipeType();
}
protected abstract AllRecipeTypes getRecipeType();
}