Pin MCPConfig version
Cleanup and implement BrewingRecipes Delete client command related things Cleanup some biome stuff.
This commit is contained in:
parent
f72a7e02e3
commit
a0cef07a0b
22 changed files with 263 additions and 711 deletions
10
build.gradle
10
build.gradle
|
@ -18,7 +18,7 @@ version = '1.0.0'
|
||||||
project(':mcp') {
|
project(':mcp') {
|
||||||
apply plugin: 'net.minecraftforge.gradle.forgedev.mcp'
|
apply plugin: 'net.minecraftforge.gradle.forgedev.mcp'
|
||||||
mcp {
|
mcp {
|
||||||
config = 'de.oceanlabs.mcp:mcp_config:1.13@zip'
|
config = 'de.oceanlabs.mcp:mcp_config:1.13-2018.08.19.04.56.08@zip'
|
||||||
pipeline = 'joined'
|
pipeline = 'joined'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,13 +73,17 @@ project(':forge') {
|
||||||
srgPatches = false
|
srgPatches = false
|
||||||
clientRun {
|
clientRun {
|
||||||
main = 'net.minecraftforge.fml.LaunchTesting'
|
main = 'net.minecraftforge.fml.LaunchTesting'
|
||||||
env = [
|
environment = [
|
||||||
target: 'fmldevclient'
|
target: 'fmldevclient'
|
||||||
]
|
]
|
||||||
|
properties = [
|
||||||
|
target: 'fmldevclient',
|
||||||
|
assetDirectory: downloadAssets.output
|
||||||
|
]
|
||||||
}
|
}
|
||||||
serverRun {
|
serverRun {
|
||||||
main = 'net.minecraftforge.fml.LaunchTesting'
|
main = 'net.minecraftforge.fml.LaunchTesting'
|
||||||
env = [
|
environment = [
|
||||||
target: 'fmldevserver'
|
target: 'fmldevserver'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
-public final class ItemStack {
|
-public final class ItemStack {
|
||||||
+public final class ItemStack extends net.minecraftforge.common.capabilities.CapabilityProvider implements net.minecraftforge.common.capabilities.ICapabilitySerializable<NBTTagCompound> {
|
+public final class ItemStack extends net.minecraftforge.common.capabilities.CapabilityProvider implements net.minecraftforge.common.capabilities.ICapabilitySerializable<NBTTagCompound>, net.minecraftforge.common.extensions.IForgeItemStack {
|
||||||
private static final Logger field_199558_c = LogManager.getLogger();
|
private static final Logger field_199558_c = LogManager.getLogger();
|
||||||
public static final ItemStack EMPTY = new ItemStack((Item)null);
|
public static final ItemStack EMPTY = new ItemStack((Item)null);
|
||||||
public static final DecimalFormat DECIMALFORMAT = func_208306_D();
|
public static final DecimalFormat DECIMALFORMAT = func_208306_D();
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
--- a/net/minecraft/item/crafting/IRecipeHidden.java
|
||||||
|
+++ b/net/minecraft/item/crafting/IRecipeHidden.java
|
||||||
|
@@ -3,7 +3,7 @@
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
-public abstract class IRecipeHidden implements IRecipe {
|
||||||
|
+public abstract class IRecipeHidden extends net.minecraftforge.registries.ForgeRegistryEntry<IRecipe> implements IRecipe {
|
||||||
|
private final ResourceLocation field_199563_a;
|
||||||
|
|
||||||
|
public IRecipeHidden(ResourceLocation p_i48169_1_) {
|
|
@ -0,0 +1,83 @@
|
||||||
|
--- a/net/minecraft/tileentity/TileEntityBrewingStand.java
|
||||||
|
+++ b/net/minecraft/tileentity/TileEntityBrewingStand.java
|
||||||
|
@@ -133,6 +133,7 @@
|
||||||
|
|
||||||
|
private boolean canBrew() {
|
||||||
|
ItemStack itemstack = this.brewingItemStacks.get(3);
|
||||||
|
+ if (!itemstack.isEmpty()) return net.minecraftforge.common.brewing.BrewingRecipeRegistry.canBrew(brewingItemStacks, itemstack, OUTPUT_SLOTS); // divert to VanillaBrewingRegistry
|
||||||
|
if (itemstack.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
} else if (!PotionBrewing.isReagent(itemstack)) {
|
||||||
|
@@ -150,16 +151,15 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
private void brewPotions() {
|
||||||
|
+ if (net.minecraftforge.event.ForgeEventFactory.onPotionAttemptBrew(brewingItemStacks)) return;
|
||||||
|
ItemStack itemstack = this.brewingItemStacks.get(3);
|
||||||
|
|
||||||
|
- for(int i = 0; i < 3; ++i) {
|
||||||
|
- this.brewingItemStacks.set(i, PotionBrewing.doReaction(itemstack, this.brewingItemStacks.get(i)));
|
||||||
|
- }
|
||||||
|
+ net.minecraftforge.common.brewing.BrewingRecipeRegistry.brewPotions(brewingItemStacks, itemstack, OUTPUT_SLOTS);
|
||||||
|
|
||||||
|
itemstack.shrink(1);
|
||||||
|
BlockPos blockpos = this.getPos();
|
||||||
|
- if (itemstack.getItem().hasContainerItem()) {
|
||||||
|
- ItemStack itemstack1 = new ItemStack(itemstack.getItem().getContainerItem());
|
||||||
|
+ if (itemstack.hasContainerItem()) {
|
||||||
|
+ ItemStack itemstack1 = itemstack.getContainerItem();
|
||||||
|
if (itemstack.isEmpty()) {
|
||||||
|
itemstack = itemstack1;
|
||||||
|
} else {
|
||||||
|
@@ -169,6 +169,7 @@
|
||||||
|
|
||||||
|
this.brewingItemStacks.set(3, itemstack);
|
||||||
|
this.world.playEvent(1035, blockpos, 0);
|
||||||
|
+ net.minecraftforge.event.ForgeEventFactory.onPotionBrewed(brewingItemStacks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readFromNBT(NBTTagCompound compound) {
|
||||||
|
@@ -234,13 +235,13 @@
|
||||||
|
|
||||||
|
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||||
|
if (index == 3) {
|
||||||
|
- return PotionBrewing.isReagent(stack);
|
||||||
|
+ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidIngredient(stack);
|
||||||
|
} else {
|
||||||
|
Item item = stack.getItem();
|
||||||
|
if (index == 4) {
|
||||||
|
return item == Items.BLAZE_POWDER;
|
||||||
|
} else {
|
||||||
|
- return (item == Items.POTIONITEM || item == Items.SPLASH_POTION || item == Items.LINGERING_POTION || item == Items.GLASS_BOTTLE) && this.getStackInSlot(index).isEmpty();
|
||||||
|
+ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(stack) && this.getStackInSlot(index).isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -302,4 +303,27 @@
|
||||||
|
public void clear() {
|
||||||
|
this.brewingItemStacks.clear();
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ net.minecraftforge.common.capabilities.OptionalCapabilityInstance<? extends net.minecraftforge.items.IItemHandler>[] handlers =
|
||||||
|
+ net.minecraftforge.items.wrapper.SidedInvWrapper.create(this, EnumFacing.UP, EnumFacing.DOWN, EnumFacing.NORTH);
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public <T> net.minecraftforge.common.capabilities.OptionalCapabilityInstance<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @Nullable EnumFacing facing) {
|
||||||
|
+ if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||||
|
+ if (facing == EnumFacing.UP)
|
||||||
|
+ return handlers[0].cast();
|
||||||
|
+ else if (facing == EnumFacing.UP)
|
||||||
|
+ return handlers[1].cast();
|
||||||
|
+ else
|
||||||
|
+ return handlers[2].cast();
|
||||||
|
+ }
|
||||||
|
+ return super.getCapability(capability, facing);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void invalidate() {
|
||||||
|
+ super.invalidate();
|
||||||
|
+ for (int x = 0; x < handlers.length; x++)
|
||||||
|
+ handlers[x].invalidate();
|
||||||
|
+ }
|
||||||
|
}
|
|
@ -1,168 +0,0 @@
|
||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2018.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.client;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiChat;
|
|
||||||
import net.minecraft.command.CommandException;
|
|
||||||
import net.minecraft.command.CommandHandler;
|
|
||||||
import net.minecraft.command.ICommand;
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.command.WrongUsageException;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.event.CommandEvent;
|
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
|
||||||
import net.minecraft.util.text.TextComponentTranslation;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import net.minecraftforge.fml.common.FMLLog;
|
|
||||||
|
|
||||||
import static net.minecraft.util.text.TextFormatting.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The class that handles client-side chat commands. You should register any
|
|
||||||
* commands that you want handled on the client with this command handler.
|
|
||||||
*
|
|
||||||
* If there is a command with the same name registered both on the server and
|
|
||||||
* client, the client takes precedence!
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ClientCommandHandler {} /*extends CommandHandler
|
|
||||||
{
|
|
||||||
public static final ClientCommandHandler instance = new ClientCommandHandler();
|
|
||||||
|
|
||||||
public String[] latestAutoComplete = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return 1 if successfully executed, -1 if no permission or wrong usage,
|
|
||||||
* 0 if it doesn't exist or it was canceled (it's sent to the server)
|
|
||||||
* /
|
|
||||||
@Override
|
|
||||||
public int executeCommand(ICommandSender sender, String message)
|
|
||||||
{
|
|
||||||
message = message.trim();
|
|
||||||
|
|
||||||
boolean usedSlash = message.startsWith("/");
|
|
||||||
if (usedSlash)
|
|
||||||
{
|
|
||||||
message = message.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] temp = message.split(" ");
|
|
||||||
String[] args = new String[temp.length - 1];
|
|
||||||
String commandName = temp[0];
|
|
||||||
System.arraycopy(temp, 1, args, 0, args.length);
|
|
||||||
ICommand icommand = getCommands().get(commandName);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (icommand == null || (!usedSlash && icommand instanceof IClientCommand && !((IClientCommand)icommand).allowUsageWithoutPrefix(sender, message)))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (icommand.checkPermission(this.getServer(), sender))
|
|
||||||
{
|
|
||||||
CommandEvent event = new CommandEvent(icommand, sender, args);
|
|
||||||
if (MinecraftForge.EVENT_BUS.post(event))
|
|
||||||
{
|
|
||||||
if (event.getException() != null)
|
|
||||||
{
|
|
||||||
throw event.getException();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.tryExecute(sender, args, icommand, message);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sender.sendMessage(format(RED, "commands.generic.permission"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (WrongUsageException wue)
|
|
||||||
{
|
|
||||||
sender.sendMessage(format(RED, "commands.generic.usage", format(RED, wue.getMessage(), wue.getErrorObjects())));
|
|
||||||
}
|
|
||||||
catch (CommandException ce)
|
|
||||||
{
|
|
||||||
sender.sendMessage(format(RED, ce.getMessage(), ce.getErrorObjects()));
|
|
||||||
}
|
|
||||||
catch (Throwable t)
|
|
||||||
{
|
|
||||||
sender.sendMessage(format(RED, "commands.generic.exception"));
|
|
||||||
FMLLog.log.error("Command '{}' threw an exception:", message, t);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Couple of helpers because the mcp names are stupid and long...
|
|
||||||
private TextComponentTranslation format(TextFormatting color, String str, Object... args)
|
|
||||||
{
|
|
||||||
TextComponentTranslation ret = new TextComponentTranslation(str, args);
|
|
||||||
ret.getStyle().setColor(color);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void autoComplete(String leftOfCursor)
|
|
||||||
{
|
|
||||||
latestAutoComplete = null;
|
|
||||||
|
|
||||||
if (leftOfCursor.charAt(0) == '/')
|
|
||||||
{
|
|
||||||
leftOfCursor = leftOfCursor.substring(1);
|
|
||||||
|
|
||||||
Minecraft mc = FMLClientHandler.instance().getClient();
|
|
||||||
if (mc.currentScreen instanceof GuiChat)
|
|
||||||
{
|
|
||||||
List<String> commands = getTabCompletions(mc.player, leftOfCursor, mc.player.getPosition());
|
|
||||||
if (!commands.isEmpty())
|
|
||||||
{
|
|
||||||
if (leftOfCursor.indexOf(' ') == -1)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < commands.size(); i++)
|
|
||||||
{
|
|
||||||
commands.set(i, GRAY + "/" + commands.get(i) + RESET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int i = 0; i < commands.size(); i++)
|
|
||||||
{
|
|
||||||
commands.set(i, GRAY + commands.get(i) + RESET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
latestAutoComplete = commands.toArray(new String[commands.size()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected MinecraftServer getServer() {
|
|
||||||
return Minecraft.getMinecraft().getIntegratedServer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2018.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.client;
|
|
||||||
|
|
||||||
import net.minecraft.command.ICommand;
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Client-side commands can implement this interface to allow additional control over when the command may be used.
|
|
||||||
*/
|
|
||||||
public interface IClientCommand extends ICommand
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine whether this command can be used without the "/" prefix. By default this is true.
|
|
||||||
* @param sender the command sender
|
|
||||||
* @param message the message, without potential prefix
|
|
||||||
* @return true to allow the usage of this command without the prefix
|
|
||||||
*/
|
|
||||||
boolean allowUsageWithoutPrefix(ICommandSender sender, String message);
|
|
||||||
|
|
||||||
}
|
|
|
@ -23,13 +23,15 @@ import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import net.minecraft.init.Biomes;
|
import net.minecraft.init.Biomes;
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.biome.*;
|
import net.minecraft.world.biome.*;
|
||||||
import static net.minecraftforge.common.BiomeDictionary.Type.*;
|
import static net.minecraftforge.common.BiomeDictionary.Type.*;
|
||||||
import net.minecraftforge.fml.common.FMLLog;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
@ -38,6 +40,7 @@ import com.google.common.collect.ImmutableList;
|
||||||
public class BiomeDictionary
|
public class BiomeDictionary
|
||||||
{
|
{
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
public static final class Type
|
public static final class Type
|
||||||
{
|
{
|
||||||
|
@ -106,11 +109,6 @@ public class BiomeDictionary
|
||||||
byName.put(name, this);
|
byName.put(name, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasSubTypes()
|
|
||||||
{
|
|
||||||
return !subTypes.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name for this type.
|
* Gets the name for this type.
|
||||||
*/
|
*/
|
||||||
|
@ -159,6 +157,16 @@ public class BiomeDictionary
|
||||||
{
|
{
|
||||||
return allTypes;
|
return allTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static Type fromVanilla(Biome.Category category)
|
||||||
|
{
|
||||||
|
if (category == Biome.Category.NONE)
|
||||||
|
return null;
|
||||||
|
if (category == Biome.Category.THEEND)
|
||||||
|
return VOID;
|
||||||
|
return getType(category.name());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<ResourceLocation, BiomeInfo> biomeInfoMap = new HashMap<ResourceLocation, BiomeInfo>();
|
private static final Map<ResourceLocation, BiomeInfo> biomeInfoMap = new HashMap<ResourceLocation, BiomeInfo>();
|
||||||
|
@ -262,28 +270,10 @@ public class BiomeDictionary
|
||||||
*/
|
*/
|
||||||
public static void makeBestGuess(Biome biome)
|
public static void makeBestGuess(Biome biome)
|
||||||
{
|
{
|
||||||
if (biome.decorator.treesPerChunk >= 3)
|
Type type = Type.fromVanilla(biome.func_201856_r());
|
||||||
|
if (type != null)
|
||||||
{
|
{
|
||||||
if (biome.isHighHumidity() && biome.getDefaultTemperature() >= 0.9F)
|
BiomeDictionary.addTypes(biome, type);
|
||||||
{
|
|
||||||
BiomeDictionary.addTypes(biome, JUNGLE);
|
|
||||||
}
|
|
||||||
else if (!biome.isHighHumidity())
|
|
||||||
{
|
|
||||||
BiomeDictionary.addTypes(biome, FOREST);
|
|
||||||
|
|
||||||
if (biome.getDefaultTemperature() <= 0.2f)
|
|
||||||
{
|
|
||||||
BiomeDictionary.addTypes(biome, CONIFEROUS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (biome.getHeightVariation() <= 0.3F && biome.getHeightVariation() >= 0.0F)
|
|
||||||
{
|
|
||||||
if (!biome.isHighHumidity() || biome.getBaseHeight() >= 0.0F)
|
|
||||||
{
|
|
||||||
BiomeDictionary.addTypes(biome, PLAINS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (biome.getRainfall() > 0.85f)
|
if (biome.getRainfall() > 0.85f)
|
||||||
|
@ -306,15 +296,6 @@ public class BiomeDictionary
|
||||||
BiomeDictionary.addTypes(biome, COLD);
|
BiomeDictionary.addTypes(biome, COLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (biome.decorator.treesPerChunk > 0 && biome.decorator.treesPerChunk < 3)
|
|
||||||
{
|
|
||||||
BiomeDictionary.addTypes(biome, SPARSE);
|
|
||||||
}
|
|
||||||
else if (biome.decorator.treesPerChunk >= 10)
|
|
||||||
{
|
|
||||||
BiomeDictionary.addTypes(biome, DENSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (biome.isHighHumidity() && biome.getBaseHeight() < 0.0F && (biome.getHeightVariation() <= 0.3F && biome.getHeightVariation() >= 0.0F))
|
if (biome.isHighHumidity() && biome.getBaseHeight() < 0.0F && (biome.getHeightVariation() <= 0.3F && biome.getHeightVariation() >= 0.0F))
|
||||||
{
|
{
|
||||||
BiomeDictionary.addTypes(biome, SWAMP);
|
BiomeDictionary.addTypes(biome, SWAMP);
|
||||||
|
@ -341,29 +322,6 @@ public class BiomeDictionary
|
||||||
{
|
{
|
||||||
BiomeDictionary.addTypes(biome, MOUNTAIN);
|
BiomeDictionary.addTypes(biome, MOUNTAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (biome.getEnableSnow())
|
|
||||||
{
|
|
||||||
BiomeDictionary.addTypes(biome, SNOWY);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (biome.topBlock.getBlock() != Blocks.SAND && biome.getDefaultTemperature() >= 1.0f && biome.getRainfall() < 0.2f)
|
|
||||||
{
|
|
||||||
BiomeDictionary.addTypes(biome, SAVANNA);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (biome.topBlock.getBlock() == Blocks.SAND)
|
|
||||||
{
|
|
||||||
BiomeDictionary.addTypes(biome, SANDY);
|
|
||||||
}
|
|
||||||
else if (biome.topBlock.getBlock() == Blocks.MYCELIUM)
|
|
||||||
{
|
|
||||||
BiomeDictionary.addTypes(biome, MUSHROOM);
|
|
||||||
}
|
|
||||||
if (biome.fillerBlock.getBlock() == Blocks.HARDENED_CLAY)
|
|
||||||
{
|
|
||||||
BiomeDictionary.addTypes(biome, MESA);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Internal implementation
|
//Internal implementation
|
||||||
|
@ -380,7 +338,7 @@ public class BiomeDictionary
|
||||||
if (!hasAnyType(biome))
|
if (!hasAnyType(biome))
|
||||||
{
|
{
|
||||||
makeBestGuess(biome);
|
makeBestGuess(biome);
|
||||||
FMLLog.log.warn("No types have been added to Biome {}, types have been assigned on a best-effort guess: {}", biome.getRegistryName(), getTypes(biome));
|
LOGGER.warn("No types have been added to Biome {}, types have been assigned on a best-effort guess: {}", biome.getRegistryName(), getTypes(biome));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,6 +404,17 @@ public class BiomeDictionary
|
||||||
addTypes(Biomes.MESA, MESA, SANDY );
|
addTypes(Biomes.MESA, MESA, SANDY );
|
||||||
addTypes(Biomes.MESA_ROCK, MESA, SPARSE, SANDY );
|
addTypes(Biomes.MESA_ROCK, MESA, SPARSE, SANDY );
|
||||||
addTypes(Biomes.MESA_CLEAR_ROCK, MESA, SANDY );
|
addTypes(Biomes.MESA_CLEAR_ROCK, MESA, SANDY );
|
||||||
|
addTypes(Biomes.field_201936_P, END );
|
||||||
|
addTypes(Biomes.field_201937_Q, END );
|
||||||
|
addTypes(Biomes.field_201938_R, END );
|
||||||
|
addTypes(Biomes.field_201939_S, END );
|
||||||
|
addTypes(Biomes.field_203614_T, OCEAN, HOT );
|
||||||
|
addTypes(Biomes.field_203615_U, OCEAN );
|
||||||
|
addTypes(Biomes.field_203616_V, OCEAN, COLD );
|
||||||
|
addTypes(Biomes.field_203617_W, OCEAN, HOT );
|
||||||
|
addTypes(Biomes.field_203618_X, OCEAN );
|
||||||
|
addTypes(Biomes.field_203619_Y, OCEAN, COLD );
|
||||||
|
addTypes(Biomes.field_203620_Z, OCEAN, COLD );
|
||||||
addTypes(Biomes.VOID, VOID );
|
addTypes(Biomes.VOID, VOID );
|
||||||
addTypes(Biomes.MUTATED_PLAINS, PLAINS, RARE );
|
addTypes(Biomes.MUTATED_PLAINS, PLAINS, RARE );
|
||||||
addTypes(Biomes.MUTATED_DESERT, HOT, DRY, SANDY, RARE );
|
addTypes(Biomes.MUTATED_DESERT, HOT, DRY, SANDY, RARE );
|
||||||
|
@ -471,14 +440,11 @@ public class BiomeDictionary
|
||||||
|
|
||||||
|
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
{
|
|
||||||
FMLLog.log.debug("BiomeDictionary:");
|
|
||||||
for (Type type : Type.byName.values())
|
|
||||||
{
|
{
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append(" ").append(type.name).append(": ").append(type.biomes.stream().map(Biome::getBiomeName).collect(Collectors.joining(", ")));
|
buf.append("BiomeDictionary:\n");
|
||||||
FMLLog.log.debug(buf.toString());
|
Type.byName.forEach((name, type) -> buf.append(" ").append(type.name).append(": ").append(type.biomes.stream().map(b -> b.getRegistryName().toString()).collect(Collectors.joining(", "))).append('\n'));
|
||||||
}
|
LOGGER.debug(buf.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
package net.minecraftforge.common;
|
package net.minecraftforge.common;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -29,9 +28,7 @@ import com.google.common.collect.ImmutableList;
|
||||||
import net.minecraft.init.Biomes;
|
import net.minecraft.init.Biomes;
|
||||||
import net.minecraft.util.WeightedRandom;
|
import net.minecraft.util.WeightedRandom;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.biome.BiomeProvider;
|
import net.minecraft.world.biome.provider.BiomeProvider;
|
||||||
import net.minecraft.world.gen.structure.MapGenVillage;
|
|
||||||
import net.minecraftforge.common.util.EnumHelper;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -41,9 +38,6 @@ public class BiomeManager
|
||||||
|
|
||||||
public static List<Biome> oceanBiomes = new ArrayList<Biome>();
|
public static List<Biome> oceanBiomes = new ArrayList<Biome>();
|
||||||
|
|
||||||
public static ArrayList<Biome> strongHoldBiomes = new ArrayList<Biome>();
|
|
||||||
public static ArrayList<Biome> strongHoldBiomesBlackList = new ArrayList<Biome>();
|
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
oceanBiomes.add(Biomes.OCEAN);
|
oceanBiomes.add(Biomes.OCEAN);
|
||||||
|
@ -86,55 +80,19 @@ public class BiomeManager
|
||||||
return currentBiomes;
|
return currentBiomes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addVillageBiome(Biome biome, boolean canSpawn)
|
|
||||||
{
|
|
||||||
if (!MapGenVillage.VILLAGE_SPAWN_BIOMES.contains(biome))
|
|
||||||
{
|
|
||||||
ArrayList<Biome> biomes = new ArrayList<Biome>(MapGenVillage.VILLAGE_SPAWN_BIOMES);
|
|
||||||
biomes.add(biome);
|
|
||||||
MapGenVillage.VILLAGE_SPAWN_BIOMES = biomes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeVillageBiome(Biome biome)
|
|
||||||
{
|
|
||||||
if (MapGenVillage.VILLAGE_SPAWN_BIOMES.contains(biome))
|
|
||||||
{
|
|
||||||
ArrayList<Biome> biomes = new ArrayList<Biome>(MapGenVillage.VILLAGE_SPAWN_BIOMES);
|
|
||||||
biomes.remove(biome);
|
|
||||||
MapGenVillage.VILLAGE_SPAWN_BIOMES = biomes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addStrongholdBiome(Biome biome)
|
|
||||||
{
|
|
||||||
if (!strongHoldBiomes.contains(biome))
|
|
||||||
{
|
|
||||||
strongHoldBiomes.add(biome);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeStrongholdBiome(Biome biome)
|
|
||||||
{
|
|
||||||
if (!strongHoldBiomesBlackList.contains(biome))
|
|
||||||
{
|
|
||||||
strongHoldBiomesBlackList.add(biome);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addSpawnBiome(Biome biome)
|
public static void addSpawnBiome(Biome biome)
|
||||||
{
|
{
|
||||||
if (!BiomeProvider.allowedBiomes.contains(biome))
|
if (!BiomeProvider.field_201540_a.contains(biome))
|
||||||
{
|
{
|
||||||
BiomeProvider.allowedBiomes.add(biome);
|
BiomeProvider.field_201540_a.add(biome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeSpawnBiome(Biome biome)
|
public static void removeSpawnBiome(Biome biome)
|
||||||
{
|
{
|
||||||
if (BiomeProvider.allowedBiomes.contains(biome))
|
if (BiomeProvider.field_201540_a.contains(biome))
|
||||||
{
|
{
|
||||||
BiomeProvider.allowedBiomes.remove(biome);
|
BiomeProvider.field_201540_a.remove(biome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,23 +137,8 @@ public class BiomeManager
|
||||||
{
|
{
|
||||||
DESERT, WARM, COOL, ICY;
|
DESERT, WARM, COOL, ICY;
|
||||||
|
|
||||||
public static BiomeType getType(String name)
|
public static BiomeType create(String name) {
|
||||||
{
|
return null;
|
||||||
name = name.toUpperCase();
|
|
||||||
|
|
||||||
for (BiomeType t : values())
|
|
||||||
{
|
|
||||||
if (t.name().equals(name)) return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
BiomeType ret = EnumHelper.addEnum(BiomeType.class, name, new Class[0], new Object[0]);
|
|
||||||
|
|
||||||
if (ret.ordinal() >= biomes.length)
|
|
||||||
{
|
|
||||||
biomes = Arrays.copyOf(biomes, ret.ordinal() + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -399,7 +399,7 @@ public class DimensionManager
|
||||||
{
|
{
|
||||||
w.saveAllChunks(true, null);
|
w.saveAllChunks(true, null);
|
||||||
}
|
}
|
||||||
catch (MinecraftException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LOGGER.error(DIMMGR,"Caught an exception while saving all chunks:", e);
|
LOGGER.error(DIMMGR,"Caught an exception while saving all chunks:", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2018.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.common.brewing;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public abstract class AbstractBrewingRecipe<T> implements IBrewingRecipe
|
|
||||||
{
|
|
||||||
@Nonnull
|
|
||||||
private final ItemStack input;
|
|
||||||
private final T ingredient;
|
|
||||||
private final ItemStack output;
|
|
||||||
|
|
||||||
protected AbstractBrewingRecipe(@Nonnull ItemStack input, @Nonnull T ingredient, @Nonnull ItemStack output)
|
|
||||||
{
|
|
||||||
this.input = input;
|
|
||||||
this.ingredient = ingredient;
|
|
||||||
this.output = output;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInput(@Nonnull ItemStack stack)
|
|
||||||
{
|
|
||||||
return OreDictionary.itemMatches(this.getInput(), stack, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nonnull
|
|
||||||
public ItemStack getOutput(@Nonnull ItemStack input, @Nonnull ItemStack ingredient)
|
|
||||||
{
|
|
||||||
return isInput(input) && isIngredient(ingredient) ? getOutput().copy() : ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public ItemStack getInput()
|
|
||||||
{
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public T getIngredient()
|
|
||||||
{
|
|
||||||
return ingredient;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public ItemStack getOutput()
|
|
||||||
{
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2018.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.common.brewing;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class BrewingOreRecipe extends AbstractBrewingRecipe<List<ItemStack>> {
|
|
||||||
|
|
||||||
public BrewingOreRecipe(@Nonnull ItemStack input, @Nonnull String ingredient, @Nonnull ItemStack output)
|
|
||||||
{
|
|
||||||
super(input, OreDictionary.getOres(ingredient), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BrewingOreRecipe(@Nonnull ItemStack input, @Nonnull List<ItemStack> ingredient, @Nonnull ItemStack output)
|
|
||||||
{
|
|
||||||
super(input, ingredient, output);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isIngredient(@Nonnull ItemStack stack)
|
|
||||||
{
|
|
||||||
for (ItemStack target : this.getIngredient())
|
|
||||||
{
|
|
||||||
if (OreDictionary.itemMatches(target, stack, false))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,20 +20,53 @@
|
||||||
package net.minecraftforge.common.brewing;
|
package net.minecraftforge.common.brewing;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class BrewingRecipe extends AbstractBrewingRecipe<ItemStack> {
|
public class BrewingRecipe implements IBrewingRecipe
|
||||||
|
|
||||||
public BrewingRecipe(@Nonnull ItemStack input, @Nonnull ItemStack ingredient, @Nonnull ItemStack output)
|
|
||||||
{
|
{
|
||||||
super(input, ingredient, output);
|
@Nonnull private final ItemStack input;
|
||||||
|
@Nonnull private final Ingredient ingredient;
|
||||||
|
@Nonnull private final ItemStack output;
|
||||||
|
|
||||||
|
public BrewingRecipe(ItemStack input, Ingredient ingredient, ItemStack output)
|
||||||
|
{
|
||||||
|
this.input = input;
|
||||||
|
this.ingredient = ingredient;
|
||||||
|
this.output = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isIngredient(@Nonnull ItemStack stack)
|
public boolean isInput(@Nonnull ItemStack stack)
|
||||||
{
|
{
|
||||||
return OreDictionary.itemMatches(this.getIngredient(), stack, false);
|
return ingredient.test(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getOutput(ItemStack input, ItemStack ingredient)
|
||||||
|
{
|
||||||
|
return isInput(input) && isIngredient(ingredient) ? getOutput().copy() : ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getInput()
|
||||||
|
{
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ingredient getIngredient()
|
||||||
|
{
|
||||||
|
return ingredient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getOutput()
|
||||||
|
{
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isIngredient(ItemStack ingredient)
|
||||||
|
{
|
||||||
|
return this.ingredient.test(ingredient);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,10 +23,9 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class BrewingRecipeRegistry {
|
public class BrewingRecipeRegistry {
|
||||||
|
|
||||||
private static List<IBrewingRecipe> recipes = new ArrayList<IBrewingRecipe>();
|
private static List<IBrewingRecipe> recipes = new ArrayList<IBrewingRecipe>();
|
||||||
|
@ -50,30 +49,11 @@ public class BrewingRecipeRegistry {
|
||||||
* done.
|
* done.
|
||||||
* @return true if the recipe was added.
|
* @return true if the recipe was added.
|
||||||
*/
|
*/
|
||||||
public static boolean addRecipe(@Nonnull ItemStack input, @Nonnull ItemStack ingredient, @Nonnull ItemStack output)
|
public static boolean addRecipe(ItemStack input, Ingredient ingredient, ItemStack output)
|
||||||
{
|
{
|
||||||
return addRecipe(new BrewingRecipe(input, ingredient, output));
|
return addRecipe(new BrewingRecipe(input, ingredient, output));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a recipe to the registry. Due to the nature of the brewing stand
|
|
||||||
* inputs that stack (a.k.a max stack size > 1) are not allowed.
|
|
||||||
*
|
|
||||||
* @param input
|
|
||||||
* The ItemStack that goes in same slots as the water bottles
|
|
||||||
* would.
|
|
||||||
* @param ingredient
|
|
||||||
* The ItemStack that goes in the same slot as nether wart would.
|
|
||||||
* @param output
|
|
||||||
* The ItemStack that will replace the input once the brewing is
|
|
||||||
* done.
|
|
||||||
* @return true if the recipe was added.
|
|
||||||
*/
|
|
||||||
public static boolean addRecipe(@Nonnull ItemStack input, @Nonnull String ingredient, @Nonnull ItemStack output)
|
|
||||||
{
|
|
||||||
return addRecipe(new BrewingOreRecipe(input, ingredient, output));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a recipe to the registry. Due to the nature of the brewing stand
|
* Adds a recipe to the registry. Due to the nature of the brewing stand
|
||||||
* inputs that stack (a.k.a max stack size > 1) are not allowed.
|
* inputs that stack (a.k.a max stack size > 1) are not allowed.
|
||||||
|
@ -87,8 +67,7 @@ public class BrewingRecipeRegistry {
|
||||||
* Returns the output ItemStack obtained by brewing the passed input and
|
* Returns the output ItemStack obtained by brewing the passed input and
|
||||||
* ingredient.
|
* ingredient.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static ItemStack getOutput(ItemStack input, ItemStack ingredient)
|
||||||
public static ItemStack getOutput(@Nonnull ItemStack input, @Nonnull ItemStack ingredient)
|
|
||||||
{
|
{
|
||||||
if (input.isEmpty() || input.getCount() != 1) return ItemStack.EMPTY;
|
if (input.isEmpty() || input.getCount() != 1) return ItemStack.EMPTY;
|
||||||
if (ingredient.isEmpty()) return ItemStack.EMPTY;
|
if (ingredient.isEmpty()) return ItemStack.EMPTY;
|
||||||
|
@ -107,7 +86,7 @@ public class BrewingRecipeRegistry {
|
||||||
/**
|
/**
|
||||||
* Returns true if the passed input and ingredient have an output
|
* Returns true if the passed input and ingredient have an output
|
||||||
*/
|
*/
|
||||||
public static boolean hasOutput(@Nonnull ItemStack input, @Nonnull ItemStack ingredient)
|
public static boolean hasOutput(ItemStack input, ItemStack ingredient)
|
||||||
{
|
{
|
||||||
return !getOutput(input, ingredient).isEmpty();
|
return !getOutput(input, ingredient).isEmpty();
|
||||||
}
|
}
|
||||||
|
@ -117,7 +96,7 @@ public class BrewingRecipeRegistry {
|
||||||
* Extra parameters exist to allow modders to create bigger brewing stands
|
* Extra parameters exist to allow modders to create bigger brewing stands
|
||||||
* without much hassle
|
* without much hassle
|
||||||
*/
|
*/
|
||||||
public static boolean canBrew(NonNullList<ItemStack> inputs, @Nonnull ItemStack ingredient, int[] inputIndexes)
|
public static boolean canBrew(NonNullList<ItemStack> inputs, ItemStack ingredient, int[] inputIndexes)
|
||||||
{
|
{
|
||||||
if (ingredient.isEmpty()) return false;
|
if (ingredient.isEmpty()) return false;
|
||||||
|
|
||||||
|
@ -136,7 +115,7 @@ public class BrewingRecipeRegistry {
|
||||||
* Used by the brewing stand to brew its inventory Extra parameters exist to
|
* Used by the brewing stand to brew its inventory Extra parameters exist to
|
||||||
* allow modders to create bigger brewing stands without much hassle
|
* allow modders to create bigger brewing stands without much hassle
|
||||||
*/
|
*/
|
||||||
public static void brewPotions(NonNullList<ItemStack> inputs, @Nonnull ItemStack ingredient, int[] inputIndexes)
|
public static void brewPotions(NonNullList<ItemStack> inputs, ItemStack ingredient, int[] inputIndexes)
|
||||||
{
|
{
|
||||||
for (int i : inputIndexes)
|
for (int i : inputIndexes)
|
||||||
{
|
{
|
||||||
|
@ -152,7 +131,7 @@ public class BrewingRecipeRegistry {
|
||||||
* Returns true if the passed ItemStack is a valid ingredient for any of the
|
* Returns true if the passed ItemStack is a valid ingredient for any of the
|
||||||
* recipes in the registry.
|
* recipes in the registry.
|
||||||
*/
|
*/
|
||||||
public static boolean isValidIngredient(@Nonnull ItemStack stack)
|
public static boolean isValidIngredient(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack.isEmpty()) return false;
|
if (stack.isEmpty()) return false;
|
||||||
|
|
||||||
|
@ -170,7 +149,7 @@ public class BrewingRecipeRegistry {
|
||||||
* Returns true if the passed ItemStack is a valid input for any of the
|
* Returns true if the passed ItemStack is a valid input for any of the
|
||||||
* recipes in the registry.
|
* recipes in the registry.
|
||||||
*/
|
*/
|
||||||
public static boolean isValidInput(@Nonnull ItemStack stack)
|
public static boolean isValidInput(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack.getCount() != 1) return false;
|
if (stack.getCount() != 1) return false;
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,6 @@ package net.minecraftforge.common.brewing;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public interface IBrewingRecipe {
|
public interface IBrewingRecipe {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,19 +28,18 @@ public interface IBrewingRecipe {
|
||||||
* being the item that goes in one of the three bottom slots of the brewing
|
* being the item that goes in one of the three bottom slots of the brewing
|
||||||
* stand (e.g: water bottle)
|
* stand (e.g: water bottle)
|
||||||
*/
|
*/
|
||||||
boolean isInput(@Nonnull ItemStack input);
|
boolean isInput(ItemStack input);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the passed ItemStack is an ingredient for this recipe.
|
* Returns true if the passed ItemStack is an ingredient for this recipe.
|
||||||
* "Ingredient" being the item that goes in the top slot of the brewing
|
* "Ingredient" being the item that goes in the top slot of the brewing
|
||||||
* stand (e.g: nether wart)
|
* stand (e.g: nether wart)
|
||||||
*/
|
*/
|
||||||
boolean isIngredient(@Nonnull ItemStack ingredient);
|
boolean isIngredient(ItemStack ingredient);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the output when the passed input is brewed with the passed
|
* Returns the output when the passed input is brewed with the passed
|
||||||
* ingredient. Empty if invalid input or ingredient.
|
* ingredient. Empty if invalid input or ingredient.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
ItemStack getOutput(ItemStack input, ItemStack ingredient);
|
||||||
ItemStack getOutput(@Nonnull ItemStack input, @Nonnull ItemStack ingredient);
|
|
||||||
}
|
}
|
|
@ -37,7 +37,7 @@ public class VanillaBrewingRecipe implements IBrewingRecipe {
|
||||||
* Code adapted from TileEntityBrewingStand.isItemValidForSlot(int index, ItemStack stack)
|
* Code adapted from TileEntityBrewingStand.isItemValidForSlot(int index, ItemStack stack)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isInput(@Nonnull ItemStack stack)
|
public boolean isInput(ItemStack stack)
|
||||||
{
|
{
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
return item == Items.POTIONITEM || item == Items.SPLASH_POTION || item == Items.LINGERING_POTION || item == Items.GLASS_BOTTLE;
|
return item == Items.POTIONITEM || item == Items.SPLASH_POTION || item == Items.LINGERING_POTION || item == Items.GLASS_BOTTLE;
|
||||||
|
@ -47,7 +47,7 @@ public class VanillaBrewingRecipe implements IBrewingRecipe {
|
||||||
* Code adapted from TileEntityBrewingStand.isItemValidForSlot(int index, ItemStack stack)
|
* Code adapted from TileEntityBrewingStand.isItemValidForSlot(int index, ItemStack stack)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isIngredient(@Nonnull ItemStack stack)
|
public boolean isIngredient(ItemStack stack)
|
||||||
{
|
{
|
||||||
return PotionBrewing.isReagent(stack);
|
return PotionBrewing.isReagent(stack);
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,7 @@ public class VanillaBrewingRecipe implements IBrewingRecipe {
|
||||||
* or if the new potion is a splash potion when the old one wasn't.
|
* or if the new potion is a splash potion when the old one wasn't.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
public ItemStack getOutput(ItemStack input, ItemStack ingredient)
|
||||||
public ItemStack getOutput(@Nonnull ItemStack input, @Nonnull ItemStack ingredient)
|
|
||||||
{
|
{
|
||||||
if (!input.isEmpty() && !ingredient.isEmpty() && isIngredient(ingredient))
|
if (!input.isEmpty() && !ingredient.isEmpty() && isIngredient(ingredient))
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
@MethodsReturnNonnullByDefault
|
||||||
|
package net.minecraftforge.common.brewing;
|
||||||
|
|
||||||
|
import mcp.MethodsReturnNonnullByDefault;
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
|
@ -1,52 +0,0 @@
|
||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2018.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.common.command;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.command.CommandException;
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler for custom types of selectors registered with {@link SelectorHandlerManager}
|
|
||||||
*/
|
|
||||||
public interface SelectorHandler
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Returns a {@link List} of {@link Entity Entities} of class {@code targetClass} ({@code T}) represented by {@code token}<br>
|
|
||||||
* <b>Note:</b> If {@code token} does not match the overall syntax defined by {@link #isSelector}, this method should return an empty list.
|
|
||||||
* For any other error, an exception should be thrown
|
|
||||||
*
|
|
||||||
* @param sender The {@link ICommandSender} that initiated the query
|
|
||||||
*/
|
|
||||||
<T extends Entity> List<T> matchEntities(ICommandSender sender, String token, Class<? extends T> targetClass) throws CommandException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the selector string potentially matches multiple entities
|
|
||||||
*/
|
|
||||||
boolean matchesMultiplePlayers(String selectorStr) throws CommandException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the string matches the overall syntax of the selector<br>
|
|
||||||
* <b>Note:</b> If this returns {@code false}, {@link #matchEntities} should return an empty list
|
|
||||||
*/
|
|
||||||
boolean isSelector(String selectorStr);
|
|
||||||
}
|
|
|
@ -1,141 +0,0 @@
|
||||||
/*
|
|
||||||
* Minecraft Forge
|
|
||||||
* Copyright (c) 2016-2018.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation version 2.1
|
|
||||||
* of the License.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraftforge.common.command;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.NavigableMap;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
|
|
||||||
import net.minecraft.command.CommandException;
|
|
||||||
import net.minecraft.command.EntitySelector;
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraftforge.fml.common.Loader;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows registration of custom selector types by assigning a {@link SelectorHandler} to a prefix
|
|
||||||
* This class handles calls to the {@link EntitySelector} methods {@link EntitySelector#matchEntities matchEntities},
|
|
||||||
* {@link EntitySelector#matchesMultiplePlayers matchesMultiplePlayers} and {@link EntitySelector#isSelector isSelector}.<br>
|
|
||||||
* The calls are delegated to the handler with the longest matching prefix.<br>
|
|
||||||
* <br>
|
|
||||||
* <b>Note:</b> If you register a {@link SelectorHandler} to a broader domain (not just a single selector), you should take care of possible shadowing conflicts yourself.
|
|
||||||
* For this you can use the information provided by {@link #selectorHandlers} and {@link #registeringMods}.
|
|
||||||
*/
|
|
||||||
public class SelectorHandlerManager
|
|
||||||
{
|
|
||||||
private SelectorHandlerManager()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//the ordering is reversed such that longer prefixes appear before their shorter substrings
|
|
||||||
public static final NavigableMap<String, SelectorHandler> selectorHandlers = new TreeMap<String, SelectorHandler>(Collections.<String> reverseOrder());
|
|
||||||
public static final NavigableMap<String, String> registeringMods = new TreeMap<String, String>(Collections.<String> reverseOrder());
|
|
||||||
|
|
||||||
private static final SelectorHandler vanillaHandler = new SelectorHandler()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public <T extends Entity> List<T> matchEntities(final ICommandSender sender, final String token, final Class<? extends T> targetClass) throws CommandException
|
|
||||||
{
|
|
||||||
return EntitySelector.matchEntitiesDefault(sender, token, targetClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matchesMultiplePlayers(final String selectorStr) throws CommandException
|
|
||||||
{
|
|
||||||
return EntitySelector.matchesMultiplePlayersDefault(selectorStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSelector(final String selectorStr)
|
|
||||||
{
|
|
||||||
return EntitySelector.isSelectorDefault(selectorStr);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
for (final String prefix : ArrayUtils.toArray("@p", "@a", "@r", "@e", "@s"))
|
|
||||||
{
|
|
||||||
selectorHandlers.put(prefix, vanillaHandler);
|
|
||||||
registeringMods.put(prefix, "minecraft");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a new {@link SelectorHandler} for {@code prefix}.<br>
|
|
||||||
*
|
|
||||||
* @param prefix The domain the specified {@code handler} is registered for.
|
|
||||||
* If you want to register just a single selector, {@code prefix} has the form '@{selectorName}'
|
|
||||||
*/
|
|
||||||
public static void register(final String prefix, final SelectorHandler handler)
|
|
||||||
{
|
|
||||||
if (prefix.isEmpty())
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Prefix must not be empty");
|
|
||||||
}
|
|
||||||
|
|
||||||
final String modId = Loader.instance().activeModContainer().getModId();
|
|
||||||
|
|
||||||
selectorHandlers.put(prefix, handler);
|
|
||||||
registeringMods.put(prefix, modId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the best matching handler for the given string. Defaults to the vanilla handler if no prefix applies
|
|
||||||
*/
|
|
||||||
public static SelectorHandler getHandler(final String selectorStr)
|
|
||||||
{
|
|
||||||
if (!selectorStr.isEmpty())
|
|
||||||
{
|
|
||||||
for (final Entry<String, SelectorHandler> handler : selectorHandlers.subMap(selectorStr, true, selectorStr.substring(0, 1), true).entrySet())
|
|
||||||
{
|
|
||||||
if (selectorStr.startsWith(handler.getKey()))
|
|
||||||
{
|
|
||||||
return handler.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vanillaHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
//These methods are called by the vanilla methods
|
|
||||||
|
|
||||||
public static <T extends Entity> List<T> matchEntities(final ICommandSender sender, final String token, final Class<? extends T> targetClass) throws CommandException
|
|
||||||
{
|
|
||||||
return getHandler(token).matchEntities(sender, token, targetClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean matchesMultiplePlayers(final String selectorStr) throws CommandException
|
|
||||||
{
|
|
||||||
return getHandler(selectorStr).matchesMultiplePlayers(selectorStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isSelector(final String selectorStr)
|
|
||||||
{
|
|
||||||
return getHandler(selectorStr).isSelector(selectorStr);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package net.minecraftforge.common.extensions;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extension added to ItemStack that bounces to ItemSack sensitive Item methods. Typically this is just for convince.
|
||||||
|
*/
|
||||||
|
public interface IForgeItemStack
|
||||||
|
{
|
||||||
|
// Helpers for accessing Item data
|
||||||
|
default ItemStack getStack()
|
||||||
|
{
|
||||||
|
return (ItemStack)this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ItemStack sensitive version of getContainerItem. Returns a full ItemStack
|
||||||
|
* instance of the result.
|
||||||
|
*
|
||||||
|
* @param itemStack The current ItemStack
|
||||||
|
* @return The resulting ItemStack
|
||||||
|
*/
|
||||||
|
default ItemStack getContainerItem()
|
||||||
|
{
|
||||||
|
return getStack().getItem().getContainerItem(getStack());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ItemStack sensitive version of hasContainerItem
|
||||||
|
*
|
||||||
|
* @param stack The current item stack
|
||||||
|
* @return True if this item has a 'container'
|
||||||
|
*/
|
||||||
|
default boolean hasContainerItem()
|
||||||
|
{
|
||||||
|
return getStack().getItem().hasContainerItem(getStack());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ package net.minecraftforge.items.wrapper;
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraftforge.common.capabilities.OptionalCapabilityInstance;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
|
@ -32,7 +33,17 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||||
protected final ISidedInventory inv;
|
protected final ISidedInventory inv;
|
||||||
protected final EnumFacing side;
|
protected final EnumFacing side;
|
||||||
|
|
||||||
public SidedInvWrapper(ISidedInventory inv, EnumFacing side)
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T extends OptionalCapabilityInstance<IItemHandlerModifiable>> T[] create(ISidedInventory inv, EnumFacing... sides) {
|
||||||
|
T[] ret = (T[])new Object[sides.length];
|
||||||
|
for (int x = 0; x < sides.length; x++) {
|
||||||
|
final EnumFacing side = sides[x];
|
||||||
|
ret[x] = (T)OptionalCapabilityInstance.of(() -> (IItemHandlerModifiable)new SidedInvWrapper(inv, side));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SidedInvWrapper(ISidedInventory inv, EnumFacing side)
|
||||||
{
|
{
|
||||||
this.inv = inv;
|
this.inv = inv;
|
||||||
this.side = side;
|
this.side = side;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package net.minecraftforge.oredict;
|
package net.minecraftforge.oredict;
|
||||||
|
|
||||||
|
/*
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -51,6 +52,7 @@ import net.minecraftforge.fml.common.FMLLog;
|
||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
*/
|
||||||
|
|
||||||
public class OreDictionary
|
public class OreDictionary
|
||||||
{
|
{
|
||||||
|
|
|
@ -353,3 +353,6 @@ public net.minecraft.client.Minecraft func_193986_ar()V # populateSearchTreeMana
|
||||||
# Advancements
|
# Advancements
|
||||||
public net.minecraft.advancements.AdvancementManager field_192783_b # GSON
|
public net.minecraft.advancements.AdvancementManager field_192783_b # GSON
|
||||||
public net.minecraft.advancements.CriteriaTriggers func_192118_a(Lnet/minecraft/advancements/ICriterionTrigger;)Lnet/minecraft/advancements/ICriterionTrigger; # register
|
public net.minecraft.advancements.CriteriaTriggers func_192118_a(Lnet/minecraft/advancements/ICriterionTrigger;)Lnet/minecraft/advancements/ICriterionTrigger; # register
|
||||||
|
|
||||||
|
# BiomeProvider
|
||||||
|
public net.minecraft.world.biome.provider.BiomeProvider field_201540_a # BIOMES_TO_SPAWN_IN
|
||||||
|
|
Loading…
Reference in a new issue