Initial 1.16.2 Update

This commit is contained in:
LexManos committed 2020-08-13 00:35:08 -07:00
1 parent a3c4ffd2c1
commit fe43088c96
233 files changed
+1644 -2297

No files matched your search

@@ -19,13 +19,11 @@
package net.minecraftforge.client.event;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.eventbus.api.Event;
/**
* Author: MachineMuse (Claire Semple)
* Created: 6:07 PM, 9/5/13
*/
public class FOVUpdateEvent extends Event
{
private final PlayerEntity entity;
@@ -36,7 +34,7 @@ public class FOVUpdateEvent extends Event
{
this.entity = entity;
this.fov = fov;
this.setNewfov(fov);
this.setNewfov(MathHelper.lerp(Minecraft.getInstance().gameSettings.field_243227_aN, 1.0F, fov));
}
public PlayerEntity getEntity()
@@ -1,49 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2020.
*
* 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.event;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.Cancelable;
/**
* This event is called before the pushOutOfBlocks calls in EntityPlayerSP.
*
* Cancelling the event will prevent pushOutOfBlocks from being called.
*/
@Cancelable
public class PlayerSPPushOutOfBlocksEvent extends PlayerEvent
{
private double minY;
public PlayerSPPushOutOfBlocksEvent(PlayerEntity player)
{
super(player);
this.minY = player.getPosY() + 0.5D;
}
public void setMinY(double value) {
this.minY = value;
}
public double getMinY() {
return this.minY;
}
}
@@ -283,7 +283,7 @@ public class ForgeIngameGui extends IngameGui
ItemStack itemstack = this.mc.player.inventory.armorItemInSlot(3);
if (this.mc.gameSettings.thirdPersonView == 0 && !itemstack.isEmpty())
if (this.mc.gameSettings.func_243230_g().func_243192_a() && !itemstack.isEmpty())
{
Item item = itemstack.getItem();
if (item == Blocks.CARVED_PUMPKIN.asItem())
@@ -684,7 +684,7 @@ public class ForgeIngameGui extends IngameGui
RenderSystem.defaultBlendFunc();
int color = (animateOverlayMessageColor ? MathHelper.hsvToRGB(hue / 50.0F, 0.7F, 0.6F) & WHITE : WHITE);
func_238448_a_(mStack, fontrenderer, -4, fontrenderer.func_238414_a_(overlayMessage), 16777215 | (opacity << 24));
fontrenderer.func_238422_b_(mStack, overlayMessage, -fontrenderer.func_238414_a_(overlayMessage) / 2, -4, color | (opacity << 24));
fontrenderer.func_238422_b_(mStack, overlayMessage.func_241878_f(), -fontrenderer.func_238414_a_(overlayMessage) / 2, -4, color | (opacity << 24));
RenderSystem.disableBlend();
RenderSystem.popMatrix();
}
@@ -719,13 +719,13 @@ public class ForgeIngameGui extends IngameGui
RenderSystem.pushMatrix();
RenderSystem.scalef(4.0F, 4.0F, 4.0F);
int l = opacity << 24 & -16777216;
this.getFontRenderer().func_238407_a_(mStack, this.displayedTitle, (float)(-this.getFontRenderer().func_238414_a_(this.displayedTitle) / 2), -10.0F, 16777215 | l);
this.getFontRenderer().func_238407_a_(mStack, this.displayedTitle.func_241878_f(), (float)(-this.getFontRenderer().func_238414_a_(this.displayedTitle) / 2), -10.0F, 16777215 | l);
RenderSystem.popMatrix();
if (this.displayedSubTitle != null)
{
RenderSystem.pushMatrix();
RenderSystem.scalef(2.0F, 2.0F, 2.0F);
this.getFontRenderer().func_238407_a_(mStack, this.displayedSubTitle, (float)(-this.getFontRenderer().func_238414_a_(this.displayedSubTitle) / 2), 5.0F, 16777215 | l);
this.getFontRenderer().func_238407_a_(mStack, this.displayedSubTitle.func_241878_f(), (float)(-this.getFontRenderer().func_238414_a_(this.displayedSubTitle) / 2), 5.0F, 16777215 | l);
RenderSystem.popMatrix();
}
RenderSystem.disableBlend();
@@ -16,7 +16,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Biomes are completely redone in 1.16.2, reevaluate
package net.minecraftforge.common;
import java.util.*;
@@ -48,25 +48,25 @@ public class BiomeDictionary
private static final Map<String, Type> byName = new HashMap<String, Type>();
private static Collection<Type> allTypes = Collections.unmodifiableCollection(byName.values());
/*Temperature-based tags. Specifying neither implies a biome is temperate*/
/*Temperature-based tags. Specifying neither implies a biome is temperate* /
public static final Type HOT = new Type("HOT");
public static final Type COLD = new Type("COLD");
/*Tags specifying the amount of vegetation a biome has. Specifying neither implies a biome to have moderate amounts*/
//Tags specifying the amount of vegetation a biome has. Specifying neither implies a biome to have moderate amounts* /
public static final Type SPARSE = new Type("SPARSE");
public static final Type DENSE = new Type("DENSE");
/*Tags specifying how moist a biome is. Specifying neither implies the biome as having moderate humidity*/
//Tags specifying how moist a biome is. Specifying neither implies the biome as having moderate humidity* /
public static final Type WET = new Type("WET");
public static final Type DRY = new Type("DRY");
/*Tree-based tags, SAVANNA refers to dry, desert-like trees (Such as Acacia), CONIFEROUS refers to snowy trees (Such as Spruce) and JUNGLE refers to jungle trees.
* Specifying no tag implies a biome has temperate trees (Such as Oak)*/
* Specifying no tag implies a biome has temperate trees (Such as Oak)* /
public static final Type SAVANNA = new Type("SAVANNA");
public static final Type CONIFEROUS = new Type("CONIFEROUS");
public static final Type JUNGLE = new Type("JUNGLE");
/*Tags specifying the nature of a biome*/
/*Tags specifying the nature of a biome* /
public static final Type SPOOKY = new Type("SPOOKY");
public static final Type DEAD = new Type("DEAD");
public static final Type LUSH = new Type("LUSH");
@@ -80,10 +80,10 @@ public class BiomeDictionary
public static final Type RIVER = new Type("RIVER");
/**
* A general tag for all water-based biomes. Shown as present if OCEAN or RIVER are.
**/
** /
public static final Type WATER = new Type("WATER", OCEAN, RIVER);
/*Generic types which a biome can be*/
/*Generic types which a biome can be* /
public static final Type MESA = new Type("MESA");
public static final Type FOREST = new Type("FOREST");
public static final Type PLAINS = new Type("PLAINS");
@@ -96,7 +96,7 @@ public class BiomeDictionary
public static final Type BEACH = new Type("BEACH");
public static final Type VOID = new Type("VOID");
/*Tags specifying the dimension a biome generates in. Specifying none implies a biome that generates in a modded dimension*/
/*Tags specifying the dimension a biome generates in. Specifying none implies a biome that generates in a modded dimension* /
public static final Type OVERWORLD = new Type("OVERWORLD");
public static final Type NETHER = new Type("NETHER");
public static final Type END = new Type("END");
@@ -116,7 +116,7 @@ public class BiomeDictionary
/**
* Gets the name for this type.
*/
* /
public String getName()
{
return name;
@@ -143,7 +143,7 @@ public class BiomeDictionary
*
* @param name The name of this Type
* @return An instance of Type for this name.
*/
* /
public static Type getType(String name, Type... subTypes)
{
name = name.toUpperCase();
@@ -157,7 +157,7 @@ public class BiomeDictionary
/**
* @return An unmodifiable collection of all current biome types.
*/
* /
public static Collection<Type> getAll()
{
return allTypes;
@@ -192,7 +192,7 @@ public class BiomeDictionary
/**
* Adds the given types to the biome.
*
*/
* /
public static void addTypes(Biome biome, Type... types)
{
Preconditions.checkArgument(ForgeRegistries.BIOMES.containsValue(biome), "Cannot add types to unregistered biome %s", biome);
@@ -213,7 +213,7 @@ public class BiomeDictionary
/**
* Gets the set of biomes that have the given type.
*
*/
* /
@Nonnull
public static Set<Biome> getBiomes(Type type)
{
@@ -223,7 +223,7 @@ public class BiomeDictionary
/**
* Gets the set of types that have been added to the given biome.
*
*/
* /
@Nonnull
public static Set<Type> getTypes(Biome biome)
{
@@ -235,7 +235,7 @@ public class BiomeDictionary
* Checks if the two given biomes have types in common.
*
* @return returns true if a common type is found, false otherwise
*/
* /
public static boolean areSimilar(Biome biomeA, Biome biomeB)
{
for (Type type : getTypes(biomeA))
@@ -252,7 +252,7 @@ public class BiomeDictionary
/**
* Checks if the given type has been added to the given biome.
*
*/
* /
public static boolean hasType(Biome biome, Type type)
{
return getTypes(biome).contains(type);
@@ -261,7 +261,7 @@ public class BiomeDictionary
/**
* Checks if any type has been added to the given biome.
*
*/
* /
public static boolean hasAnyType(Biome biome)
{
return !getBiomeInfo(biome).types.isEmpty();
@@ -272,7 +272,7 @@ public class BiomeDictionary
* If a biome's types are requested and no types have been added to the biome so far, the biome's types
* will be determined and added using this method.
*
*/
* /
public static void makeBestGuess(Biome biome)
{
Type type = Type.fromVanilla(biome.getCategory());
@@ -337,7 +337,7 @@ public class BiomeDictionary
/**
* Ensure that at least one type has been added to the given biome.
*/
* /
static void ensureHasTypes(Biome biome)
{
if (!hasAnyType(biome))
@@ -369,79 +369,79 @@ public class BiomeDictionary
private static void registerVanillaBiomes()
{
addTypes(Biomes.OCEAN, OCEAN, OVERWORLD);
addTypes(Biomes.PLAINS, PLAINS, OVERWORLD);
addTypes(Biomes.DESERT, HOT, DRY, SANDY, OVERWORLD);
addTypes(Biomes.MOUNTAINS, MOUNTAIN, HILLS, OVERWORLD);
addTypes(Biomes.FOREST, FOREST, OVERWORLD);
addTypes(Biomes.TAIGA, COLD, CONIFEROUS, FOREST, OVERWORLD);
addTypes(Biomes.SWAMP, WET, SWAMP, OVERWORLD);
addTypes(Biomes.RIVER, RIVER, OVERWORLD);
addTypes(Biomes.field_235254_j_, HOT, DRY, NETHER);
addTypes(Biomes.THE_END, COLD, DRY, END);
addTypes(Biomes.FROZEN_OCEAN, COLD, OCEAN, SNOWY, OVERWORLD);
addTypes(Biomes.FROZEN_RIVER, COLD, RIVER, SNOWY, OVERWORLD);
addTypes(Biomes.SNOWY_TUNDRA, COLD, SNOWY, WASTELAND, OVERWORLD);
addTypes(Biomes.SNOWY_MOUNTAINS, COLD, SNOWY, MOUNTAIN, OVERWORLD);
addTypes(Biomes.MUSHROOM_FIELDS, MUSHROOM, RARE, OVERWORLD);
addTypes(Biomes.MUSHROOM_FIELD_SHORE, MUSHROOM, BEACH, RARE, OVERWORLD);
addTypes(Biomes.BEACH, BEACH, OVERWORLD);
addTypes(Biomes.DESERT_HILLS, HOT, DRY, SANDY, HILLS, OVERWORLD);
addTypes(Biomes.WOODED_HILLS, FOREST, HILLS, OVERWORLD);
addTypes(Biomes.TAIGA_HILLS, COLD, CONIFEROUS, FOREST, HILLS, OVERWORLD);
addTypes(Biomes.MOUNTAIN_EDGE, MOUNTAIN, OVERWORLD);
addTypes(Biomes.JUNGLE, HOT, WET, DENSE, JUNGLE, OVERWORLD);
addTypes(Biomes.JUNGLE_HILLS, HOT, WET, DENSE, JUNGLE, HILLS, OVERWORLD);
addTypes(Biomes.JUNGLE_EDGE, HOT, WET, JUNGLE, FOREST, RARE, OVERWORLD);
addTypes(Biomes.DEEP_OCEAN, OCEAN, OVERWORLD);
addTypes(Biomes.STONE_SHORE, BEACH, OVERWORLD);
addTypes(Biomes.SNOWY_BEACH, COLD, BEACH, SNOWY, OVERWORLD);
addTypes(Biomes.BIRCH_FOREST, FOREST, OVERWORLD);
addTypes(Biomes.BIRCH_FOREST_HILLS, FOREST, HILLS, OVERWORLD);
addTypes(Biomes.DARK_FOREST, SPOOKY, DENSE, FOREST, OVERWORLD);
addTypes(Biomes.SNOWY_TAIGA, COLD, CONIFEROUS, FOREST, SNOWY, OVERWORLD);
addTypes(Biomes.SNOWY_TAIGA_HILLS, COLD, CONIFEROUS, FOREST, SNOWY, HILLS, OVERWORLD);
addTypes(Biomes.GIANT_TREE_TAIGA, COLD, CONIFEROUS, FOREST, OVERWORLD);
addTypes(Biomes.GIANT_TREE_TAIGA_HILLS, COLD, CONIFEROUS, FOREST, HILLS, OVERWORLD);
addTypes(Biomes.WOODED_MOUNTAINS, MOUNTAIN, FOREST, SPARSE, OVERWORLD);
addTypes(Biomes.SAVANNA, HOT, SAVANNA, PLAINS, SPARSE, OVERWORLD);
addTypes(Biomes.SAVANNA_PLATEAU, HOT, SAVANNA, PLAINS, SPARSE, RARE, OVERWORLD, PLATEAU);
addTypes(Biomes.BADLANDS, MESA, SANDY, DRY, OVERWORLD);
addTypes(Biomes.WOODED_BADLANDS_PLATEAU, MESA, SANDY, DRY, SPARSE, OVERWORLD, PLATEAU);
addTypes(Biomes.BADLANDS_PLATEAU, MESA, SANDY, DRY, OVERWORLD, PLATEAU);
addTypes(Biomes.SMALL_END_ISLANDS, END);
addTypes(Biomes.END_MIDLANDS, END);
addTypes(Biomes.END_HIGHLANDS, END);
addTypes(Biomes.END_BARRENS, END);
addTypes(Biomes.WARM_OCEAN, OCEAN, HOT, OVERWORLD);
addTypes(Biomes.LUKEWARM_OCEAN, OCEAN, OVERWORLD);
addTypes(Biomes.COLD_OCEAN, OCEAN, COLD, OVERWORLD);
addTypes(Biomes.DEEP_WARM_OCEAN, OCEAN, HOT, OVERWORLD);
addTypes(Biomes.DEEP_LUKEWARM_OCEAN, OCEAN, OVERWORLD);
addTypes(Biomes.DEEP_COLD_OCEAN, OCEAN, COLD, OVERWORLD);
addTypes(Biomes.DEEP_FROZEN_OCEAN, OCEAN, COLD, OVERWORLD);
addTypes(Biomes.THE_VOID, VOID);
addTypes(Biomes.SUNFLOWER_PLAINS, PLAINS, RARE, OVERWORLD);
addTypes(Biomes.DESERT_LAKES, HOT, DRY, SANDY, RARE, OVERWORLD);
addTypes(Biomes.GRAVELLY_MOUNTAINS, MOUNTAIN, SPARSE, RARE, OVERWORLD);
addTypes(Biomes.FLOWER_FOREST, FOREST, HILLS, RARE, OVERWORLD);
addTypes(Biomes.TAIGA_MOUNTAINS, COLD, CONIFEROUS, FOREST, MOUNTAIN, RARE, OVERWORLD);
addTypes(Biomes.SWAMP_HILLS, WET, SWAMP, HILLS, RARE, OVERWORLD);
addTypes(Biomes.ICE_SPIKES, COLD, SNOWY, HILLS, RARE, OVERWORLD);
addTypes(Biomes.MODIFIED_JUNGLE, HOT, WET, DENSE, JUNGLE, MOUNTAIN, RARE, OVERWORLD, MODIFIED);
addTypes(Biomes.MODIFIED_JUNGLE_EDGE, HOT, SPARSE, JUNGLE, HILLS, RARE, OVERWORLD, MODIFIED);
addTypes(Biomes.TALL_BIRCH_FOREST, FOREST, DENSE, HILLS, RARE, OVERWORLD);
addTypes(Biomes.TALL_BIRCH_HILLS, FOREST, DENSE, MOUNTAIN, RARE, OVERWORLD);
addTypes(Biomes.DARK_FOREST_HILLS, SPOOKY, DENSE, FOREST, MOUNTAIN, RARE, OVERWORLD);
addTypes(Biomes.SNOWY_TAIGA_MOUNTAINS, COLD, CONIFEROUS, FOREST, SNOWY, MOUNTAIN, RARE, OVERWORLD);
addTypes(Biomes.GIANT_SPRUCE_TAIGA, DENSE, FOREST, RARE, OVERWORLD);
addTypes(Biomes.GIANT_SPRUCE_TAIGA_HILLS, DENSE, FOREST, HILLS, RARE, OVERWORLD);
addTypes(Biomes.MODIFIED_GRAVELLY_MOUNTAINS, MOUNTAIN, SPARSE, RARE, OVERWORLD, MODIFIED);
addTypes(Biomes.SHATTERED_SAVANNA, HOT, DRY, SPARSE, SAVANNA, MOUNTAIN, RARE, OVERWORLD);
addTypes(Biomes.SHATTERED_SAVANNA_PLATEAU, HOT, DRY, SPARSE, SAVANNA, HILLS, RARE, OVERWORLD, PLATEAU);
addTypes(Biomes.ERODED_BADLANDS, HOT, DRY, SPARSE, MOUNTAIN, RARE, OVERWORLD);
addTypes(Biomes.MODIFIED_WOODED_BADLANDS_PLATEAU, HOT, DRY, SPARSE, HILLS, RARE, OVERWORLD, PLATEAU, MODIFIED);
addTypes(Biomes.MODIFIED_BADLANDS_PLATEAU, HOT, DRY, SPARSE, MOUNTAIN, RARE, OVERWORLD, PLATEAU, MODIFIED);
addTypes(Biomes.OCEAN, OCEAN, OVERWORLD);
addTypes(Biomes.PLAINS, PLAINS, OVERWORLD);
addTypes(Biomes.DESERT, HOT, DRY, SANDY, OVERWORLD);
addTypes(Biomes.MOUNTAINS, MOUNTAIN, HILLS, OVERWORLD);
addTypes(Biomes.FOREST, FOREST, OVERWORLD);
addTypes(Biomes.TAIGA, COLD, CONIFEROUS, FOREST, OVERWORLD);
addTypes(Biomes.SWAMP, WET, SWAMP, OVERWORLD);
addTypes(Biomes.RIVER, RIVER, OVERWORLD);
addTypes(Biomes.field_235254_j_, HOT, DRY, NETHER);
addTypes(Biomes.THE_END, COLD, DRY, END);
addTypes(Biomes.FROZEN_OCEAN, COLD, OCEAN, SNOWY, OVERWORLD);
addTypes(Biomes.FROZEN_RIVER, COLD, RIVER, SNOWY, OVERWORLD);
addTypes(Biomes.SNOWY_TUNDRA, COLD, SNOWY, WASTELAND, OVERWORLD);
addTypes(Biomes.SNOWY_MOUNTAINS, COLD, SNOWY, MOUNTAIN, OVERWORLD);
addTypes(Biomes.MUSHROOM_FIELDS, MUSHROOM, RARE, OVERWORLD);
addTypes(Biomes.MUSHROOM_FIELD_SHORE, MUSHROOM, BEACH, RARE, OVERWORLD);
addTypes(Biomes.BEACH, BEACH, OVERWORLD);
addTypes(Biomes.DESERT_HILLS, HOT, DRY, SANDY, HILLS, OVERWORLD);
addTypes(Biomes.WOODED_HILLS, FOREST, HILLS, OVERWORLD);
addTypes(Biomes.TAIGA_HILLS, COLD, CONIFEROUS, FOREST, HILLS, OVERWORLD);
addTypes(Biomes.MOUNTAIN_EDGE, MOUNTAIN, OVERWORLD);
addTypes(Biomes.JUNGLE, HOT, WET, DENSE, JUNGLE, OVERWORLD);
addTypes(Biomes.JUNGLE_HILLS, HOT, WET, DENSE, JUNGLE, HILLS, OVERWORLD);
addTypes(Biomes.JUNGLE_EDGE, HOT, WET, JUNGLE, FOREST, RARE, OVERWORLD);
addTypes(Biomes.DEEP_OCEAN, OCEAN, OVERWORLD);
addTypes(Biomes.STONE_SHORE, BEACH, OVERWORLD);
addTypes(Biomes.SNOWY_BEACH, COLD, BEACH, SNOWY, OVERWORLD);
addTypes(Biomes.BIRCH_FOREST, FOREST, OVERWORLD);
addTypes(Biomes.BIRCH_FOREST_HILLS, FOREST, HILLS, OVERWORLD);
addTypes(Biomes.DARK_FOREST, SPOOKY, DENSE, FOREST, OVERWORLD);
addTypes(Biomes.SNOWY_TAIGA, COLD, CONIFEROUS, FOREST, SNOWY, OVERWORLD);
addTypes(Biomes.SNOWY_TAIGA_HILLS, COLD, CONIFEROUS, FOREST, SNOWY, HILLS, OVERWORLD);
addTypes(Biomes.GIANT_TREE_TAIGA, COLD, CONIFEROUS, FOREST, OVERWORLD);
addTypes(Biomes.GIANT_TREE_TAIGA_HILLS, COLD, CONIFEROUS, FOREST, HILLS, OVERWORLD);
addTypes(Biomes.WOODED_MOUNTAINS, MOUNTAIN, FOREST, SPARSE, OVERWORLD);
addTypes(Biomes.SAVANNA, HOT, SAVANNA, PLAINS, SPARSE, OVERWORLD);
addTypes(Biomes.SAVANNA_PLATEAU, HOT, SAVANNA, PLAINS, SPARSE, RARE, OVERWORLD, PLATEAU);
addTypes(Biomes.BADLANDS, MESA, SANDY, DRY, OVERWORLD);
addTypes(Biomes.WOODED_BADLANDS_PLATEAU, MESA, SANDY, DRY, SPARSE, OVERWORLD, PLATEAU);
addTypes(Biomes.BADLANDS_PLATEAU, MESA, SANDY, DRY, OVERWORLD, PLATEAU);
addTypes(Biomes.SMALL_END_ISLANDS, END);
addTypes(Biomes.END_MIDLANDS, END);
addTypes(Biomes.END_HIGHLANDS, END);
addTypes(Biomes.END_BARRENS, END);
addTypes(Biomes.WARM_OCEAN, OCEAN, HOT, OVERWORLD);
addTypes(Biomes.LUKEWARM_OCEAN, OCEAN, OVERWORLD);
addTypes(Biomes.COLD_OCEAN, OCEAN, COLD, OVERWORLD);
addTypes(Biomes.DEEP_WARM_OCEAN, OCEAN, HOT, OVERWORLD);
addTypes(Biomes.DEEP_LUKEWARM_OCEAN, OCEAN, OVERWORLD);
addTypes(Biomes.DEEP_COLD_OCEAN, OCEAN, COLD, OVERWORLD);
addTypes(Biomes.DEEP_FROZEN_OCEAN, OCEAN, COLD, OVERWORLD);
addTypes(Biomes.THE_VOID, VOID);
addTypes(Biomes.SUNFLOWER_PLAINS, PLAINS, RARE, OVERWORLD);
addTypes(Biomes.DESERT_LAKES, HOT, DRY, SANDY, RARE, OVERWORLD);
addTypes(Biomes.GRAVELLY_MOUNTAINS, MOUNTAIN, SPARSE, RARE, OVERWORLD);
addTypes(Biomes.FLOWER_FOREST, FOREST, HILLS, RARE, OVERWORLD);
addTypes(Biomes.TAIGA_MOUNTAINS, COLD, CONIFEROUS, FOREST, MOUNTAIN, RARE, OVERWORLD);
addTypes(Biomes.SWAMP_HILLS, WET, SWAMP, HILLS, RARE, OVERWORLD);
addTypes(Biomes.ICE_SPIKES, COLD, SNOWY, HILLS, RARE, OVERWORLD);
addTypes(Biomes.MODIFIED_JUNGLE, HOT, WET, DENSE, JUNGLE, MOUNTAIN, RARE, OVERWORLD, MODIFIED);
addTypes(Biomes.MODIFIED_JUNGLE_EDGE, HOT, SPARSE, JUNGLE, HILLS, RARE, OVERWORLD, MODIFIED);
addTypes(Biomes.TALL_BIRCH_FOREST, FOREST, DENSE, HILLS, RARE, OVERWORLD);
addTypes(Biomes.TALL_BIRCH_HILLS, FOREST, DENSE, MOUNTAIN, RARE, OVERWORLD);
addTypes(Biomes.DARK_FOREST_HILLS, SPOOKY, DENSE, FOREST, MOUNTAIN, RARE, OVERWORLD);
addTypes(Biomes.SNOWY_TAIGA_MOUNTAINS, COLD, CONIFEROUS, FOREST, SNOWY, MOUNTAIN, RARE, OVERWORLD);
addTypes(Biomes.GIANT_SPRUCE_TAIGA, DENSE, FOREST, RARE, OVERWORLD);
addTypes(Biomes.GIANT_SPRUCE_TAIGA_HILLS, DENSE, FOREST, HILLS, RARE, OVERWORLD);
addTypes(Biomes.MODIFIED_GRAVELLY_MOUNTAINS, MOUNTAIN, SPARSE, RARE, OVERWORLD, MODIFIED);
addTypes(Biomes.SHATTERED_SAVANNA, HOT, DRY, SPARSE, SAVANNA, MOUNTAIN, RARE, OVERWORLD);
addTypes(Biomes.SHATTERED_SAVANNA_PLATEAU, HOT, DRY, SPARSE, SAVANNA, HILLS, RARE, OVERWORLD, PLATEAU);
addTypes(Biomes.ERODED_BADLANDS, HOT, DRY, SPARSE, MOUNTAIN, RARE, OVERWORLD);
addTypes(Biomes.MODIFIED_WOODED_BADLANDS_PLATEAU, HOT, DRY, SPARSE, HILLS, RARE, OVERWORLD, PLATEAU, MODIFIED);
addTypes(Biomes.MODIFIED_BADLANDS_PLATEAU, HOT, DRY, SPARSE, MOUNTAIN, RARE, OVERWORLD, PLATEAU, MODIFIED);
if (DEBUG)
{
@@ -452,3 +452,4 @@ public class BiomeDictionary
}
}
}
*/
@@ -16,7 +16,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Biomes are completely redone in 1.16.2, reevaluate
package net.minecraftforge.common;
import java.util.ArrayList;
@@ -241,3 +241,4 @@ public class BiomeManager
}
}
}
*/
@@ -46,8 +46,6 @@ public class ForgeConfig
public final IntValue dimensionUnloadQueueDelay;
public final IntValue clumpingThreshold;
public final BooleanValue treatEmptyTagsAsAir;
public final BooleanValue fixAdvancementLoading;
@@ -101,12 +99,6 @@ public class ForgeConfig
.translation("forge.configgui.dimensionUnloadQueueDelay")
.defineInRange("dimensionUnloadQueueDelay", 0, 0, Integer.MAX_VALUE);
clumpingThreshold = builder
.comment("Controls the number threshold at which Packet51 is preferred over Packet52, default and minimum 64, maximum 1024.")
.translation("forge.configgui.clumpingThreshold")
.worldRestart()
.defineInRange("clumpingThreshold", 64, 64, 1024);
treatEmptyTagsAsAir = builder
.comment("Vanilla will treat crafting recipes using empty tags as air, and allow you to craft with nothing in that slot. This changes empty tags to use BARRIER as the item. To prevent crafting with air.")
.translation("forge.configgui.treatEmptyTagsAsAir")
@@ -318,9 +318,9 @@ public class ForgeHooks
return !MinecraftForge.EVENT_BUS.post(new LivingAttackEvent(entity, src, amount));
}
public static LivingKnockBackEvent onLivingKnockBack(LivingEntity target, Entity attacker, float strength, double ratioX, double ratioZ)
public static LivingKnockBackEvent onLivingKnockBack(LivingEntity target, float strength, double ratioX, double ratioZ)
{
LivingKnockBackEvent event = new LivingKnockBackEvent(target, attacker, strength, ratioX, ratioZ);
LivingKnockBackEvent event = new LivingKnockBackEvent(target, strength, ratioX, ratioZ);
MinecraftForge.EVENT_BUS.post(event);
return event;
}
@@ -19,18 +19,12 @@
package net.minecraftforge.common;
import java.util.Arrays;
import java.util.stream.Collectors;
import net.minecraft.block.Block;
import net.minecraft.item.DyeColor;
import net.minecraft.item.Item;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ITag;
import net.minecraft.tags.ItemTags;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.registry.Registry;
import net.minecraftforge.common.util.ForgeNetworkTagManager;
import net.minecraftforge.registries.IForgeRegistryEntry;
public class Tags
{
@@ -52,10 +46,10 @@ public class Tags
public static final ITag.INamedTag<Block> DIRT = tag("dirt");
public static final ITag.INamedTag<Block> END_STONES = tag("end_stones");
public static final ITag.INamedTag<Block> FENCE_GATES = tag("fence_gates");
public static final ITag.INamedTag<Block> FENCE_GATES_WOODEN = defaulted("fence_gates/wooden", net.minecraft.block.Blocks.OAK_FENCE_GATE, net.minecraft.block.Blocks.BIRCH_FENCE_GATE, net.minecraft.block.Blocks.SPRUCE_FENCE_GATE, net.minecraft.block.Blocks.JUNGLE_FENCE_GATE, net.minecraft.block.Blocks.DARK_OAK_FENCE_GATE, net.minecraft.block.Blocks.ACACIA_FENCE_GATE);
public static final ITag.INamedTag<Block> FENCE_GATES_WOODEN = tag("fence_gates/wooden");
public static final ITag.INamedTag<Block> FENCES = tag("fences");
public static final ITag.INamedTag<Block> FENCES_NETHER_BRICK = tag("fences/nether_brick");
public static final ITag.INamedTag<Block> FENCES_WOODEN = defaulted("fences/wooden", net.minecraft.block.Blocks.OAK_FENCE, net.minecraft.block.Blocks.BIRCH_FENCE, net.minecraft.block.Blocks.SPRUCE_FENCE, net.minecraft.block.Blocks.JUNGLE_FENCE, net.minecraft.block.Blocks.DARK_OAK_FENCE, net.minecraft.block.Blocks.ACACIA_FENCE);
public static final ITag.INamedTag<Block> FENCES_WOODEN = tag("fences/wooden");
public static final ITag.INamedTag<Block> GLASS = tag("glass");
public static final ITag.INamedTag<Block> GLASS_BLACK = tag("glass/black");
@@ -130,12 +124,6 @@ public class Tags
{
return BlockTags.makeWrapperTag("forge:" + name);
}
@SuppressWarnings("deprecation")
private static ITag.INamedTag<Block> defaulted(String name, Block... values)
{
return ForgeNetworkTagManager.defaulted(Registry.field_239711_l_, tag(name), Arrays.asList(values).stream().map(e -> e.getRegistryName()).collect(Collectors.toSet()));
}
}
public static class Items
@@ -162,32 +150,32 @@ public class Tags
public static final ITag.INamedTag<Item> DUSTS_GLOWSTONE = tag("dusts/glowstone");
public static final ITag.INamedTag<Item> DYES = tag("dyes");
public static final ITag.INamedTag<Item> DYES_BLACK = tag("dyes/black");
public static final ITag.INamedTag<Item> DYES_RED = tag("dyes/red");
public static final ITag.INamedTag<Item> DYES_GREEN = tag("dyes/green");
public static final ITag.INamedTag<Item> DYES_BROWN = tag("dyes/brown");
public static final ITag.INamedTag<Item> DYES_BLUE = tag("dyes/blue");
public static final ITag.INamedTag<Item> DYES_PURPLE = tag("dyes/purple");
public static final ITag.INamedTag<Item> DYES_CYAN = tag("dyes/cyan");
public static final ITag.INamedTag<Item> DYES_LIGHT_GRAY = tag("dyes/light_gray");
public static final ITag.INamedTag<Item> DYES_GRAY = tag("dyes/gray");
public static final ITag.INamedTag<Item> DYES_PINK = tag("dyes/pink");
public static final ITag.INamedTag<Item> DYES_LIME = tag("dyes/lime");
public static final ITag.INamedTag<Item> DYES_YELLOW = tag("dyes/yellow");
public static final ITag.INamedTag<Item> DYES_LIGHT_BLUE = tag("dyes/light_blue");
public static final ITag.INamedTag<Item> DYES_MAGENTA = tag("dyes/magenta");
public static final ITag.INamedTag<Item> DYES_ORANGE = tag("dyes/orange");
public static final ITag.INamedTag<Item> DYES_WHITE = tag("dyes/white");
public static final ITag.INamedTag<Item> DYES_BLACK = DyeColor.BLACK.getTag();
public static final ITag.INamedTag<Item> DYES_RED = DyeColor.RED.getTag();
public static final ITag.INamedTag<Item> DYES_GREEN = DyeColor.GREEN.getTag();
public static final ITag.INamedTag<Item> DYES_BROWN = DyeColor.BROWN.getTag();
public static final ITag.INamedTag<Item> DYES_BLUE = DyeColor.BLUE.getTag();
public static final ITag.INamedTag<Item> DYES_PURPLE = DyeColor.PURPLE.getTag();
public static final ITag.INamedTag<Item> DYES_CYAN = DyeColor.CYAN.getTag();
public static final ITag.INamedTag<Item> DYES_LIGHT_GRAY = DyeColor.LIGHT_GRAY.getTag();
public static final ITag.INamedTag<Item> DYES_GRAY = DyeColor.GRAY.getTag();
public static final ITag.INamedTag<Item> DYES_PINK = DyeColor.PINK.getTag();
public static final ITag.INamedTag<Item> DYES_LIME = DyeColor.LIME.getTag();
public static final ITag.INamedTag<Item> DYES_YELLOW = DyeColor.YELLOW.getTag();
public static final ITag.INamedTag<Item> DYES_LIGHT_BLUE = DyeColor.LIGHT_BLUE.getTag();
public static final ITag.INamedTag<Item> DYES_MAGENTA = DyeColor.MAGENTA.getTag();
public static final ITag.INamedTag<Item> DYES_ORANGE = DyeColor.ORANGE.getTag();
public static final ITag.INamedTag<Item> DYES_WHITE = DyeColor.WHITE.getTag();
public static final ITag.INamedTag<Item> EGGS = tag("eggs");
public static final ITag.INamedTag<Item> END_STONES = tag("end_stones");
public static final ITag.INamedTag<Item> ENDER_PEARLS = tag("ender_pearls");
public static final ITag.INamedTag<Item> FEATHERS = tag("feathers");
public static final ITag.INamedTag<Item> FENCE_GATES = tag("fence_gates");
public static final ITag.INamedTag<Item> FENCE_GATES_WOODEN = defaulted("fence_gates/wooden", Blocks.FENCE_GATES_WOODEN);
public static final ITag.INamedTag<Item> FENCE_GATES_WOODEN = tag("fence_gates/wooden");
public static final ITag.INamedTag<Item> FENCES = tag("fences");
public static final ITag.INamedTag<Item> FENCES_NETHER_BRICK = tag("fences/nether_brick");
public static final ITag.INamedTag<Item> FENCES_WOODEN = defaulted("fences/wooden", Blocks.FENCES_WOODEN);
public static final ITag.INamedTag<Item> FENCES_WOODEN = tag("fences/wooden");
public static final ITag.INamedTag<Item> GEMS = tag("gems");
public static final ITag.INamedTag<Item> GEMS_DIAMOND = tag("gems/diamond");
public static final ITag.INamedTag<Item> GEMS_EMERALD = tag("gems/emerald");
@@ -293,11 +281,5 @@ public class Tags
{
return ItemTags.makeWrapperTag("forge:" + name);
}
@SuppressWarnings("deprecation")
private static ITag.INamedTag<Item> defaulted(String name, ITag.INamedTag<Block> parent)
{
return ForgeNetworkTagManager.defaulted(Registry.field_239714_o_, tag(name), RegistryKey.func_240903_a_(Registry.field_239711_l_, parent.func_230234_a_()));
}
}
}
@@ -23,8 +23,6 @@ import com.google.gson.JsonObject;
import net.minecraft.item.Item;
import net.minecraft.tags.ITag;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagCollectionManager;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
@@ -58,7 +56,7 @@ public class TagEmptyCondition implements ICondition
@Override
public boolean test()
{
ITag<Item> tag = TagCollectionManager.func_232928_e_().func_232925_b_().get(tag_name);
ITag<Item> tag = TagCollectionManager.func_242178_a().func_241836_b().get(tag_name);
return tag == null || tag.func_230236_b_().isEmpty();
}
@@ -119,6 +119,7 @@ public abstract class LanguageProvider implements IDataProvider {
add(key.getName(), name);
}
/*
public void addBiome(Supplier<? extends Biome> key, String name) {
add(key.get(), name);
}
@@ -126,6 +127,7 @@ public abstract class LanguageProvider implements IDataProvider {
public void add(Biome key, String name) {
add(key.getTranslationKey(), name);
}
*/
public void addEffect(Supplier<? extends Effect> key, String name) {
add(key.get(), name);
@@ -242,14 +242,15 @@ public interface IForgeBlock
* @param state The current state
* @param world The current world
* @param pos Block position in world
* @param orientation The direction the entity is facing while getting into bed.
* @param sleeper The sleeper or camera entity, null in some cases.
* @return The spawn position
*/
default Optional<Vector3d> getBedSpawnPosition(EntityType<?> entityType, BlockState state, IWorldReader world, BlockPos pos, @Nullable LivingEntity sleeper)
default Optional<Vector3d> getBedSpawnPosition(EntityType<?> entityType, BlockState state, IWorldReader world, BlockPos pos, float orientation, @Nullable LivingEntity sleeper)
{
if (world instanceof World)
{
return BedBlock.func_220172_a(entityType, world,pos,0);
return BedBlock.func_242652_a(entityType, world, pos, orientation);
}
return Optional.empty();
@@ -516,7 +517,7 @@ public interface IForgeBlock
* @param pos Block position in world
* @return True, to support being part of a nether portal frame, false otherwise.
*/
default boolean isPortalFrame(BlockState state, IWorldReader world, BlockPos pos)
default boolean isPortalFrame(BlockState state, IBlockReader world, BlockPos pos)
{
return state.isIn(Blocks.OBSIDIAN);
}
@@ -890,7 +891,7 @@ public interface IForgeBlock
{
return state.getBlock() instanceof BreakableBlock || state.getBlock() instanceof LeavesBlock;
}
/**
* Returns the state that this block should transform into when right clicked by a tool.
* For example: Used to determine if an axe can strip, a shovel can path, or a hoe can till.
@@ -195,12 +195,13 @@ public interface IForgeBlockState
*
* @param world The current world
* @param pos Block position in world
* @param orientation The direction the entity is facing while getting into bed.
* @param sleeper The sleeper or camera entity, null in some cases.
* @return The spawn position
*/
default Optional<Vector3d> getBedSpawnPosition(EntityType<?> type, IWorldReader world, BlockPos pos, @Nullable LivingEntity sleeper)
default Optional<Vector3d> getBedSpawnPosition(EntityType<?> type, IWorldReader world, BlockPos pos, float orientation, @Nullable LivingEntity sleeper)
{
return getBlockState().getBlock().getBedSpawnPosition(type, getBlockState(), world, pos, sleeper);
return getBlockState().getBlock().getBedSpawnPosition(type, getBlockState(), world, pos, orientation, sleeper);
}
/**
@@ -428,7 +429,7 @@ public interface IForgeBlockState
* @param pos Block position in world
* @return True, to support being part of a nether portal frame, false otherwise.
*/
default boolean isPortalFrame(IWorldReader world, BlockPos pos)
default boolean isPortalFrame(IBlockReader world, BlockPos pos)
{
return getBlockState().getBlock().isPortalFrame(getBlockState(), world, pos);
}
@@ -778,7 +779,7 @@ public interface IForgeBlockState
{
return getBlockState().getBlock().shouldDisplayFluidOverlay(getBlockState(), world, pos, fluidState);
}
/**
* Returns the state that this block should transform into when right clicked by a tool.
* For example: Used to determine if an axe can strip, a shovel can path, or a hoe can till.
@@ -56,28 +56,28 @@ public class BlockSnapshot
private WeakReference<IWorld> world;
private String toString = null;
private BlockSnapshot(IWorld world, BlockPos pos, BlockState state, @Nullable CompoundNBT nbt, int flags)
private BlockSnapshot(RegistryKey<World> dim, IWorld world, BlockPos pos, BlockState state, @Nullable CompoundNBT nbt, int flags)
{
this.dim = world.getWorld().func_234923_W_();
this.dim = dim;
this.pos = pos.toImmutable();
this.block = state;
this.flags = flags;
this.nbt = nbt;
this.world = new WeakReference<>(world);
this.world = new WeakReference<>(world);
if (DEBUG)
System.out.println("Created " + this.toString());
}
public static BlockSnapshot create(IWorld world, BlockPos pos)
public static BlockSnapshot create(RegistryKey<World> dim, IWorld world, BlockPos pos)
{
return create(world, pos, 3);
return create(dim, world, pos, 3);
}
public static BlockSnapshot create(IWorld world, BlockPos pos, int flag)
public static BlockSnapshot create(RegistryKey<World> dim, IWorld world, BlockPos pos, int flag)
{
return new BlockSnapshot(world, pos, world.getBlockState(pos), getTileNBT(world.getTileEntity(pos)), flag);
return new BlockSnapshot(dim, world, pos, world.getBlockState(pos), getTileNBT(world.getTileEntity(pos)), flag);
}
@Nullable
@@ -88,8 +88,8 @@ public class BlockSnapshot
public BlockState getCurrentBlock()
{
IWorld world = getWorld();
return world == null ? Blocks.AIR.getDefaultState() : world.getBlockState(this.pos);
IWorld world = getWorld();
return world == null ? Blocks.AIR.getDefaultState() : world.getBlockState(this.pos);
}
@Nullable
@@ -175,10 +175,10 @@ public class BlockSnapshot
final BlockSnapshot other = (BlockSnapshot) obj;
return this.dim.equals(other.dim) &&
this.pos.equals(other.pos) &&
this.block == other.block &&
this.flags == other.flags &&
Objects.equals(this.nbt, other.nbt);
this.pos.equals(other.pos) &&
this.block == other.block &&
this.flags == other.flags &&
Objects.equals(this.nbt, other.nbt);
}
@Override
@@ -196,18 +196,18 @@ public class BlockSnapshot
@Override
public String toString()
{
if (toString == null)
{
this.toString =
"BlockSnapshot[" +
"World:" + this.dim.func_240901_a_() + ',' +
"Pos: " + this.pos + ',' +
"State: " + this.block + ',' +
"Flags: " + this.flags + ',' +
"NBT: " + (this.nbt == null ? "null" : this.nbt.toString()) +
']';
}
return this.toString;
if (toString == null)
{
this.toString =
"BlockSnapshot[" +
"World:" + this.dim.func_240901_a_() + ',' +
"Pos: " + this.pos + ',' +
"State: " + this.block + ',' +
"Flags: " + this.flags + ',' +
"NBT: " + (this.nbt == null ? "null" : this.nbt.toString()) +
']';
}
return this.toString;
}
public BlockPos getPos() { return pos; }
@@ -1,128 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2020.
*
* 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.util;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableSet;
import net.minecraft.tags.ITag;
import net.minecraft.tags.NetworkTagCollection;
import net.minecraft.tags.NetworkTagManager;
import net.minecraft.tags.Tag;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
@Deprecated //For Forge's internal use only.
public class ForgeNetworkTagManager extends NetworkTagManager
{
private static Map<RegistryKey<?>, Set<ResourceLocation>> defaults = new HashMap<>();
/**
* Returns a new instance of this tag manager, again, only exposed for Forge's Hook use.
*/
public static NetworkTagManager create()
{
return new ForgeNetworkTagManager();
}
/**
* This will provide default tags if the server side does not send us one.
* Note: If they DO send us a empty one, this DOES NOT override that.
* This is 100% intended to be only used by Forge tto make sure our tags behave correctly on vanilla servers for the edge cases where we use tags for in-game loogic.
* Notably: Furnace burnables.
*/
public static <T> ITag.INamedTag<T> defaulted(RegistryKey<Registry<T>> type, ITag.INamedTag<T> tag, Set<ResourceLocation> values)
{
defaults.put(RegistryKey.func_240903_a_(type, tag.func_230234_a_()), ImmutableSet.copyOf(values));
return tag;
}
/**
* Copies the resource key from the parent tag to a new one.
* This simplifies the item variants of block tags.
* WILL explode if the parent hasn't been defaulted.
*/
public static <T> ITag.INamedTag<T> defaulted(RegistryKey<Registry<T>> type, ITag.INamedTag<T> tag, RegistryKey<?> parent)
{
RegistryKey<T> regKey = RegistryKey.func_240903_a_(type, tag.func_230234_a_());
Set<ResourceLocation> other = defaults.get(parent);
if (other == null)
throw new IllegalStateException("Attempted to set nested default without setting parent: " + regKey + " -> " + parent);
defaults.put(regKey, other);
return tag;
}
private ForgeNetworkTagManager()
{
this.blocks = new ForgeNetworkTagCollection<>(Registry.BLOCK, "tags/blocks", "block");
this.items = new ForgeNetworkTagCollection<>(Registry.ITEM, "tags/items", "item");
this.fluids = new ForgeNetworkTagCollection<>(Registry.FLUID, "tags/fluids", "fluid");
this.entityTypes = new ForgeNetworkTagCollection<>(Registry.ENTITY_TYPE, "tags/entity_types", "entity_type");
}
private static class ForgeNetworkTagCollection<T> extends NetworkTagCollection<T>
{
private final ITag<T> EMPTY = Tag.func_241284_a_();
private final Registry<T> registry;
private final Map<ResourceLocation, ITag<T>> cache = new HashMap<>();
public ForgeNetworkTagCollection(Registry<T> registry, String path, String name)
{
super(registry, path, name);
this.registry = registry;
}
@Override
@Nullable
public ITag<T> get(ResourceLocation key)
{
ITag<T> ret = super.get(key);
if (ret == null)
{
ret = cache.get(key);
if (ret == null) {
RegistryKey<T> regKey = RegistryKey.func_240903_a_(this.registry.getRegistryKey(), key);
Set<ResourceLocation> defaults = ForgeNetworkTagManager.defaults.get(regKey);
if (defaults == null)
{
ret = EMPTY;
}
else
{
Set<T> values = defaults.stream().map(getEntryLookup()).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toSet());
ret = Tag.func_241286_a_(values);
}
this.cache.put(key, ret);
}
}
return ret;
}
}
}
@@ -26,19 +26,19 @@ import java.util.Set;
import java.util.function.Supplier;
import net.minecraft.tags.ITag;
import net.minecraft.tags.TagCollection;
import net.minecraft.tags.ITagCollection;
import net.minecraft.util.ResourceLocation;
public class ReverseTagWrapper<T>
{
private final T target;
private final Supplier<TagCollection<T>> colSupplier;
private final Supplier<ITagCollection<T>> colSupplier;
//This map is immutable we track its identity change.
private Map<ResourceLocation, ITag<T>> colCache;
private Set<ResourceLocation> cache = null;
public ReverseTagWrapper(T target, Supplier<TagCollection<T>> colSupplier)
public ReverseTagWrapper(T target, Supplier<ITagCollection<T>> colSupplier)
{
this.target = target;
this.colSupplier = colSupplier;
@@ -46,11 +46,11 @@ public class ReverseTagWrapper<T>
public Set<ResourceLocation> getTagNames()
{
TagCollection<T> collection = colSupplier.get();
if (cache == null || colCache != collection.getTagMap()) // Identity equals.
ITagCollection<T> collection = colSupplier.get();
if (cache == null || colCache != collection.func_241833_a()) // Identity equals.
{
this.cache = Collections.unmodifiableSet(new HashSet<>(collection.getOwningTags(target)));
this.colCache = collection.getTagMap();
this.colCache = collection.func_241833_a();
}
return this.cache;
}
@@ -29,6 +29,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.block.NetherPortalBlock;
import net.minecraft.block.PortalSize;
import net.minecraft.block.BlockState;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.command.CommandSource;
@@ -79,6 +80,7 @@ import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.MobSpawnInfo;
import net.minecraft.world.storage.IServerWorldInfo;
import net.minecraft.world.storage.PlayerData;
import net.minecraftforge.api.distmarker.Dist;
@@ -232,7 +234,7 @@ public class ForgeEventFactory
}
@Nullable
public static List<Biome.SpawnListEntry> getPotentialSpawns(IWorld world, EntityClassification type, BlockPos pos, List<Biome.SpawnListEntry> oldList)
public static List<MobSpawnInfo.Spawners> getPotentialSpawns(IWorld world, EntityClassification type, BlockPos pos, List<MobSpawnInfo.Spawners> oldList)
{
WorldEvent.PotentialSpawns event = new WorldEvent.PotentialSpawns(world, type, pos, oldList);
if (MinecraftForge.EVENT_BUS.post(event))
@@ -363,7 +365,7 @@ public class ForgeEventFactory
}
return 0;
}
@Nullable
public static BlockState onToolUse(BlockState originalState, World world, BlockPos pos, PlayerEntity player, ItemStack stack, ToolType toolType)
{
@@ -670,9 +672,10 @@ public class ForgeEventFactory
return result == Result.DEFAULT ? def : result == Result.ALLOW;
}
public static boolean onTrySpawnPortal(IWorld world, BlockPos pos, NetherPortalBlock.Size size)
public static Optional<PortalSize> onTrySpawnPortal(IWorld world, BlockPos pos, Optional<PortalSize> size)
{
return MinecraftForge.EVENT_BUS.post(new BlockEvent.PortalSpawnEvent(world, pos, world.getBlockState(pos), size));
if (!size.isPresent()) return size;
return MinecraftForge.EVENT_BUS.post(new BlockEvent.PortalSpawnEvent(world, pos, world.getBlockState(pos), size.get())) ? size : Optional.empty();
}
public static int onEnchantmentLevelSet(World world, BlockPos pos, int enchantRow, int power, ItemStack itemStack, int level)
@@ -740,7 +743,7 @@ public class ForgeEventFactory
MinecraftForge.EVENT_BUS.post(event);
return event.getListeners();
}
public static void onCommandRegister(CommandDispatcher<CommandSource> dispatcher, Commands.EnvironmentType environment)
{
RegisterCommandsEvent event = new RegisterCommandsEvent(dispatcher, environment);
@@ -19,22 +19,21 @@
package net.minecraftforge.event;
import net.minecraft.tags.NetworkTagManager;
import net.minecraft.tags.ITagCollectionSupplier;
import net.minecraftforge.eventbus.api.Event;
/**
* Fired on the client when {@link NetworkTagManager} has all of its tags synced from the server to the client (just after a client has connected).
* Fired on the server when {@link NetworkTagManager} has read all tags from disk (during a data reload).
* Fired on the client when {@link ITagCollectionSupplier} has all of its tags synced from the server to the client (just after a client has connected).
* Fired on the server when {@link ITagCollectionSupplier} has read all tags from disk (during a data reload).
* This event is fired on the {@link MinecraftForge#EVENT_BUS}
* On the client, this event fires on the Client Thread.
* On the server, this event may be fired on the Server Thread, or an async reloader thread.
*/
public class TagsUpdatedEvent extends Event
{
private final NetworkTagManager manager;
public TagsUpdatedEvent(NetworkTagManager manager)
private final ITagCollectionSupplier manager;
public TagsUpdatedEvent(ITagCollectionSupplier manager)
{
this.manager = manager;
}
@@ -42,7 +41,7 @@ public class TagsUpdatedEvent extends Event
/**
* @return The network tag manager that has been updated with newly received tags.
*/
public NetworkTagManager getTagManager()
public ITagCollectionSupplier getTagManager()
{
return manager;
}
@@ -51,40 +51,31 @@ import net.minecraftforge.eventbus.api.Cancelable;
@Cancelable
public class LivingKnockBackEvent extends LivingEvent
{
protected Entity attacker;
protected float strength;
protected double ratioX, ratioZ;
protected final Entity originalAttacker;
protected final float originalStrength;
protected final double originalRatioX, originalRatioZ;
public LivingKnockBackEvent(LivingEntity target, Entity attacker, float strength, double ratioX, double ratioZ)
public LivingKnockBackEvent(LivingEntity target, float strength, double ratioX, double ratioZ)
{
super(target);
this.attacker = this.originalAttacker = attacker;
this.strength = this.originalStrength = strength;
this.ratioX = this.originalRatioX = ratioX;
this.ratioZ = this.originalRatioZ = ratioZ;
}
public Entity getAttacker() {return this.attacker;}
public float getStrength() {return this.strength;}
public double getRatioX() {return this.ratioX;}
public double getRatioZ() {return this.ratioZ;}
public Entity getOriginalAttacker() {return this.originalAttacker;}
public float getOriginalStrength() {return this.originalStrength;}
public double getOriginalRatioX() {return this.originalRatioX;}
public double getOriginalRatioZ() {return this.originalRatioZ;}
public void setAttacker(Entity attacker) {this.attacker = attacker;}
public void setStrength(float strength) {this.strength = strength;}
public void setRatioX(double ratioX) {this.ratioX = ratioX;}
@@ -23,6 +23,7 @@ import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.NetherPortalBlock;
import net.minecraft.block.PortalSize;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
@@ -432,24 +433,24 @@ public class BlockEvent extends Event
@Cancelable
public static class PortalSpawnEvent extends BlockEvent
{
private final NetherPortalBlock.Size size;
private final PortalSize size;
public PortalSpawnEvent(IWorld world, BlockPos pos, BlockState state, NetherPortalBlock.Size size)
public PortalSpawnEvent(IWorld world, BlockPos pos, BlockState state, PortalSize size)
{
super(world, pos, state);
this.size = size;
}
public NetherPortalBlock.Size getPortalSize()
public PortalSize getPortalSize()
{
return size;
}
}
/**
* Fired when when this block is right clicked by a tool to change its state.
* For example: Used to determine if an axe can strip, a shovel can path, or a hoe can till.
*
*
* This event is {@link Cancelable}. If canceled, this will prevent the tool
* from changing the block's state.
*/
@@ -481,7 +482,7 @@ public class BlockEvent extends Event
public ItemStack getHeldItemStack()
{
return stack;
}
}
/**Gets the current type of the tool being compared against.*/
public ToolType getToolType()
@@ -31,7 +31,7 @@ import net.minecraft.util.IProgressUpdate;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.biome.Biome.SpawnListEntry;
import net.minecraft.world.biome.MobSpawnInfo;
import net.minecraft.world.storage.IServerWorldInfo;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
@@ -128,17 +128,17 @@ public class WorldEvent extends Event
{
private final EntityClassification type;
private final BlockPos pos;
private final List<SpawnListEntry> list;
private final List<MobSpawnInfo.Spawners> list;
public PotentialSpawns(IWorld world, EntityClassification type, BlockPos pos, List<SpawnListEntry> oldList)
public PotentialSpawns(IWorld world, EntityClassification type, BlockPos pos, List<MobSpawnInfo.Spawners> oldList)
{
super(world);
this.pos = pos;
this.type = type;
if (oldList != null)
this.list = new ArrayList<SpawnListEntry>(oldList);
this.list = new ArrayList<>(oldList);
else
this.list = new ArrayList<SpawnListEntry>();
this.list = new ArrayList<>();
}
public EntityClassification getType()
@@ -151,7 +151,7 @@ public class WorldEvent extends Event
return pos;
}
public List<SpawnListEntry> getList()
public List<MobSpawnInfo.Spawners> getList()
{
return list;
}
@@ -91,7 +91,7 @@ public abstract class ForgeFlowingFluid extends FlowingFluid
protected void beforeReplacingBlock(IWorld worldIn, BlockPos pos, BlockState state)
{
TileEntity tileentity = state.getBlock().hasTileEntity(state) ? worldIn.getTileEntity(pos) : null;
Block.spawnDrops(state, worldIn.getWorld(), pos, tileentity);
Block.spawnDrops(state, worldIn, pos, tileentity);
}
@Override
@@ -41,7 +41,6 @@ import org.apache.logging.log4j.Logger;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.ClientResourcePackInfo;
import net.minecraft.client.resources.DownloadingPackFinder;
import net.minecraft.profiler.IProfiler;
import net.minecraft.resources.data.PackMetadataSection;
@@ -80,7 +79,7 @@ public class ClientModLoader
private static LoadingFailedException error;
private static EarlyLoaderGUI earlyLoaderGUI;
public static void begin(final Minecraft minecraft, final ResourcePackList<ClientResourcePackInfo> defaultResourcePacks, final IReloadableResourceManager mcResourceManager, DownloadingPackFinder metadataSerializer)
public static void begin(final Minecraft minecraft, final ResourcePackList defaultResourcePacks, final IReloadableResourceManager mcResourceManager, DownloadingPackFinder metadataSerializer)
{
// force log4j to shutdown logging in a shutdown hook. This is because we disable default shutdown hook so the server properly logs it's shutdown
Runtime.getRuntime().addShutdownHook(new Thread(LogManager::shutdown));
@@ -184,18 +183,18 @@ public class ClientModLoader
return loading;
}
private static <T extends ResourcePackInfo> ResourcePackLoader.IPackInfoFinder<T> buildPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ? super T> packSetter) {
private static ResourcePackLoader.IPackInfoFinder buildPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ResourcePackInfo> packSetter) {
return (packList, factory) -> clientPackFinder(modResourcePacks, packSetter, packList, factory);
}
private static <T extends ResourcePackInfo> void clientPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ? super T> packSetter, Consumer<T> consumer, ResourcePackInfo.IFactory<? extends T> factory) {
private static void clientPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ResourcePackInfo> packSetter, Consumer<ResourcePackInfo> consumer, ResourcePackInfo.IFactory factory) {
List<DelegatableResourcePack> hiddenPacks = new ArrayList<>();
for (Entry<ModFile, ? extends ModFileResourcePack> e : modResourcePacks.entrySet())
{
IModInfo mod = e.getKey().getModInfos().get(0);
if (Objects.equals(mod.getModId(), "minecraft")) continue; // skip the minecraft "mod"
final String name = "mod:" + mod.getModId();
final T packInfo = ResourcePackInfo.createResourcePack(name, false, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.field_232625_a_);
final ResourcePackInfo packInfo = ResourcePackInfo.createResourcePack(name, false, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.field_232625_a_);
if (packInfo == null) {
// Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong
ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey()));
@@ -209,7 +208,7 @@ public class ClientModLoader
hiddenPacks.add(e.getValue());
}
}
final T packInfo = ResourcePackInfo.createResourcePack("mod_resources", true, () -> new DelegatingResourcePack("mod_resources", "Mod Resources",
final ResourcePackInfo packInfo = ResourcePackInfo.createResourcePack("mod_resources", true, () -> new DelegatingResourcePack("mod_resources", "Mod Resources",
new PackMetadataSection(new TranslationTextComponent("fml.resources.modresources", hiddenPacks.size()), 5),
hiddenPacks), factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.field_232625_a_);
consumer.accept(packInfo);
@@ -27,6 +27,7 @@ import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IReorderingProcessor;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.vector.Matrix4f;
import net.minecraft.util.text.ITextProperties;
@@ -240,7 +241,8 @@ public class GuiUtils
cachedTooltipStack = ItemStack.EMPTY;
}
public static void drawHoveringText(MatrixStack mStack, List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
/*
public static void drawHoveringText(MatrixStack mStack, List<? extends IReorderingProcessor> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
{
drawHoveringText(mStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, DEFAULT_BACKGROUND_COLOR, DEFAULT_BORDER_COLOR_START, DEFAULT_BORDER_COLOR_END, font);
}
@@ -263,8 +265,8 @@ public class GuiUtils
* @param borderColorEnd The ending color of the box border. The border color will be smoothly interpolated
* between the start and end values.
* @param font the font for drawing the text in the tooltip box
*/
public static void drawHoveringText(MatrixStack mStack, List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
* /
public static void drawHoveringText(MatrixStack mStack, List<? extends IReorderingProcessor> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, FontRenderer font)
{
drawHoveringText(cachedTooltipStack, mStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, backgroundColor, borderColorStart, borderColorEnd, font);
@@ -279,9 +281,9 @@ public class GuiUtils
* Use this version if calling from somewhere where ItemStack context is available.
*
* @see #drawHoveringText(MatrixStack, List, int, int, int, int, int, int, int, int, FontRenderer)
*/
* /
//TODO, Validate rendering is the same as the original
public static void drawHoveringText(@Nonnull final ItemStack stack, MatrixStack mStack, List<? extends ITextProperties> textLines, int mouseX, int mouseY,
public static void drawHoveringText(@Nonnull final ItemStack stack, MatrixStack mStack, List<? extends IReorderingProcessor> textLines, int mouseX, int mouseY,
int screenWidth, int screenHeight, int maxTextWidth,
int backgroundColor, int borderColorStart, int borderColorEnd, FontRenderer font)
{
@@ -301,7 +303,7 @@ public class GuiUtils
RenderSystem.disableDepthTest();
int tooltipTextWidth = 0;
for (ITextProperties textLine : textLines)
for (IReorderingProcessor textLine : textLines)
{
int textLineWidth = font.func_238414_a_(textLine);
if (textLineWidth > tooltipTextWidth)
@@ -422,6 +424,7 @@ public class GuiUtils
RenderSystem.enableRescaleNormal();
}
}
*/
public static void drawGradientRect(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor)
{
@@ -25,6 +25,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.screen.ErrorScreen;
import net.minecraft.client.gui.widget.list.ExtendedList;
import net.minecraft.util.IReorderingProcessor;
import net.minecraft.util.Util;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.ITextProperties;
@@ -100,8 +101,8 @@ public class LoadingErrorScreen extends ErrorScreen {
}
private void drawMultiLineCenteredString(MatrixStack mStack, FontRenderer fr, ITextComponent str, int x, int y) {
for (ITextProperties s : fr.func_238425_b_(str, this.field_230708_k_)) {
fr.func_238407_a_(mStack, s, (float) (x - fr.func_238414_a_(s) / 2.0), y, 0xFFFFFF);
for (IReorderingProcessor s : fr.func_238425_b_(str, this.field_230708_k_)) {
fr.func_238407_a_(mStack, s, (float) (x - fr.func_243245_a(s) / 2.0), y, 0xFFFFFF);
y+=fr.FONT_HEIGHT;
}
}
@@ -148,11 +149,11 @@ public class LoadingErrorScreen extends ErrorScreen {
@Override
public void func_230432_a_(MatrixStack mStack, int entryIdx, int top, int left, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean p_194999_5_, final float partialTicks) {
FontRenderer font = Minecraft.getInstance().fontRenderer;
final List<ITextProperties> strings = font.func_238425_b_(message, LoadingEntryList.this.field_230670_d_);
final List<IReorderingProcessor> strings = font.func_238425_b_(message, LoadingEntryList.this.field_230670_d_);
int y = top + 2;
for (int i = 0; i < Math.min(strings.size(), 2); i++) {
if (center)
font.func_238422_b_(mStack, strings.get(i), left + (field_230670_d_) - font.func_238414_a_(strings.get(i)) / 2F, y, 0xFFFFFF);
font.func_238422_b_(mStack, strings.get(i), left + (field_230670_d_) - font.func_243245_a(strings.get(i)) / 2F, y, 0xFFFFFF);
else
font.func_238422_b_(mStack, strings.get(i), left + 5, y, 0xFFFFFF);
y += font.FONT_HEIGHT;
@@ -51,6 +51,7 @@ import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.IReorderingProcessor;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraftforge.client.gui.ScrollPanel;
@@ -130,7 +131,7 @@ public class ModListScreen extends Screen
class InfoPanel extends ScrollPanel {
private ResourceLocation logoPath;
private Size2i logoDims = new Size2i(0, 0);
private List<ITextProperties> lines = Collections.emptyList();
private List<IReorderingProcessor> lines = Collections.emptyList();
InfoPanel(Minecraft mcIn, int widthIn, int heightIn, int topIn)
{
@@ -151,9 +152,9 @@ public class ModListScreen extends Screen
this.lines = Collections.emptyList();
}
private List<ITextProperties> resizeContent(List<String> lines)
private List<IReorderingProcessor> resizeContent(List<String> lines)
{
List<ITextProperties> ret = new ArrayList<>();
List<IReorderingProcessor> ret = new ArrayList<>();
for (String line : lines)
{
if (line == null)
@@ -166,7 +167,7 @@ public class ModListScreen extends Screen
int maxTextLength = this.width - 12;
if (maxTextLength >= 0)
{
ret.addAll(field_230712_o_.func_238420_b_().func_238362_b_(chat, maxTextLength, Style.field_240709_b_));
ret.addAll(LanguageMap.getInstance().func_244260_a(field_230712_o_.func_238420_b_().func_238362_b_(chat, maxTextLength, Style.field_240709_b_)));
}
}
return ret;
@@ -201,7 +202,7 @@ public class ModListScreen extends Screen
relativeY += headerHeight + PADDING;
}
for (ITextProperties line : lines)
for (IReorderingProcessor line : lines)
{
if (line != null)
{
@@ -231,10 +232,10 @@ public class ModListScreen extends Screen
if (lineIdx >= lines.size() || lineIdx < 1)
return null;
ITextProperties line = lines.get(lineIdx-1);
IReorderingProcessor line = lines.get(lineIdx-1);
if (line != null)
{
return field_230712_o_.func_238420_b_().func_238357_a_(line, mouseX);
return field_230712_o_.func_238420_b_().func_243239_a(line, mouseX);
}
return null;
}
@@ -375,7 +376,7 @@ public class ModListScreen extends Screen
ITextComponent text = new TranslationTextComponent("fml.menu.mods.search");
int x = modList.getLeft() + ((modList.getRight() - modList.getLeft()) / 2) - (getFontRenderer().func_238414_a_(text) / 2);
getFontRenderer().func_238422_b_(mStack, text, x, search.field_230691_m_ - getFontRenderer().FONT_HEIGHT, 0xFFFFFF);
getFontRenderer().func_238422_b_(mStack, text.func_241878_f(), x, search.field_230691_m_ - getFontRenderer().FONT_HEIGHT, 0xFFFFFF);
this.search.func_230430_a_(mStack, mouseX , mouseY, partialTicks);
super.func_230430_a_(mStack, mouseX, mouseY, partialTicks);
}
@@ -66,7 +66,7 @@ public class ExtendedButton extends Button
//TODO, srg names make it hard to figure out how to append to an ITextProperties from this trim operation, wraping this in StringTextComponent is kinda dirty.
buttonText = new StringTextComponent(mc.fontRenderer.func_238417_a_(buttonText, field_230688_j_ - 6 - ellipsisWidth).getString() + "...");
this.func_238472_a_(mStack, mc.fontRenderer, buttonText, this.field_230690_l_ + this.field_230688_j_ / 2, this.field_230691_m_ + (this.field_230689_k_ - 8) / 2, getFGColor());
func_238472_a_(mStack, mc.fontRenderer, buttonText, this.field_230690_l_ + this.field_230688_j_ / 2, this.field_230691_m_ + (this.field_230689_k_ - 8) / 2, getFGColor());
}
}
}
@@ -26,6 +26,8 @@ import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.widget.list.ExtendedList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.ITextProperties;
import net.minecraft.util.text.LanguageMap;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.client.gui.screen.ModListScreen;
import net.minecraftforge.versions.forge.ForgeVersion;
@@ -90,8 +92,8 @@ public class ModListWidget extends ExtendedList<ModListWidget.ModEntry>
ITextComponent version = new StringTextComponent(stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion())));
VersionChecker.CheckResult vercheck = VersionChecker.getResult(modInfo);
FontRenderer font = this.parent.getFontRenderer();
font.func_238422_b_(mStack, font.func_238417_a_(name, listWidth),left + 3, top + 2, 0xFFFFFF);
font.func_238422_b_(mStack, font.func_238417_a_(version, listWidth), left + 3 , top + 2 + font.FONT_HEIGHT, 0xCCCCCC);
font.func_238422_b_(mStack, LanguageMap.getInstance().func_241870_a(ITextProperties.func_240655_a_(font.func_238417_a_(name, listWidth))), left + 3, top + 2, 0xFFFFFF);
font.func_238422_b_(mStack, LanguageMap.getInstance().func_241870_a(ITextProperties.func_240655_a_(font.func_238417_a_(version, listWidth))), left + 3, top + 2 + font.FONT_HEIGHT, 0xCCCCCC);
if (vercheck.status.shouldDraw())
{
//TODO: Consider adding more icons for visualization
@@ -36,6 +36,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.minecraft.resources.IPackFinder;
import net.minecraft.resources.ResourcePackInfo;
import net.minecraft.resources.ResourcePackInfo.IFactory;
import net.minecraft.resources.ResourcePackList;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
@@ -44,7 +45,7 @@ import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
public class ResourcePackLoader
{
private static Map<ModFile, ModFileResourcePack> modResourcePacks;
private static ResourcePackList<?> resourcePackList;
private static ResourcePackList resourcePackList;
public static Optional<ModFileResourcePack> getResourcePackFor(String modId)
{
@@ -52,7 +53,7 @@ public class ResourcePackLoader
map(ModFileInfo::getFile).map(mf->modResourcePacks.get(mf));
}
public static <T extends ResourcePackInfo> void loadResourcePacks(ResourcePackList<T> resourcePacks, BiFunction<Map<ModFile, ? extends ModFileResourcePack>, BiConsumer<? super ModFileResourcePack, T>, IPackInfoFinder> packFinder) {
public static void loadResourcePacks(ResourcePackList resourcePacks, BiFunction<Map<ModFile, ? extends ModFileResourcePack>, BiConsumer<? super ModFileResourcePack, ResourcePackInfo>, IPackInfoFinder> packFinder) {
resourcePackList = resourcePacks;
modResourcePacks = ModList.get().getModFiles().stream().
filter(mf->!Objects.equals(mf.getModLoader(),"minecraft")).
@@ -96,8 +97,8 @@ public class ResourcePackLoader
};
}
public interface IPackInfoFinder<T extends ResourcePackInfo> {
void addPackInfos(Consumer<T> consumer, ResourcePackInfo.IFactory<T> factory);
public interface IPackInfoFinder {
void addPackInfos(Consumer<ResourcePackInfo> consumer, IFactory factory);
}
// SO GROSS - DON'T @ me bro
@@ -110,7 +111,7 @@ public class ResourcePackLoader
}
@Override
public <T extends ResourcePackInfo> void func_230230_a_(Consumer<T> consumer, ResourcePackInfo.IFactory<T> factory)
public void func_230230_a_(Consumer<ResourcePackInfo> consumer, IFactory factory)
{
wrapped.addPackInfos(consumer, factory);
}
@@ -214,17 +214,17 @@ public class ServerLifecycleHooks
//INTERNAL MODDERS DO NOT USE
@Deprecated
public static <T extends ResourcePackInfo> ResourcePackLoader.IPackInfoFinder<T> buildPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ? super T> packSetter) {
public static ResourcePackLoader.IPackInfoFinder buildPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ResourcePackInfo> packSetter) {
return (packList, factory) -> serverPackFinder(modResourcePacks, packSetter, packList, factory);
}
private static <T extends ResourcePackInfo> void serverPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ? super T> packSetter, Consumer<T> consumer, ResourcePackInfo.IFactory<? extends T> factory) {
private static void serverPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ResourcePackInfo> packSetter, Consumer<ResourcePackInfo> consumer, ResourcePackInfo.IFactory factory) {
for (Entry<ModFile, ? extends ModFileResourcePack> e : modResourcePacks.entrySet())
{
IModInfo mod = e.getKey().getModInfos().get(0);
if (Objects.equals(mod.getModId(), "minecraft")) continue; // skip the minecraft "mod"
final String name = "mod:" + mod.getModId();
final T packInfo = ResourcePackInfo.createResourcePack(name, true, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.field_232625_a_);
final ResourcePackInfo packInfo = ResourcePackInfo.createResourcePack(name, true, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.field_232625_a_);
if (packInfo == null) {
// Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong
ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey()));
@@ -32,6 +32,7 @@ import net.minecraft.entity.merchant.villager.VillagerProfession;
import net.minecraft.fluid.Fluid;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.util.registry.Bootstrap;
import net.minecraft.util.registry.Registry;
import net.minecraft.village.PointOfInterestType;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipeSerializer;
@@ -40,6 +41,8 @@ import net.minecraft.potion.Effect;
import net.minecraft.potion.Potion;
import net.minecraft.stats.StatType;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.ChunkStatus;
@@ -70,7 +73,6 @@ public class ForgeRegistries
public static final IForgeRegistry<Fluid> FLUIDS = RegistryManager.ACTIVE.getRegistry(Fluid.class);
public static final IForgeRegistry<Item> ITEMS = RegistryManager.ACTIVE.getRegistry(Item.class);
public static final IForgeRegistry<Effect> POTIONS = RegistryManager.ACTIVE.getRegistry(Effect.class);
public static final IForgeRegistry<Biome> BIOMES = RegistryManager.ACTIVE.getRegistry(Biome.class);
public static final IForgeRegistry<SoundEvent> SOUND_EVENTS = RegistryManager.ACTIVE.getRegistry(SoundEvent.class);
public static final IForgeRegistry<Potion> POTION_TYPES = RegistryManager.ACTIVE.getRegistry(Potion.class);
public static final IForgeRegistry<Enchantment> ENCHANTMENTS = RegistryManager.ACTIVE.getRegistry(Enchantment.class);
@@ -96,7 +98,6 @@ public class ForgeRegistries
public static final IForgeRegistry<SurfaceBuilder<?>> SURFACE_BUILDERS = RegistryManager.ACTIVE.getRegistry(SurfaceBuilder.class);
public static final IForgeRegistry<Feature<?>> FEATURES = RegistryManager.ACTIVE.getRegistry(Feature.class);
public static final IForgeRegistry<Placement<?>> DECORATORS = RegistryManager.ACTIVE.getRegistry(Placement.class);
// public static final IForgeRegistry<ChunkGeneratorType<?, ?>> CHUNK_GENERATOR_TYPES = RegistryManager.ACTIVE.getRegistry(ChunkGeneratorType.class);
public static final IForgeRegistry<ChunkStatus> CHUNK_STATUS = RegistryManager.ACTIVE.getRegistry(ChunkStatus.class);
public static final IForgeRegistry<Structure<?>> STRUCTURE_FEATURES = RegistryManager.ACTIVE.getRegistry(Structure.class);
public static final IForgeRegistry<BlockStateProviderType<?>> BLOCK_STATE_PROVIDER_TYPES = RegistryManager.ACTIVE.getRegistry(BlockStateProviderType.class);
@@ -108,11 +109,57 @@ public class ForgeRegistries
public static final IForgeRegistry<DataSerializerEntry> DATA_SERIALIZERS = RegistryManager.ACTIVE.getRegistry(DataSerializerEntry.class);
public static final IForgeRegistry<GlobalLootModifierSerializer<?>> LOOT_MODIFIER_SERIALIZERS = RegistryManager.ACTIVE.getRegistry(GlobalLootModifierSerializer.class);
public static final class Keys {
//Vanilla
public static final RegistryKey<Registry<Block>> BLOCKS = key("block");
public static final RegistryKey<Registry<Fluid>> FLUIDS = key("fluid");
public static final RegistryKey<Registry<Item>> ITEMS = key("item");
public static final RegistryKey<Registry<Effect>> EFFECTS = key("mob_effect");
public static final RegistryKey<Registry<Potion>> POTIONS = key("potion");
public static final RegistryKey<Registry<Attribute>> ATTRIBUTES = key("attribute");
public static final RegistryKey<Registry<StatType<?>>> STAT_TYPES = key("stat_type");
public static final RegistryKey<Registry<SoundEvent>> SOUND_EVENTS = key("sound_event");
public static final RegistryKey<Registry<Enchantment>> ENCHANTMENTS = key("enchantment");
public static final RegistryKey<Registry<EntityType<?>>> ENTITY_TYPES = key("entity_type");
public static final RegistryKey<Registry<PaintingType>> PAINTING_TYPES = key("motive");
public static final RegistryKey<Registry<ParticleType<?>>> PARTICLE_TYPES = key("particle_type");
public static final RegistryKey<Registry<ContainerType<?>>> CONTAINER_TYPES = key("menu");
public static final RegistryKey<Registry<TileEntityType<?>>> TILE_ENTITY_TYPES = key("block_entity_type");
public static final RegistryKey<Registry<IRecipeSerializer<?>>> RECIPE_SERIALIZERS = key("recipe_serializer");
public static final RegistryKey<Registry<VillagerProfession>> VILLAGER_PROFESSIONS = key("villager_profession");
public static final RegistryKey<Registry<PointOfInterestType>> POI_TYPES = key("point_of_interest_type");
public static final RegistryKey<Registry<MemoryModuleType<?>>> MEMORY_MODULE_TYPES = key("memory_module_type");
public static final RegistryKey<Registry<SensorType<?>>> SENSOR_TYPES = key("sensor_type");
public static final RegistryKey<Registry<Schedule>> SCHEDULES = key("schedule");
public static final RegistryKey<Registry<Activity>> ACTIVITIES = key("activity");
public static final RegistryKey<Registry<WorldCarver<?>>> WORLD_CARVERS = key("worldgen/carver");
public static final RegistryKey<Registry<SurfaceBuilder<?>>> SURFACE_BUILDERS = key("worldgen/surface_builder");
public static final RegistryKey<Registry<Feature<?>>> FEATURES = key("worldgen/feature");
public static final RegistryKey<Registry<Placement<?>>> DECORATORS = key("worldgen/decorator");
public static final RegistryKey<Registry<ChunkStatus>> CHUNK_STATUS = key("chunk_status");
public static final RegistryKey<Registry<Structure<?>>> STRUCTURE_FEATURES = key("worldgen/structure_feature");
public static final RegistryKey<Registry<BlockStateProviderType<?>>> BLOCK_STATE_PROVIDER_TYPES = key("worldgen/block_state_provider_type");
public static final RegistryKey<Registry<BlockPlacerType<?>>> BLOCK_PLACER_TYPES = key("worldgen/block_placer_type");
public static final RegistryKey<Registry<FoliagePlacerType<?>>> FOLIAGE_PLACER_TYPES = key("worldgen/foliage_placer_type");
public static final RegistryKey<Registry<TreeDecoratorType<?>>> TREE_DECORATOR_TYPES = key("worldgen/tree_decorator_type");
//Forge
public static final RegistryKey<Registry<DataSerializerEntry>> DATA_SERIALIZERS = key("data_serializers");
public static final RegistryKey<Registry<GlobalLootModifierSerializer<?>>> LOOT_MODIFIER_SERIALIZERS = key("forge:loot_modifier_serializers");
private static <T> RegistryKey<Registry<T>> key(String name)
{
return RegistryKey.func_240904_a_(new ResourceLocation(name));
}
private static void init() {}
}
/**
* This function is just to make sure static inializers in other classes have run and setup their registries before we query them.
*/
private static void init()
{
Keys.init();
GameData.init();
Bootstrap.register();
Tags.init();
@@ -20,6 +20,7 @@
package net.minecraftforge.registries;
import com.google.common.collect.*;
import com.mojang.serialization.Lifecycle;
import net.minecraft.block.AirBlock;
import net.minecraft.block.Block;
@@ -48,13 +49,13 @@ import net.minecraft.state.StateContainer;
import net.minecraft.stats.StatType;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ObjectIntIdentityMap;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.registry.DefaultedRegistry;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.SimpleRegistry;
import net.minecraft.village.PointOfInterestType;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.gen.DebugChunkGenerator;
import net.minecraft.world.gen.blockplacer.BlockPlacerType;
@@ -97,6 +98,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES;
import static net.minecraftforge.registries.ForgeRegistries.Keys.*;
/**
* INTERNAL ONLY
@@ -105,53 +107,6 @@ import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES;
public class GameData
{
private static final Logger LOGGER = LogManager.getLogger();
// Vanilla registries
// Names used here match those in net.minecraft.util.Registry
// Game objects
private static final ResourceLocation BLOCKS = new ResourceLocation("block");
private static final ResourceLocation FLUIDS = new ResourceLocation("fluid");
private static final ResourceLocation ITEMS = new ResourceLocation("item");
private static final ResourceLocation POTIONS = new ResourceLocation("mob_effect");
private static final ResourceLocation BIOMES = new ResourceLocation("biome");
private static final ResourceLocation SOUNDEVENTS = new ResourceLocation("sound_event");
private static final ResourceLocation POTIONTYPES = new ResourceLocation("potion");
private static final ResourceLocation ENCHANTMENTS = new ResourceLocation("enchantment");
private static final ResourceLocation ENTITIES = new ResourceLocation("entity_type");
private static final ResourceLocation TILEENTITIES = new ResourceLocation("block_entity_type");
private static final ResourceLocation PARTICLE_TYPES = new ResourceLocation("particle_type");
private static final ResourceLocation CONTAINERS = new ResourceLocation("menu");
private static final ResourceLocation PAINTING_TYPES = new ResourceLocation("motive"); // sic
private static final ResourceLocation RECIPE_SERIALIZERS = new ResourceLocation("recipe_serializer");
private static final ResourceLocation ATTRIBUTES = new ResourceLocation("attribute");
private static final ResourceLocation STAT_TYPES = new ResourceLocation("stat_type");
// Villages
private static final ResourceLocation PROFESSIONS = new ResourceLocation("villager_profession");
private static final ResourceLocation POI_TYPES = new ResourceLocation("point_of_interest_type");
private static final ResourceLocation MEMORY_MODULE_TYPES = new ResourceLocation("memory_module_type");
private static final ResourceLocation SENSOR_TYPES = new ResourceLocation("sensor_type");
private static final ResourceLocation SCHEDULES = new ResourceLocation("schedule");
private static final ResourceLocation ACTIVITIES = new ResourceLocation("activities");
// Worldgen
private static final ResourceLocation WORLD_CARVERS = new ResourceLocation("carver");
private static final ResourceLocation SURFACE_BUILDERS = new ResourceLocation("surface_builder");
private static final ResourceLocation FEATURES = new ResourceLocation("feature");
private static final ResourceLocation DECORATORS = new ResourceLocation("decorator");
private static final ResourceLocation BIOME_PROVIDER_TYPES = new ResourceLocation("biome_source_type");
private static final ResourceLocation CHUNK_STATUS = new ResourceLocation("chunk_status");
private static final ResourceLocation STRUCTURE_FEATURES = new ResourceLocation("structure_feature");
private static final ResourceLocation BLOCK_STATE_PROVIDER_TYPES = new ResourceLocation("block_state_provider_type");
private static final ResourceLocation BLOCK_PLACER_TYPES = new ResourceLocation("block_placer_type");
private static final ResourceLocation FOLIAGE_PLACER_TYPES = new ResourceLocation("foliage_placer_type");
private static final ResourceLocation TREE_DECORATOR_TYPES = new ResourceLocation("tree_decorator_type");
// Custom forge registries
private static final ResourceLocation SERIALIZERS = new ResourceLocation("minecraft:dataserializers");
private static final ResourceLocation LOOT_MODIFIER_SERIALIZERS = new ResourceLocation("forge:loot_modifier_serializers");
private static final int MAX_VARINT = Integer.MAX_VALUE - 1; //We were told it is their intention to have everything in a reg be unlimited, so assume that until we find cases where it isnt.
private static final ResourceLocation BLOCK_TO_ITEM = new ResourceLocation("minecraft:blocktoitemmap");
@@ -167,7 +122,6 @@ public class GameData
init();
}
@SuppressWarnings("unchecked")
public static void init()
{
if (DISABLE_VANILLA_REGISTRIES)
@@ -180,78 +134,80 @@ public class GameData
hasInit = true;
// Game objects
makeRegistry(BLOCKS, Block.class, new ResourceLocation("air")).addCallback(BlockCallbacks.INSTANCE).legacyName("blocks").create();
makeRegistry(FLUIDS, Fluid.class, new ResourceLocation("empty")).create();
makeRegistry(ITEMS, Item.class, new ResourceLocation("air")).addCallback(ItemCallbacks.INSTANCE).legacyName("items").create();
makeRegistry(POTIONS, Effect.class).legacyName("potions").create();
makeRegistry(BIOMES, Biome.class).legacyName("biomes").create();
makeRegistry(SOUNDEVENTS, SoundEvent.class).legacyName("soundevents").create();
makeRegistry(POTIONTYPES, Potion.class, new ResourceLocation("empty")).legacyName("potiontypes").create();
makeRegistry(BLOCKS, Block.class, "air").addCallback(BlockCallbacks.INSTANCE).legacyName("blocks").create();
makeRegistry(FLUIDS, Fluid.class, "empty").create();
makeRegistry(ITEMS, Item.class, "air").addCallback(ItemCallbacks.INSTANCE).legacyName("items").create();
makeRegistry(EFFECTS, Effect.class ).legacyName("potions").create();
//makeRegistry(BIOMES, Biome.class).legacyName("biomes").create();
makeRegistry(SOUND_EVENTS, SoundEvent.class).legacyName("soundevents").create();
makeRegistry(POTIONS, Potion.class, "empty").legacyName("potiontypes").create();
makeRegistry(ENCHANTMENTS, Enchantment.class).legacyName("enchantments").create();
makeRegistry(ENTITIES, EntityType.class, new ResourceLocation("pig")).legacyName("entities").create();
makeRegistry(TILEENTITIES, TileEntityType.class).disableSaving().legacyName("tileentities").create();
makeRegistry(PARTICLE_TYPES, ParticleType.class).disableSaving().create();
makeRegistry(CONTAINERS, ContainerType.class).disableSaving().create();
makeRegistry(PAINTING_TYPES, PaintingType.class, new ResourceLocation("kebab")).create();
makeRegistry(RECIPE_SERIALIZERS, IRecipeSerializer.class).disableSaving().create();
makeRegistry(ENTITY_TYPES, c(EntityType.class), "pig").legacyName("entities").create();
makeRegistry(TILE_ENTITY_TYPES, c(TileEntityType.class)).disableSaving().legacyName("tileentities").create();
makeRegistry(PARTICLE_TYPES, c(ParticleType.class)).disableSaving().create();
makeRegistry(CONTAINER_TYPES, c(ContainerType.class)).disableSaving().create();
makeRegistry(PAINTING_TYPES, PaintingType.class, "kebab").create();
makeRegistry(RECIPE_SERIALIZERS, c(IRecipeSerializer.class)).disableSaving().create();
makeRegistry(ATTRIBUTES, Attribute.class).onValidate(AttributeCallbacks.INSTANCE).disableSaving().disableSync().create();
makeRegistry(STAT_TYPES, StatType.class).create();
makeRegistry(STAT_TYPES, c(StatType.class)).create();
// Villagers
makeRegistry(PROFESSIONS, VillagerProfession.class, new ResourceLocation("none")).create();
makeRegistry(POI_TYPES, PointOfInterestType.class, new ResourceLocation("unemployed")).disableSync().create();
makeRegistry(MEMORY_MODULE_TYPES, MemoryModuleType.class, new ResourceLocation("dummy")).disableSync().create();
makeRegistry(SENSOR_TYPES, SensorType.class, new ResourceLocation("dummy")).disableSaving().disableSync().create();
makeRegistry(VILLAGER_PROFESSIONS, VillagerProfession.class, "none").create();
makeRegistry(POI_TYPES, PointOfInterestType.class, "unemployed").disableSync().create();
makeRegistry(MEMORY_MODULE_TYPES, c(MemoryModuleType.class), "dummy").disableSync().create();
makeRegistry(SENSOR_TYPES, c(SensorType.class), "dummy").disableSaving().disableSync().create();
makeRegistry(SCHEDULES, Schedule.class).disableSaving().disableSync().create();
makeRegistry(ACTIVITIES, Activity.class).disableSaving().disableSync().create();
// Worldgen
makeRegistry(WORLD_CARVERS, WorldCarver.class).disableSaving().disableSync().create();
makeRegistry(SURFACE_BUILDERS, SurfaceBuilder.class).disableSaving().disableSync().create();
makeRegistry(FEATURES, Feature.class).addCallback(FeatureCallbacks.INSTANCE).disableSaving().create();
makeRegistry(DECORATORS, Placement.class).disableSaving().disableSync().create();
makeRegistry(CHUNK_STATUS, ChunkStatus.class, new ResourceLocation("empty")).disableSaving().disableSync().create();
makeRegistry(STRUCTURE_FEATURES, Structure.class).disableSaving().disableSync().create();
makeRegistry(BLOCK_STATE_PROVIDER_TYPES, BlockStateProviderType.class).disableSaving().disableSync().create();
makeRegistry(BLOCK_PLACER_TYPES, BlockPlacerType.class).disableSaving().disableSync().create();
makeRegistry(FOLIAGE_PLACER_TYPES, FoliagePlacerType.class).disableSaving().disableSync().create();
makeRegistry(TREE_DECORATOR_TYPES, TreeDecoratorType.class).disableSaving().disableSync().create();
makeRegistry(WORLD_CARVERS, c(WorldCarver.class)).disableSaving().disableSync().create();
makeRegistry(SURFACE_BUILDERS, c(SurfaceBuilder.class)).disableSaving().disableSync().create();
makeRegistry(FEATURES, c(Feature.class)).addCallback(FeatureCallbacks.INSTANCE).disableSaving().create();
makeRegistry(DECORATORS, c(Placement.class)).disableSaving().disableSync().create();
makeRegistry(CHUNK_STATUS, ChunkStatus.class, "empty").disableSaving().disableSync().create();
makeRegistry(STRUCTURE_FEATURES, c(Structure.class)).disableSaving().disableSync().create();
makeRegistry(BLOCK_STATE_PROVIDER_TYPES, c(BlockStateProviderType.class)).disableSaving().disableSync().create();
makeRegistry(BLOCK_PLACER_TYPES, c(BlockPlacerType.class)).disableSaving().disableSync().create();
makeRegistry(FOLIAGE_PLACER_TYPES, c(FoliagePlacerType.class)).disableSaving().disableSync().create();
makeRegistry(TREE_DECORATOR_TYPES, c(TreeDecoratorType.class)).disableSaving().disableSync().create();
// Custom forge registries
makeRegistry(SERIALIZERS, DataSerializerEntry.class, 256 /*vanilla space*/, MAX_VARINT).disableSaving().disableOverrides().addCallback(SerializerCallbacks.INSTANCE).create();
makeRegistry(LOOT_MODIFIER_SERIALIZERS, GlobalLootModifierSerializer.class).disableSaving().disableSync().create();
makeRegistry(DATA_SERIALIZERS, DataSerializerEntry.class, 256 /*vanilla space*/, MAX_VARINT).disableSaving().disableOverrides().addCallback(SerializerCallbacks.INSTANCE).create();
makeRegistry(LOOT_MODIFIER_SERIALIZERS, c(GlobalLootModifierSerializer.class)).disableSaving().disableSync().create();
}
@SuppressWarnings("unchecked") //Ugly hack to let us pass in a typed Class object. Remove when we remove type specific references.
private static <T> Class<T> c(Class<?> cls) { return (Class<T>)cls; }
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(RegistryKey<? extends Registry<T>> key, Class<T> type)
{
return new RegistryBuilder<T>().setName(key.func_240901_a_()).setType(type).setMaxID(MAX_VARINT).addCallback(new NamespacedWrapper.Factory<T>());
}
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(RegistryKey<? extends Registry<T>> key, Class<T> type, int min, int max)
{
return new RegistryBuilder<T>().setName(key.func_240901_a_()).setType(type).setIDRange(min, max).addCallback(new NamespacedWrapper.Factory<T>());
}
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(RegistryKey<? extends Registry<T>> key, Class<T> type, String _default)
{
return new RegistryBuilder<T>().setName(key.func_240901_a_()).setType(type).setMaxID(MAX_VARINT).addCallback(new NamespacedDefaultedWrapper.Factory<T>()).setDefaultKey(new ResourceLocation(_default));
}
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceLocation name, Class<T> type)
public static <T extends IForgeRegistryEntry<T>> SimpleRegistry<T> getWrapper(RegistryKey<? extends Registry<T>> key, Lifecycle lifecycle)
{
return new RegistryBuilder<T>().setName(name).setType(type).setMaxID(MAX_VARINT).addCallback(new NamespacedWrapper.Factory<T>());
}
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceLocation name, Class<T> type, int min, int max)
{
return new RegistryBuilder<T>().setName(name).setType(type).setIDRange(min, max).addCallback(new NamespacedWrapper.Factory<T>());
}
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceLocation name, Class<T> type, ResourceLocation _default)
{
return new RegistryBuilder<T>().setName(name).setType(type).setMaxID(MAX_VARINT).addCallback(new NamespacedDefaultedWrapper.Factory<T>()).setDefaultKey(_default);
}
public static <V extends IForgeRegistryEntry<V>> DefaultedRegistry<V> getWrapperDefaulted(Class<? super V> cls)
{
IForgeRegistry<V> reg = RegistryManager.ACTIVE.<V>getRegistry(cls);
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + cls.toString());
IForgeRegistry<T> reg = RegistryManager.ACTIVE.getRegistry(key);
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + key.toString());
@SuppressWarnings("unchecked")
DefaultedRegistry<V> ret = reg.getSlaveMap(NamespacedDefaultedWrapper.Factory.ID, NamespacedDefaultedWrapper.class);
Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + cls.toString());
SimpleRegistry<T> ret = reg.getSlaveMap(NamespacedWrapper.Factory.ID, NamespacedWrapper.class);
Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + key.toString());
return ret;
}
public static <V extends IForgeRegistryEntry<V>> SimpleRegistry<V> getWrapper(Class<? super V> cls)
public static <T extends IForgeRegistryEntry<T>> DefaultedRegistry<T> getWrapper(RegistryKey<? extends Registry<T>> key, Lifecycle lifecycle, String defKey)
{
IForgeRegistry<V> reg = RegistryManager.ACTIVE.<V>getRegistry(cls);
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + cls.toString());
IForgeRegistry<T> reg = RegistryManager.ACTIVE.getRegistry(key);
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + key.toString());
@SuppressWarnings("unchecked")
SimpleRegistry<V> ret = reg.getSlaveMap(NamespacedWrapper.Factory.ID, NamespacedWrapper.class);
Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + cls.toString());
DefaultedRegistry<T> ret = reg.getSlaveMap(NamespacedDefaultedWrapper.Factory.ID, NamespacedDefaultedWrapper.class);
Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + key.toString());
return ret;
}
@@ -435,7 +391,7 @@ public class GameData
final ClearableObjectIntIdentityMap<BlockState> idMap = new ClearableObjectIntIdentityMap<BlockState>()
{
@Override
public int get(BlockState key)
public int getId(BlockState key)
{
Integer integer = (Integer)this.identityMap.get(key);
// There are some cases where this map is queried to serialize a state that is valid,
@@ -852,11 +808,11 @@ public class GameData
keys.sort((o1, o2) -> String.valueOf(o1).compareToIgnoreCase(String.valueOf(o2)));
//Move Blocks to first, and Items to second.
keys.remove(BLOCKS);
keys.remove(ITEMS);
keys.remove(BLOCKS.func_240901_a_());
keys.remove(ITEMS.func_240901_a_());
keys.add(0, BLOCKS);
keys.add(1, ITEMS);
keys.add(0, BLOCKS.func_240901_a_());
keys.add(1, ITEMS.func_240901_a_());
for (int i = 0, keysSize = keys.size(); i < keysSize; i++) {
final ResourceLocation rl = keys.get(i);
if (!filter.test(rl)) continue;
@@ -22,6 +22,7 @@ package net.minecraftforge.registries;
import java.util.Collection;
import java.util.Iterator;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Random;
import java.util.Set;
@@ -50,7 +51,7 @@ class NamespacedDefaultedWrapper<T extends IForgeRegistryEntry<T>> extends Defau
}
@Override
public <V extends T> V register(int id, RegistryKey<T> key, V value)
public <V extends T> V register(int id, RegistryKey<T> key, V value, Lifecycle lifecycle)
{
if (locked)
throw new IllegalStateException("Can not register to a locked registry. Modder should use Forge Register methods.");
@@ -67,14 +68,22 @@ class NamespacedDefaultedWrapper<T extends IForgeRegistryEntry<T>> extends Defau
}
@Override
public <V extends T> V register(RegistryKey<T> key, V value)
public <V extends T> V register(RegistryKey<T> key, V value, Lifecycle lifecycle)
{
return register(-1, key, value);
return register(-1, key, value, lifecycle);
}
@Override
public <V extends T> V func_241874_a(OptionalInt id, RegistryKey<T> key, V value, Lifecycle lifecycle) {
int wanted = -1;
if (id.isPresent() && getByValue(id.getAsInt()) != null)
wanted = id.getAsInt();
return register(wanted, key, value, lifecycle);
}
// Reading Functions
@Override
public Optional<T> getValue(@Nullable ResourceLocation name)
public Optional<T> func_241873_b(@Nullable ResourceLocation name)
{
return Optional.ofNullable( this.delegate.getRaw(name)); //get without default
}
@@ -112,12 +121,6 @@ class NamespacedDefaultedWrapper<T extends IForgeRegistryEntry<T>> extends Defau
return this.delegate.getValue(id);
}
@Override
public boolean func_230518_b_(int id)
{
return this.getByValue(id) != null;
}
@Override
public Iterator<T> iterator()
{
@@ -22,6 +22,7 @@ package net.minecraftforge.registries;
import java.util.Collection;
import java.util.Iterator;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Random;
import java.util.Set;
import javax.annotation.Nullable;
@@ -43,12 +44,12 @@ class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends SimpleRegistry
public NamespacedWrapper(ForgeRegistry<T> owner)
{
super(RegistryKey.func_240904_a_(owner.getRegistryName()), Lifecycle.experimental());
super(RegistryKey.func_240904_a_(owner.getRegistryName()), Lifecycle.experimental());
this.delegate = owner;
}
@Override
public <V extends T> V register(int id, RegistryKey<T> key, V value)
public <V extends T> V register(int id, RegistryKey<T> key, V value, Lifecycle lifecycle)
{
if (locked)
throw new IllegalStateException("Can not register to a locked registry. Modder should use Forge Register methods.");
@@ -65,9 +66,17 @@ class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends SimpleRegistry
}
@Override
public <R extends T> R register(RegistryKey<T> key, R value)
public <R extends T> R register(RegistryKey<T> key, R value, Lifecycle lifecycle)
{
return register(-1, key, value);
return register(-1, key, value, lifecycle);
}
@Override
public <V extends T> V func_241874_a(OptionalInt id, RegistryKey<T> key, V value, Lifecycle lifecycle) {
int wanted = -1;
if (id.isPresent() && getByValue(id.getAsInt()) != null)
wanted = id.getAsInt();
return register(wanted, key, value, lifecycle);
}
// Reading Functions
@@ -79,7 +88,7 @@ class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends SimpleRegistry
}
@Override
public Optional<T> getValue(@Nullable ResourceLocation name)
public Optional<T> func_241873_b(@Nullable ResourceLocation name)
{
return Optional.ofNullable( this.delegate.getRaw(name)); //get without default
}
@@ -32,7 +32,9 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.collect.Sets.SetView;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraftforge.fml.network.FMLHandshakeMessages;
import net.minecraftforge.registries.ForgeRegistry.Snapshot;
import org.apache.commons.lang3.tuple.Pair;
@@ -75,6 +77,11 @@ public class RegistryManager
return (ForgeRegistry<V>)this.registries.get(key);
}
public <V extends IForgeRegistryEntry<V>> ForgeRegistry<V> getRegistry(RegistryKey<? extends Registry<V>> key)
{
return getRegistry(key.func_240901_a_());
}
public <V extends IForgeRegistryEntry<V>> IForgeRegistry<V> getRegistry(Class<? super V> cls)
{
return getRegistry(superTypes.get(cls));
@@ -22,11 +22,14 @@ package net.minecraftforge.server.command;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.DimensionType;
import net.minecraft.world.server.ServerWorld;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -42,9 +45,11 @@ public class CommandDimensions
.requires(cs->cs.hasPermissionLevel(0)) //permission
.executes(ctx -> {
ctx.getSource().sendFeedback(new TranslationTextComponent("commands.forge.dimensions.list"), true);
final Registry<DimensionType> reg = ctx.getSource().func_241861_q().func_243612_b(Registry.field_239698_ad_);
Map<ResourceLocation, List<ResourceLocation>> types = new HashMap<>();
for (ServerWorld dim : ctx.getSource().getServer().getWorlds()) {
types.computeIfAbsent(dim.func_234922_V_().func_240901_a_(), k -> new ArrayList<>()).add(dim.func_234923_W_().func_240901_a_());
types.computeIfAbsent(reg.getKey(dim.func_230315_m_()), k -> new ArrayList<>()).add(dim.func_234923_W_().func_240901_a_());
}
types.keySet().stream().sorted().forEach(key -> {
@@ -25,7 +25,9 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.command.arguments.DimensionArgument;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.DimensionType;
import net.minecraft.world.server.ServerWorld;
class CommandTps
@@ -61,9 +63,10 @@ class CommandTps
if (times == null) // Null means the world is unloaded. Not invalid. That's taken car of by DimensionArgument itself.
times = UNLOADED;
final Registry<DimensionType> reg = cs.func_241861_q().func_243612_b(Registry.field_239698_ad_);
double worldTickTime = mean(times) * 1.0E-6D;
double worldTPS = Math.min(1000.0 / worldTickTime, 20);
cs.sendFeedback(new TranslationTextComponent("commands.forge.tps.summary.named", dim.func_234923_W_().func_240901_a_().toString(), dim.func_234922_V_().func_240901_a_().toString(), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false);
cs.sendFeedback(new TranslationTextComponent("commands.forge.tps.summary.named", dim.func_234923_W_().func_240901_a_().toString(), reg.getKey(dim.func_230315_m_()), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false);
return 1;
}