mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 10:55:17 +00:00
Merge 1.14
This commit is contained in:
commit
a6cf5653dc
2298 files changed
+44061
-14763
No files matched your search
@@ -39,7 +39,9 @@ import vazkii.botania.api.item.IExoflameHeatable;
|
||||
import vazkii.botania.api.item.IFloatingFlower;
|
||||
import vazkii.botania.client.core.proxy.ClientProxy;
|
||||
import vazkii.botania.common.advancements.AlfPortalTrigger;
|
||||
import vazkii.botania.common.advancements.AlfPortalBreadTrigger;
|
||||
import vazkii.botania.common.advancements.CorporeaRequestTrigger;
|
||||
import vazkii.botania.common.advancements.LokiPlaceTrigger;
|
||||
import vazkii.botania.common.advancements.ManaGunTrigger;
|
||||
import vazkii.botania.common.advancements.DopplegangerNoArmorTrigger;
|
||||
import vazkii.botania.common.advancements.RelicBindTrigger;
|
||||
@@ -215,6 +217,8 @@ public class Botania {
|
||||
CriteriaTriggers.register(RelicBindTrigger.INSTANCE);
|
||||
CriteriaTriggers.register(UseItemSuccessTrigger.INSTANCE);
|
||||
CriteriaTriggers.register(ManaGunTrigger.INSTANCE);
|
||||
CriteriaTriggers.register(LokiPlaceTrigger.INSTANCE);
|
||||
CriteriaTriggers.register(AlfPortalBreadTrigger.INSTANCE);
|
||||
|
||||
CraftingHelper.register(FluxfieldCondition.SERIALIZER);
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package vazkii.botania.common.advancements;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.advancements.ICriterionInstance;
|
||||
import net.minecraft.advancements.ICriterionTrigger;
|
||||
import net.minecraft.advancements.PlayerAdvancements;
|
||||
import net.minecraft.advancements.criterion.LocationPredicate;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class AlfPortalBreadTrigger implements ICriterionTrigger<AlfPortalBreadTrigger.Instance> {
|
||||
public static final ResourceLocation ID = new ResourceLocation(LibMisc.MOD_ID, "alf_portal_bread");
|
||||
public static final AlfPortalBreadTrigger INSTANCE = new AlfPortalBreadTrigger();
|
||||
private final Map<PlayerAdvancements, AlfPortalBreadTrigger.PlayerTracker> playerTrackers = new HashMap<>();
|
||||
|
||||
private AlfPortalBreadTrigger() {}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener<AlfPortalBreadTrigger.Instance> listener) {
|
||||
this.playerTrackers.computeIfAbsent(player, AlfPortalBreadTrigger.PlayerTracker::new).listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener<AlfPortalBreadTrigger.Instance> listener) {
|
||||
AlfPortalBreadTrigger.PlayerTracker tracker = this.playerTrackers.get(player);
|
||||
|
||||
if(tracker != null) {
|
||||
tracker.listeners.remove(listener);
|
||||
|
||||
if(tracker.listeners.isEmpty()) {
|
||||
this.playerTrackers.remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllListeners(@Nonnull PlayerAdvancements player) {
|
||||
playerTrackers.remove(player);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AlfPortalBreadTrigger.Instance deserializeInstance(@Nonnull JsonObject json, @Nonnull JsonDeserializationContext context) {
|
||||
return new AlfPortalBreadTrigger.Instance(LocationPredicate.deserialize(json.get("portal_location")));
|
||||
}
|
||||
|
||||
static class PlayerTracker {
|
||||
private final PlayerAdvancements playerAdvancements;
|
||||
final Set<Listener<AlfPortalBreadTrigger.Instance>> listeners = new HashSet<>();
|
||||
|
||||
PlayerTracker(PlayerAdvancements playerAdvancementsIn) {
|
||||
this.playerAdvancements = playerAdvancementsIn;
|
||||
}
|
||||
|
||||
public void trigger(ServerWorld world, BlockPos portal) {
|
||||
List<Listener<AlfPortalBreadTrigger.Instance>> list = new ArrayList<>();
|
||||
|
||||
for(ICriterionTrigger.Listener<AlfPortalBreadTrigger.Instance> listener : this.listeners) {
|
||||
if(listener.getCriterionInstance().test(world, portal)) {
|
||||
list.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
for(ICriterionTrigger.Listener<AlfPortalBreadTrigger.Instance> listener : list) {
|
||||
listener.grantCriterion(this.playerAdvancements);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void trigger(ServerPlayerEntity player, BlockPos portal) {
|
||||
AlfPortalBreadTrigger.PlayerTracker tracker = playerTrackers.get(player.getAdvancements());
|
||||
if(tracker != null) {
|
||||
tracker.trigger(player.getServerWorld(), portal);
|
||||
}
|
||||
}
|
||||
|
||||
static class Instance implements ICriterionInstance {
|
||||
private final LocationPredicate portal;
|
||||
|
||||
Instance(LocationPredicate portal) {
|
||||
this.portal = portal;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
boolean test(ServerWorld world, BlockPos portal) {
|
||||
return this.portal.test(world, portal.getX(), portal.getY(), portal.getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package vazkii.botania.common.advancements;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.advancements.ICriterionInstance;
|
||||
import net.minecraft.advancements.ICriterionTrigger;
|
||||
import net.minecraft.advancements.PlayerAdvancements;
|
||||
import net.minecraft.advancements.criterion.EntityPredicate;
|
||||
import net.minecraft.advancements.criterion.ItemPredicate;
|
||||
import net.minecraft.advancements.criterion.MinMaxBounds;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class LokiPlaceTrigger implements ICriterionTrigger<LokiPlaceTrigger.Instance> {
|
||||
public static final ResourceLocation ID = new ResourceLocation(LibMisc.MOD_ID, "loki_placed_blocks");
|
||||
public static final LokiPlaceTrigger INSTANCE = new LokiPlaceTrigger();
|
||||
private final Map<PlayerAdvancements, LokiPlaceTrigger.PlayerTracker> playerTrackers = new HashMap<>();
|
||||
|
||||
private LokiPlaceTrigger() {}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener<LokiPlaceTrigger.Instance> listener) {
|
||||
this.playerTrackers.computeIfAbsent(player, LokiPlaceTrigger.PlayerTracker::new).listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener<LokiPlaceTrigger.Instance> listener) {
|
||||
LokiPlaceTrigger.PlayerTracker tracker = this.playerTrackers.get(player);
|
||||
|
||||
if(tracker != null) {
|
||||
tracker.listeners.remove(listener);
|
||||
|
||||
if(tracker.listeners.isEmpty()) {
|
||||
this.playerTrackers.remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllListeners(@Nonnull PlayerAdvancements player) {
|
||||
playerTrackers.remove(player);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public LokiPlaceTrigger.Instance deserializeInstance(@Nonnull JsonObject json, @Nonnull JsonDeserializationContext context) {
|
||||
return new LokiPlaceTrigger.Instance(EntityPredicate.deserialize(json.get("player")), ItemPredicate.deserialize(json.get("ring")), MinMaxBounds.IntBound.fromJson(json.get("blocks_placed")));
|
||||
}
|
||||
|
||||
static class PlayerTracker {
|
||||
private final PlayerAdvancements playerAdvancements;
|
||||
final Set<ICriterionTrigger.Listener<LokiPlaceTrigger.Instance>> listeners = new HashSet<>();
|
||||
|
||||
PlayerTracker(PlayerAdvancements playerAdvancementsIn) {
|
||||
this.playerAdvancements = playerAdvancementsIn;
|
||||
}
|
||||
|
||||
public void trigger(ServerPlayerEntity player, ItemStack ring, int blocksPlaced) {
|
||||
List<ICriterionTrigger.Listener<LokiPlaceTrigger.Instance>> list = new ArrayList<>();
|
||||
|
||||
for(ICriterionTrigger.Listener<LokiPlaceTrigger.Instance> listener : this.listeners) {
|
||||
if(listener.getCriterionInstance().test(player, ring, blocksPlaced)) {
|
||||
list.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
for(ICriterionTrigger.Listener<LokiPlaceTrigger.Instance> listener : list) {
|
||||
listener.grantCriterion(this.playerAdvancements);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void trigger(ServerPlayerEntity player, ItemStack ring, int blocksPlaced) {
|
||||
LokiPlaceTrigger.PlayerTracker tracker = playerTrackers.get(player.getAdvancements());
|
||||
if(tracker != null) {
|
||||
tracker.trigger(player, ring, blocksPlaced);
|
||||
}
|
||||
}
|
||||
|
||||
static class Instance implements ICriterionInstance {
|
||||
private final EntityPredicate player;
|
||||
private final ItemPredicate ring;
|
||||
private final MinMaxBounds.IntBound blocksPlaced;
|
||||
|
||||
Instance(EntityPredicate player, ItemPredicate ring, MinMaxBounds.IntBound blocksPlaced) {
|
||||
this.player = player;
|
||||
this.ring = ring;
|
||||
this.blocksPlaced = blocksPlaced;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
boolean test(ServerPlayerEntity player, ItemStack ring, int blocksPlaced) {
|
||||
return this.player.test(player, null) && this.ring.test(ring) && this.blocksPlaced.test(blocksPlaced);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,38 +10,46 @@
|
||||
*/
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tileentity.BannerPattern;
|
||||
import net.minecraft.util.IItemProvider;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public final class ModBanners {
|
||||
|
||||
public static final Map<IRegistryDelegate<Item>, BannerPattern> PATTERNS = new LinkedHashMap<>();
|
||||
|
||||
public static void init() {
|
||||
addPattern("flower", "flr", new ItemStack(ModItems.livingwoodTwig));
|
||||
addPattern("lexicon", "lex", new ItemStack(ModItems.lexicon));
|
||||
addPattern("logo", "lgo", new ItemStack(ModItems.terrasteel));
|
||||
addPattern("sapling", "spl", new ItemStack(ModItems.dreamwoodTwig));
|
||||
addPattern("tiny_potato", "tpt", new ItemStack(ModBlocks.tinyPotato));
|
||||
addPattern("flower", "flr", ModItems.livingwoodTwig);
|
||||
addPattern("lexicon", "lex", ModItems.lexicon);
|
||||
addPattern("logo", "lgo", ModItems.terrasteel);
|
||||
addPattern("sapling", "spl", ModItems.dreamwoodTwig);
|
||||
addPattern("tiny_potato", "tpt", ModBlocks.tinyPotato);
|
||||
|
||||
addPattern("spark_dispersive", "sds", new ItemStack(ModItems.sparkUpgradeDispersive));
|
||||
addPattern("spark_dominant", "sdm", new ItemStack(ModItems.sparkUpgradeDominant));
|
||||
addPattern("spark_recessive", "src", new ItemStack(ModItems.sparkUpgradeRecessive));
|
||||
addPattern("spark_isolated", "sis", new ItemStack(ModItems.sparkUpgradeIsolated));
|
||||
addPattern("spark_dispersive", "sds", ModItems.sparkUpgradeDispersive);
|
||||
addPattern("spark_dominant", "sdm", ModItems.sparkUpgradeDominant);
|
||||
addPattern("spark_recessive", "src", ModItems.sparkUpgradeRecessive);
|
||||
addPattern("spark_isolated", "sis", ModItems.sparkUpgradeIsolated);
|
||||
|
||||
addPattern("fish", "fis", new ItemStack(Items.COD));
|
||||
addPattern("axe", "axe", new ItemStack(Items.IRON_AXE));
|
||||
addPattern("hoe", "hoe", new ItemStack(Items.IRON_HOE));
|
||||
addPattern("pickaxe", "pik", new ItemStack(Items.IRON_PICKAXE));
|
||||
addPattern("shovel", "shv", new ItemStack(Items.IRON_SHOVEL));
|
||||
addPattern("sword", "srd", new ItemStack(Items.IRON_SWORD));
|
||||
addPattern("fish", "fis", Items.COD);
|
||||
addPattern("axe", "axe", Items.IRON_AXE);
|
||||
addPattern("hoe", "hoe", Items.IRON_HOE);
|
||||
addPattern("pickaxe", "pik", Items.IRON_PICKAXE);
|
||||
addPattern("shovel", "shv", Items.IRON_SHOVEL);
|
||||
addPattern("sword", "srd", Items.IRON_SWORD);
|
||||
}
|
||||
|
||||
private static void addPattern(String name, String id, ItemStack craftingItem) {
|
||||
private static void addPattern(String name, String id, IItemProvider craftingItem) {
|
||||
name = "botania_" + name;
|
||||
id = "bt_" + id;
|
||||
BannerPattern.create(name.toUpperCase(Locale.ROOT), name, id, craftingItem);
|
||||
BannerPattern pattern = BannerPattern.create(name.toUpperCase(Locale.ROOT), name, id, new ItemStack(craftingItem));
|
||||
PATTERNS.put(craftingItem.asItem().delegate, pattern);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@@ -32,6 +34,7 @@ import vazkii.botania.api.recipe.RecipeElvenTrade;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.api.state.enums.AlfPortalState;
|
||||
import vazkii.botania.client.fx.WispParticleData;
|
||||
import vazkii.botania.common.advancements.AlfPortalBreadTrigger;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.mana.BlockPool;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
@@ -43,9 +46,11 @@ import vazkii.patchouli.api.IMultiblock;
|
||||
import vazkii.patchouli.api.PatchouliAPI;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
|
||||
@@ -77,6 +82,8 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
private int ticksSinceLastItem = 0;
|
||||
private boolean closeNow = false;
|
||||
private boolean explode = false;
|
||||
@Nullable
|
||||
private UUID breadPlayer = null;
|
||||
|
||||
public TileAlfPortal() {
|
||||
super(TYPE);
|
||||
@@ -124,7 +131,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
|
||||
if (consume) {
|
||||
item.remove();
|
||||
if (validateItemUsage(stack))
|
||||
if (validateItemUsage(item))
|
||||
addItem(stack);
|
||||
ticksSinceLastItem = 0;
|
||||
}
|
||||
@@ -149,17 +156,29 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
world.createExplosion(null, pos.getX() + .5, pos.getY() + 2.0, pos.getZ() + .5,
|
||||
3f, Explosion.Mode.DESTROY);
|
||||
explode = false;
|
||||
|
||||
if (!world.isRemote && breadPlayer != null) {
|
||||
PlayerEntity entity = world.getPlayerByUuid(breadPlayer);
|
||||
if (entity instanceof ServerPlayerEntity) {
|
||||
AlfPortalBreadTrigger.INSTANCE.trigger((ServerPlayerEntity) entity, getPos());
|
||||
}
|
||||
}
|
||||
breadPlayer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validateItemUsage(ItemStack inputStack) {
|
||||
private boolean validateItemUsage(ItemEntity entity) {
|
||||
ItemStack inputStack = entity.getItem();
|
||||
for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes.values()) {
|
||||
if(recipe.containsItem(inputStack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(inputStack.getItem() == Items.BREAD) //Don't teleport bread. (See also: #2403)
|
||||
if(inputStack.getItem() == Items.BREAD) {
|
||||
//Don't teleport bread. (See also: #2403)
|
||||
explode = true;
|
||||
breadPlayer = entity.getThrowerId();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import vazkii.botania.common.item.ItemAncientWill;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class AncientWillRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<AncientWillRecipe> SERIALIZER = new SpecialRecipeSerializer<>(AncientWillRecipe::new);
|
||||
public static final SpecialRecipeSerializer<AncientWillRecipe> SERIALIZER = new SpecialRecipeSerializer<>(AncientWillRecipe::new);
|
||||
|
||||
public AncientWillRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* This class was created by <Hubry>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [2020-01-30, 19:13 (UTC+2)]
|
||||
*/
|
||||
package vazkii.botania.common.crafting.recipe;
|
||||
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.DyeColor;
|
||||
import net.minecraft.item.DyeItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.SpecialRecipe;
|
||||
import net.minecraft.item.crafting.SpecialRecipeSerializer;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tileentity.BannerPattern;
|
||||
import net.minecraft.tileentity.BannerTileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.common.block.ModBanners;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
// Workaround recipe for the loom hardcoding problem.
|
||||
public class BannerRecipe extends SpecialRecipe {
|
||||
public static SpecialRecipeSerializer<BannerRecipe> SERIALIZER = new SpecialRecipeSerializer<>(BannerRecipe::new);
|
||||
|
||||
public BannerRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(CraftingInventory inv, @Nonnull World world) {
|
||||
boolean foundBanner = false;
|
||||
boolean foundItem = false;
|
||||
boolean foundDye = false;
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
Item item = stack.getItem();
|
||||
if (stack.isEmpty())
|
||||
continue;
|
||||
|
||||
if (ModBanners.PATTERNS.containsKey(item.delegate) && !foundItem) {
|
||||
foundItem = true;
|
||||
} else if (ItemTags.BANNERS.contains(item) && !foundBanner && BannerTileEntity.getPatterns(stack) < 6) {
|
||||
foundBanner = true;
|
||||
} else if (item instanceof DyeItem && !foundDye) {
|
||||
foundDye = true;
|
||||
} else return false;
|
||||
}
|
||||
return foundBanner && foundItem && foundDye;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult(@Nonnull CraftingInventory inv) {
|
||||
ItemStack banner = ItemStack.EMPTY;
|
||||
ItemStack dye = ItemStack.EMPTY;
|
||||
BannerPattern pattern = null;
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
Item item = stack.getItem();
|
||||
if (ModBanners.PATTERNS.containsKey(item.delegate)) {
|
||||
pattern = ModBanners.PATTERNS.get(item.delegate);
|
||||
} else if (ItemTags.BANNERS.contains(item)) {
|
||||
banner = stack;
|
||||
} else if (item instanceof DyeItem) {
|
||||
dye = stack;
|
||||
}
|
||||
}
|
||||
return applyPattern(banner, pattern, dye);
|
||||
}
|
||||
|
||||
// [VanillaCopy] From LoomContainer.func_217031_j, edits noted
|
||||
@SuppressWarnings("UnnecessaryLocalVariable")
|
||||
private static ItemStack applyPattern(ItemStack banner, BannerPattern pattern, ItemStack dye) {
|
||||
ItemStack itemstack = banner; // Apply our context here
|
||||
ItemStack itemstack1 = dye;
|
||||
ItemStack itemstack2 = ItemStack.EMPTY;
|
||||
|
||||
if (!itemstack.isEmpty() && !itemstack1.isEmpty()) {
|
||||
itemstack2 = itemstack.copy();
|
||||
itemstack2.setCount(1);
|
||||
BannerPattern bannerpattern = pattern; // Replace the pattern with provided one
|
||||
DyeColor dyecolor = ((DyeItem) itemstack1.getItem()).getDyeColor();
|
||||
CompoundNBT compoundnbt = itemstack2.getOrCreateChildTag("BlockEntityTag");
|
||||
ListNBT listnbt;
|
||||
if (compoundnbt.contains("Patterns", 9)) {
|
||||
listnbt = compoundnbt.getList("Patterns", 10);
|
||||
} else {
|
||||
listnbt = new ListNBT();
|
||||
compoundnbt.put("Patterns", listnbt);
|
||||
}
|
||||
|
||||
CompoundNBT compoundnbt1 = new CompoundNBT();
|
||||
compoundnbt1.putString("Pattern", bannerpattern.getHashname());
|
||||
compoundnbt1.putInt("Color", dyecolor.getId());
|
||||
listnbt.add(compoundnbt1);
|
||||
}
|
||||
return itemstack2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFit(int width, int height) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
return SERIALIZER;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -24,7 +24,7 @@ import vazkii.botania.common.item.ModItems;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BlackHoleTalismanExtractRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<BlackHoleTalismanExtractRecipe> SERIALIZER = new SpecialRecipeSerializer<>(BlackHoleTalismanExtractRecipe::new);
|
||||
public static final SpecialRecipeSerializer<BlackHoleTalismanExtractRecipe> SERIALIZER = new SpecialRecipeSerializer<>(BlackHoleTalismanExtractRecipe::new);
|
||||
|
||||
public BlackHoleTalismanExtractRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
|
||||
@@ -23,7 +23,7 @@ import vazkii.botania.api.mana.ICompositableLens;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CompositeLensRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<CompositeLensRecipe> SERIALIZER = new SpecialRecipeSerializer<>(CompositeLensRecipe::new);
|
||||
public static final SpecialRecipeSerializer<CompositeLensRecipe> SERIALIZER = new SpecialRecipeSerializer<>(CompositeLensRecipe::new);
|
||||
|
||||
public CompositeLensRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
|
||||
@@ -23,7 +23,7 @@ import vazkii.botania.api.item.ICosmeticBauble;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CosmeticAttachRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<CosmeticAttachRecipe> SERIALIZER = new SpecialRecipeSerializer<>(CosmeticAttachRecipe::new);
|
||||
public static final SpecialRecipeSerializer<CosmeticAttachRecipe> SERIALIZER = new SpecialRecipeSerializer<>(CosmeticAttachRecipe::new);
|
||||
|
||||
public CosmeticAttachRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
|
||||
@@ -23,7 +23,7 @@ import vazkii.botania.api.item.ICosmeticBauble;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CosmeticRemoveRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<CosmeticRemoveRecipe> SERIALIZER = new SpecialRecipeSerializer<>(CosmeticRemoveRecipe::new);
|
||||
public static final SpecialRecipeSerializer<CosmeticRemoveRecipe> SERIALIZER = new SpecialRecipeSerializer<>(CosmeticRemoveRecipe::new);
|
||||
|
||||
public CosmeticRemoveRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
|
||||
@@ -24,7 +24,7 @@ import vazkii.botania.common.item.ModItems;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class KeepIvyRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<KeepIvyRecipe> SERIALIZER = new SpecialRecipeSerializer<>(KeepIvyRecipe::new);
|
||||
public static final SpecialRecipeSerializer<KeepIvyRecipe> SERIALIZER = new SpecialRecipeSerializer<>(KeepIvyRecipe::new);
|
||||
|
||||
public KeepIvyRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class LensDyeingRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<LensDyeingRecipe> SERIALIZER = new SpecialRecipeSerializer<>(LensDyeingRecipe::new);
|
||||
public static final SpecialRecipeSerializer<LensDyeingRecipe> SERIALIZER = new SpecialRecipeSerializer<>(LensDyeingRecipe::new);
|
||||
|
||||
private final List<Ingredient> dyes = Arrays.asList(
|
||||
Ingredient.fromTag(Tags.Items.DYES_WHITE), Ingredient.fromTag(Tags.Items.DYES_ORANGE),
|
||||
|
||||
@@ -23,7 +23,7 @@ import vazkii.botania.common.item.ModItems;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ManaGunClipRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<ManaGunClipRecipe> SERIALIZER = new SpecialRecipeSerializer<>(ManaGunClipRecipe::new);
|
||||
public static final SpecialRecipeSerializer<ManaGunClipRecipe> SERIALIZER = new SpecialRecipeSerializer<>(ManaGunClipRecipe::new);
|
||||
|
||||
public ManaGunClipRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
|
||||
@@ -24,7 +24,7 @@ import vazkii.botania.common.item.ItemManaGun;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ManaGunLensRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<ManaGunLensRecipe> SERIALIZER = new SpecialRecipeSerializer<>(ManaGunLensRecipe::new);
|
||||
public static final SpecialRecipeSerializer<ManaGunLensRecipe> SERIALIZER = new SpecialRecipeSerializer<>(ManaGunLensRecipe::new);
|
||||
|
||||
public ManaGunLensRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
|
||||
@@ -22,7 +22,7 @@ import vazkii.botania.common.item.ItemManaGun;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ManaGunRemoveLensRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<ManaGunRemoveLensRecipe> SERIALIZER = new SpecialRecipeSerializer<>(ManaGunRemoveLensRecipe::new);
|
||||
public static final SpecialRecipeSerializer<ManaGunRemoveLensRecipe> SERIALIZER = new SpecialRecipeSerializer<>(ManaGunRemoveLensRecipe::new);
|
||||
|
||||
public ManaGunRemoveLensRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
|
||||
@@ -23,7 +23,7 @@ import vazkii.botania.common.item.ModItems;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class PhantomInkRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<PhantomInkRecipe> SERIALIZER = new SpecialRecipeSerializer<>(PhantomInkRecipe::new);
|
||||
public static final SpecialRecipeSerializer<PhantomInkRecipe> SERIALIZER = new SpecialRecipeSerializer<>(PhantomInkRecipe::new);
|
||||
|
||||
public PhantomInkRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
|
||||
@@ -22,7 +22,7 @@ import vazkii.botania.common.item.ModItems;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class SpellClothRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<SpellClothRecipe> SERIALIZER = new SpecialRecipeSerializer<>(SpellClothRecipe::new);
|
||||
public static final SpecialRecipeSerializer<SpellClothRecipe> SERIALIZER = new SpecialRecipeSerializer<>(SpellClothRecipe::new);
|
||||
|
||||
public SpellClothRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
|
||||
@@ -23,7 +23,7 @@ import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TerraPickTippingRecipe extends SpecialRecipe {
|
||||
public static final IRecipeSerializer<TerraPickTippingRecipe> SERIALIZER = new SpecialRecipeSerializer<>(TerraPickTippingRecipe::new);
|
||||
public static final SpecialRecipeSerializer<TerraPickTippingRecipe> SERIALIZER = new SpecialRecipeSerializer<>(TerraPickTippingRecipe::new);
|
||||
|
||||
public TerraPickTippingRecipe(ResourceLocation id) {
|
||||
super(id);
|
||||
|
||||
@@ -709,6 +709,7 @@ public final class ModItems {
|
||||
IForgeRegistry<IRecipeSerializer<?>> r = evt.getRegistry();
|
||||
register(r, AncientWillRecipe.SERIALIZER, "ancient_will_attach");
|
||||
register(r, ArmorUpgradeRecipe.SERIALIZER, "armor_upgrade");
|
||||
register(r, BannerRecipe.SERIALIZER, "banner_pattern_apply");
|
||||
register(r, BlackHoleTalismanExtractRecipe.SERIALIZER, "black_hole_talisman_extract");
|
||||
register(r, CompositeLensRecipe.SERIALIZER, "composite_lens");
|
||||
register(r, CosmeticAttachRecipe.SERIALIZER, "cosmetic_attach");
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
@@ -36,6 +37,7 @@ import vazkii.botania.api.item.ISequentialBreaker;
|
||||
import vazkii.botania.api.item.IWireframeCoordinateListProvider;
|
||||
import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.common.advancements.LokiPlaceTrigger;
|
||||
import vazkii.botania.common.core.handler.EquipmentHandler;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.core.helper.PlayerHelper;
|
||||
@@ -107,6 +109,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
|
||||
event.setCancellationResult(ActionResultType.SUCCESS);
|
||||
} else {
|
||||
ItemStack original = stack.copy();
|
||||
int successes = 0;
|
||||
for(BlockPos cursor : cursors) {
|
||||
BlockPos pos = hit.add(cursor);
|
||||
if(ManaItemHandler.requestManaExact(lokiRing, player, cost, false)) {
|
||||
@@ -124,9 +127,13 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
|
||||
|
||||
if (result == ActionResultType.SUCCESS) {
|
||||
ManaItemHandler.requestManaExact(lokiRing, player, cost, true);
|
||||
successes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player instanceof ServerPlayerEntity) {
|
||||
LokiPlaceTrigger.INSTANCE.trigger((ServerPlayerEntity) player, lokiRing, successes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.rod;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -66,8 +67,9 @@ public class ItemDiviningRod extends Item implements IManaUsingItem, IAvatarWiel
|
||||
pos.add(range, range, range))) {
|
||||
BlockState state = world.getBlockState(pos_);
|
||||
|
||||
if(Tags.Blocks.ORES.contains(state.getBlock())) {
|
||||
Random rand = new Random(state.hashCode() ^ seedxor);
|
||||
Block block = state.getBlock();
|
||||
if(Tags.Blocks.ORES.contains(block)) {
|
||||
Random rand = new Random(block.getRegistryName().hashCode() ^ seedxor);
|
||||
WispParticleData data = WispParticleData.wisp(0.25F, rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 8, false);
|
||||
world.addParticle(data, pos_.getX() + world.rand.nextFloat(),
|
||||
pos_.getY() + world.rand.nextFloat(),
|
||||
|
||||
@@ -12,6 +12,7 @@ package vazkii.botania.common.lib;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.item.DyeColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.EntityTypeTags;
|
||||
@@ -34,6 +35,11 @@ public class ModTags {
|
||||
public static final Tag<Item> NUGGETS_MANASTEEL = forgeTag("nuggets/manasteel");
|
||||
public static final Tag<Item> NUGGETS_TERRASTEEL = forgeTag("nuggets/terrasteel");
|
||||
|
||||
public static final Tag<Item> BLOCKS_ELEMENTIUM = forgeTag("storage_blocks/elementium");
|
||||
public static final Tag<Item> BLOCKS_MANASTEEL = forgeTag("storage_blocks/manasteel");
|
||||
public static final Tag<Item> BLOCKS_TERRASTEEL = forgeTag("storage_blocks/terrasteel");
|
||||
public static final Tag<Item> BLOCKS_QUARTZ = forgeTag("storage_blocks/quartz");
|
||||
|
||||
public static final Tag<Item> MYSTICAL_FLOWERS = tag("mystical_flowers");
|
||||
public static final Tag<Item> DOUBLE_MYSTICAL_FLOWERS = tag("double_mystical_flowers");
|
||||
|
||||
@@ -95,6 +101,44 @@ public class ModTags {
|
||||
public static final Tag<Item> RUNES_WATER = tag("runes/water");
|
||||
public static final Tag<Item> RUNES_WINTER = tag("runes/winter");
|
||||
public static final Tag<Item> RUNES_WRATH = tag("runes/wrath");
|
||||
|
||||
public static Tag<Item> getFlowerTag(DyeColor color) {
|
||||
switch (color) {
|
||||
default:
|
||||
case WHITE:
|
||||
return PETALS_WHITE;
|
||||
case ORANGE:
|
||||
return PETALS_ORANGE;
|
||||
case MAGENTA:
|
||||
return PETALS_MAGENTA;
|
||||
case LIGHT_BLUE:
|
||||
return PETALS_LIGHT_BLUE;
|
||||
case YELLOW:
|
||||
return PETALS_YELLOW;
|
||||
case LIME:
|
||||
return PETALS_LIME;
|
||||
case PINK:
|
||||
return PETALS_PINK;
|
||||
case GRAY:
|
||||
return PETALS_GRAY;
|
||||
case LIGHT_GRAY:
|
||||
return PETALS_LIGHT_GRAY;
|
||||
case CYAN:
|
||||
return PETALS_CYAN;
|
||||
case PURPLE:
|
||||
return PETALS_PURPLE;
|
||||
case BLUE:
|
||||
return PETALS_BLUE;
|
||||
case BROWN:
|
||||
return PETALS_BROWN;
|
||||
case GREEN:
|
||||
return PETALS_GREEN;
|
||||
case RED:
|
||||
return PETALS_RED;
|
||||
case BLACK:
|
||||
return PETALS_BLACK;
|
||||
}
|
||||
}
|
||||
|
||||
private static Tag<Item> tag(String name) {
|
||||
return new ItemTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, name));
|
||||
@@ -122,6 +166,11 @@ public class ModTags {
|
||||
public static final Tag<Block> LIVINGROCK = tag("livingrock");
|
||||
public static final Tag<Block> LIVINGWOOD = tag("livingwood");
|
||||
|
||||
public static final Tag<Block> BLOCKS_ELEMENTIUM = forgeTag("storage_blocks/elementium");
|
||||
public static final Tag<Block> BLOCKS_MANASTEEL = forgeTag("storage_blocks/manasteel");
|
||||
public static final Tag<Block> BLOCKS_TERRASTEEL = forgeTag("storage_blocks/terrasteel");
|
||||
public static final Tag<Block> BLOCKS_QUARTZ = forgeTag("storage_blocks/quartz");
|
||||
|
||||
public static final Tag<Block> GAIA_BREAK_BLACKLIST = tag("gaia_break_blacklist");
|
||||
public static final Tag<Block> MAGNET_RING_BLACKLIST = tag("magnet_ring_blacklist");
|
||||
|
||||
@@ -131,6 +180,10 @@ public class ModTags {
|
||||
private static Tag<Block> tag(String name) {
|
||||
return new BlockTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, name));
|
||||
}
|
||||
|
||||
private static Tag<Block> forgeTag(String name) {
|
||||
return new BlockTags.Wrapper(new ResourceLocation("forge", name));
|
||||
}
|
||||
}
|
||||
|
||||
public static class Entities {
|
||||
|
||||
@@ -7,14 +7,18 @@ import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class DataGenerators {
|
||||
@SubscribeEvent
|
||||
public static void gatherData(GatherDataEvent evt) {
|
||||
evt.getGenerator().addProvider(new BlockLootProvider(evt.getGenerator()));
|
||||
evt.getGenerator().addProvider(new BlockTagProvider(evt.getGenerator()));
|
||||
evt.getGenerator().addProvider(new ItemTagProvider(evt.getGenerator()));
|
||||
evt.getGenerator().addProvider(new StonecuttingProvider(evt.getGenerator()));
|
||||
evt.getGenerator().addProvider(new FloatingFlowerModelProvider(evt.getGenerator(), evt.getExistingFileHelper()));
|
||||
evt.getGenerator().addProvider(new ItemModelProvider(evt.getGenerator(), evt.getExistingFileHelper()));
|
||||
evt.getGenerator().addProvider(new BlockstateProvider(evt.getGenerator(), evt.getExistingFileHelper()));
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void gatherData(GatherDataEvent evt) {
|
||||
if (evt.includeServer()) {
|
||||
evt.getGenerator().addProvider(new BlockLootProvider(evt.getGenerator()));
|
||||
evt.getGenerator().addProvider(new BlockTagProvider(evt.getGenerator()));
|
||||
evt.getGenerator().addProvider(new ItemTagProvider(evt.getGenerator()));
|
||||
evt.getGenerator().addProvider(new StonecuttingProvider(evt.getGenerator()));
|
||||
evt.getGenerator().addProvider(new RecipeProvider(evt.getGenerator()));
|
||||
evt.getGenerator().addProvider(new SmeltingProvider(evt.getGenerator()));
|
||||
evt.getGenerator().addProvider(new FloatingFlowerModelProvider(evt.getGenerator(), evt.getExistingFileHelper()));
|
||||
evt.getGenerator().addProvider(new ItemModelProvider(evt.getGenerator(), evt.getExistingFileHelper()));
|
||||
evt.getGenerator().addProvider(new BlockstateProvider(evt.getGenerator(), evt.getExistingFileHelper()));
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* This class was created by <Hubry>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [2020-02-12, 00:02 (UTC+2)]
|
||||
*/
|
||||
package vazkii.botania.data;
|
||||
|
||||
import net.minecraft.data.CookingRecipeBuilder;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.data.RecipeProvider;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import vazkii.botania.common.block.ModFluffBlocks;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class SmeltingProvider extends RecipeProvider {
|
||||
public SmeltingProvider(DataGenerator generatorIn) {
|
||||
super(generatorIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRecipes(Consumer<IFinishedRecipe> consumer) {
|
||||
CookingRecipeBuilder.smeltingRecipe(Ingredient.fromItems(ModFluffBlocks.biomeCobblestoneForest), ModFluffBlocks.biomeStoneForest, 0.1f, 200)
|
||||
.addCriterion("has_item", hasItem(ModFluffBlocks.biomeCobblestoneForest))
|
||||
.build(consumer, "botania:smelting/metamorphic_forest_stone");
|
||||
CookingRecipeBuilder.smeltingRecipe(Ingredient.fromItems(ModFluffBlocks.biomeCobblestonePlains), ModFluffBlocks.biomeStonePlains, 0.1f, 200)
|
||||
.addCriterion("has_item", hasItem(ModFluffBlocks.biomeCobblestonePlains))
|
||||
.build(consumer, "botania:smelting/metamorphic_plains_stone");
|
||||
CookingRecipeBuilder.smeltingRecipe(Ingredient.fromItems(ModFluffBlocks.biomeCobblestoneMountain), ModFluffBlocks.biomeStoneMountain, 0.1f, 200)
|
||||
.addCriterion("has_item", hasItem(ModFluffBlocks.biomeCobblestoneMountain))
|
||||
.build(consumer, "botania:smelting/metamorphic_mountain_stone");
|
||||
CookingRecipeBuilder.smeltingRecipe(Ingredient.fromItems(ModFluffBlocks.biomeCobblestoneFungal), ModFluffBlocks.biomeStoneFungal, 0.1f, 200)
|
||||
.addCriterion("has_item", hasItem(ModFluffBlocks.biomeCobblestoneFungal))
|
||||
.build(consumer, "botania:smelting/metamorphic_fungal_stone");
|
||||
CookingRecipeBuilder.smeltingRecipe(Ingredient.fromItems(ModFluffBlocks.biomeCobblestoneSwamp), ModFluffBlocks.biomeStoneSwamp, 0.1f, 200)
|
||||
.addCriterion("has_item", hasItem(ModFluffBlocks.biomeCobblestoneSwamp))
|
||||
.build(consumer, "botania:smelting/metamorphic_swamp_stone");
|
||||
CookingRecipeBuilder.smeltingRecipe(Ingredient.fromItems(ModFluffBlocks.biomeCobblestoneDesert), ModFluffBlocks.biomeStoneDesert, 0.1f, 200)
|
||||
.addCriterion("has_item", hasItem(ModFluffBlocks.biomeCobblestoneDesert))
|
||||
.build(consumer, "botania:smelting/metamorphic_desert_stone");
|
||||
CookingRecipeBuilder.smeltingRecipe(Ingredient.fromItems(ModFluffBlocks.biomeCobblestoneTaiga), ModFluffBlocks.biomeStoneTaiga, 0.1f, 200)
|
||||
.addCriterion("has_item", hasItem(ModFluffBlocks.biomeCobblestoneTaiga))
|
||||
.build(consumer, "botania:smelting/metamorphic_taiga_stone");
|
||||
CookingRecipeBuilder.smeltingRecipe(Ingredient.fromItems(ModFluffBlocks.biomeCobblestoneMesa), ModFluffBlocks.biomeStoneMesa, 0.1f, 200)
|
||||
.addCriterion("has_item", hasItem(ModFluffBlocks.biomeCobblestoneMesa))
|
||||
.build(consumer, "botania:smelting/metamorphic_mesa_stone");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Botania smelting recipes";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* This class was created by <Hubry>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [2020-02-12, 19:29 (UTC+2)]
|
||||
*/
|
||||
package vazkii.botania.data;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class WrapperResult implements IFinishedRecipe {
|
||||
private final IFinishedRecipe delegate;
|
||||
@Nullable
|
||||
private final IRecipeSerializer<?> type;
|
||||
@Nullable
|
||||
private final Consumer<JsonObject> transform;
|
||||
|
||||
/**
|
||||
* Wraps recipe consumer with one that swaps the recipe type to a different one.
|
||||
*/
|
||||
public static Consumer<IFinishedRecipe> ofType(IRecipeSerializer<?> type, Consumer<IFinishedRecipe> parent) {
|
||||
return recipe -> parent.accept(new WrapperResult(recipe, type, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the resulting recipe json with the specified action, eg. adding NBT to an item result.
|
||||
*/
|
||||
public static Consumer<IFinishedRecipe> transformJson(Consumer<IFinishedRecipe> parent, Consumer<JsonObject> transform) {
|
||||
return recipe -> parent.accept(new WrapperResult(recipe, null, transform));
|
||||
}
|
||||
|
||||
private WrapperResult(IFinishedRecipe delegate, @Nullable IRecipeSerializer<?> type, @Nullable Consumer<JsonObject> transform) {
|
||||
this.delegate = delegate;
|
||||
this.type = type;
|
||||
this.transform = transform;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonObject json) {
|
||||
delegate.serialize(json);
|
||||
if(transform != null)
|
||||
transform.accept(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject getRecipeJson() {
|
||||
if(type == null)
|
||||
return IFinishedRecipe.super.getRecipeJson();
|
||||
JsonObject jsonobject = new JsonObject();
|
||||
jsonobject.addProperty("type", this.type.getRegistryName().toString());
|
||||
this.serialize(jsonobject);
|
||||
return jsonobject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID() {
|
||||
return delegate.getID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
return type != null ? type : delegate.getSerializer();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JsonObject getAdvancementJson() {
|
||||
return delegate.getAdvancementJson();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getAdvancementID() {
|
||||
return delegate.getAdvancementID();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
@javax.annotation.ParametersAreNonnullByDefault
|
||||
@mcp.MethodsReturnNonnullByDefault
|
||||
package vazkii.botania.data;
|
||||
Reference in new issue
Block a user