-
-
Notifications
You must be signed in to change notification settings - Fork 214
Implement Recipe API #1395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Recipe API #1395
Conversation
public boolean apply(@Nullable net.minecraft.item.ItemStack p_apply_1_) { | ||
|
||
// first check for matching predicates | ||
if (predicates.stream().anyMatch(p -> p.test(ItemStackUtil.fromNative(p_apply_1_)))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.
} | ||
|
||
@Override | ||
public boolean apply(@Nullable net.minecraft.item.ItemStack p_apply_1_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameter could use a better name.
} | ||
|
||
@Override | ||
public boolean apply(@Nullable ItemStack p_apply_1_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameter could use a better name
|
||
@Override | ||
public boolean apply(@Nullable ItemStack p_apply_1_) { | ||
return delegate.test(ItemStackUtil.fromNative(p_apply_1_)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.
@Override | ||
public Collection<CraftingRecipe> getRecipes() { | ||
// TODO Unmodifiable? | ||
return Streams.stream(CraftingManager.REGISTRY.iterator()).map(CraftingRecipe.class::cast).collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.collect(ImmutableList.toImmutableList())
c7d5d92
to
eb1f33a
Compare
|
||
@Override | ||
public ShapedCraftingRecipe.Builder group(@Nullable String name) { | ||
this.groupName = name == null ? "" : name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Strings.nullToEmpty
@@ -82,6 +83,11 @@ | |||
@Shadow | |||
public abstract Slot getSlot(int slotId); | |||
|
|||
@Shadow | |||
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { | |||
throw new IllegalStateException("Shadowed."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not making this abstract?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MixinContainerCrafting extends this and calls super.slotClick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, one of the rare cases!
public RecipeRegistry getRecipeRegistry() { | ||
throw new UnsupportedOperationException(); // TODO | ||
public CraftingRecipeRegistry getCraftingRecipeRegistry() { | ||
return new SpongeCraftingRecipeRegistry(); // TODO cache it somewhere |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cache it in SpongeCraftingRecipeRegistry
?
|
||
|
||
public net.minecraft.entity.passive.EntityVillager field_175561_bA # DEFAULT_TRADE_LIST_MAP | ||
public net.minecraft.entity.EntityList func_191303_a(ILjava/lang/String;Ljava/lang/Class;Ljava/lang/String;)V # register |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must have happened when rebasing stuff
@@ -28,6 +28,7 @@ | |||
|
|||
import com.google.common.collect.ImmutableList; | |||
import com.google.common.collect.Streams; | |||
import com.google.inject.Singleton; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want this annotation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nobody can know!
b44fa86
to
d5aad0a
Compare
} | ||
|
||
@Inject(method = "getSmeltingResult", at = @At("RETURN"), cancellable = true) | ||
public void onGetSmeltingResult(ItemStack stack, CallbackInfoReturnable<ItemStack> cir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to have this public
} | ||
|
||
@Inject(method = "getSmeltingExperience", at = @At("RETURN"), cancellable = true) | ||
public void onGetSmeltingExperience(ItemStack stack, CallbackInfoReturnable<Float> cir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to have this public
68e8a4c
to
96ebeb6
Compare
96ebeb6
to
ad869e0
Compare
SpongeAPI|SpongeCommon|SpongeForge
Continuation of #1119 of SpongePowered/SpongeAPI#1098
Updated for MC 1.12
InventoryUtil
: CraftingInventory <-> InventoryCrafting UtilItemStackUtil
: List <-> native Ingredient[]AbstractSpongeCraftingRecipe
/DelegateSpongeCraftingRecipe
: for custom CraftingRecipe Impls.CustomIngredient
: For Ingredients using Predicates instead of Items.DelegateIngredient
: For custom Ingredient Impls.IngredientUtil
: Ingredient <-> native IngredientSpongeCraftingRecipeRegistry
: delegates registration to theCraftingManager
SpongeIngredientBuilder
: Builder for IngredientsSpongeShapedCraftingRecipeBuilder
: Builder for shaped CraftingRecipesSpongeShapelessCraftingRecipeBuilder
: Builder for shapeless CraftingRecipesMatchSmeltingVanillaItemStack
:SpongeSmeltingRecipe
:SpongeSmeltingRecipeBuilder
MixinContainerCrafting
:MixinIRecipe
: make IRecipe implement CraftingRecipeMixinIngredient
: make native Ingredient implement IngredientMixinShapedRecipes
: make ShapedRecipes implement ShapedCraftingRecipeMixinShapelessRecipes
: make ShapelessRecipes implement ShapelessCraftingRecipeMixinFurnaceRecipes
: make FurnaceRecipes implement SmeltingRecipeRegistryCommonModuleRegistry
: register Builders:Ingredient
,ShapedCraftingRecipe
,ShapelessCraftingRecipe
,SmeltingRecipe
Ideas for Further enhancement: