Update to 1.14.2

This commit is contained in:
LexManos authored and cpw committed 2019-06-07 16:50:47 -04:00
1 parent d3e8804dbf
commit a7df63e1a1
1010 files changed
+15254 -19520

No files matched your search

@@ -22,8 +22,8 @@ package net.minecraftforge.fml.common;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.chunk.AbstractChunkProvider;
import net.minecraft.world.gen.ChunkGenerator;
/**
@@ -45,5 +45,5 @@ public interface IWorldGenerator
* @param chunkProvider : additionalData[2] {@link IChunkProvider} that is requesting the world generation.
*
*/
void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider);
void generate(Random random, int chunkX, int chunkZ, World world, ChunkGenerator chunkGenerator, AbstractChunkProvider chunkProvider);
}
@@ -18,6 +18,8 @@
*/
package net.minecraftforge.fml.common;
import net.minecraftforge.fml.common.EnhancedRuntimeException.WrappedPrintStream;
public class LoaderException extends EnhancedRuntimeException
{
@@ -19,8 +19,8 @@
package net.minecraftforge.fml.common.gameevent;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.dimension.DimensionType;
@@ -29,13 +29,13 @@ import net.minecraftforge.eventbus.api.Event;
import javax.annotation.Nonnull;
public class PlayerEvent extends Event {
private final EntityPlayer player;
private PlayerEvent(EntityPlayer player)
private final PlayerEntity player;
private PlayerEvent(PlayerEntity player)
{
this.player = player;
}
public EntityPlayer getPlayer()
public PlayerEntity getPlayer()
{
return this.player;
}
@@ -44,12 +44,12 @@ public class PlayerEvent extends Event {
/**
* Original EntityItem with current remaining stack size
*/
private final EntityItem originalEntity;
private final ItemEntity originalEntity;
/**
* Clone item stack, containing the item and amount picked up
*/
private final ItemStack stack;
public ItemPickupEvent(EntityPlayer player, EntityItem entPickedUp, ItemStack stack)
public ItemPickupEvent(PlayerEntity player, ItemEntity entPickedUp, ItemStack stack)
{
super(player);
this.originalEntity = entPickedUp;
@@ -60,7 +60,7 @@ public class PlayerEvent extends Event {
return stack;
}
public EntityItem getOriginalEntity() {
public ItemEntity getOriginalEntity() {
return originalEntity;
}
}
@@ -69,7 +69,7 @@ public class PlayerEvent extends Event {
@Nonnull
private final ItemStack crafting;
private final IInventory craftMatrix;
public ItemCraftedEvent(EntityPlayer player, @Nonnull ItemStack crafting, IInventory craftMatrix)
public ItemCraftedEvent(PlayerEntity player, @Nonnull ItemStack crafting, IInventory craftMatrix)
{
super(player);
this.crafting = crafting;
@@ -90,7 +90,7 @@ public class PlayerEvent extends Event {
public static class ItemSmeltedEvent extends PlayerEvent {
@Nonnull
private final ItemStack smelting;
public ItemSmeltedEvent(EntityPlayer player, @Nonnull ItemStack crafting)
public ItemSmeltedEvent(PlayerEntity player, @Nonnull ItemStack crafting)
{
super(player);
this.smelting = crafting;
@@ -104,14 +104,14 @@ public class PlayerEvent extends Event {
}
public static class PlayerLoggedInEvent extends PlayerEvent {
public PlayerLoggedInEvent(EntityPlayer player)
public PlayerLoggedInEvent(PlayerEntity player)
{
super(player);
}
}
public static class PlayerLoggedOutEvent extends PlayerEvent {
public PlayerLoggedOutEvent(EntityPlayer player)
public PlayerLoggedOutEvent(PlayerEntity player)
{
super(player);
}
@@ -120,7 +120,7 @@ public class PlayerEvent extends Event {
public static class PlayerRespawnEvent extends PlayerEvent {
private final boolean endConquered;
public PlayerRespawnEvent(EntityPlayer player, boolean endConquered)
public PlayerRespawnEvent(PlayerEntity player, boolean endConquered)
{
super(player);
this.endConquered = endConquered;
@@ -141,7 +141,7 @@ public class PlayerEvent extends Event {
public static class PlayerChangedDimensionEvent extends PlayerEvent {
private final DimensionType fromDim;
private final DimensionType toDim;
public PlayerChangedDimensionEvent(EntityPlayer player, DimensionType fromDim, DimensionType toDim)
public PlayerChangedDimensionEvent(PlayerEntity player, DimensionType fromDim, DimensionType toDim)
{
super(player);
this.fromDim = fromDim;
@@ -19,8 +19,8 @@
package net.minecraftforge.fml.common.gameevent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.LogicalSide;
@@ -67,11 +67,11 @@ public class TickEvent extends net.minecraftforge.eventbus.api.Event
}
}
public static class PlayerTickEvent extends TickEvent {
public final EntityPlayer player;
public final PlayerEntity player;
public PlayerTickEvent(Phase phase, EntityPlayer player)
public PlayerTickEvent(Phase phase, PlayerEntity player)
{
super(Type.PLAYER, player instanceof EntityPlayerMP ? LogicalSide.SERVER : LogicalSide.CLIENT, phase);
super(Type.PLAYER, player instanceof ServerPlayerEntity ? LogicalSide.SERVER : LogicalSide.CLIENT, phase);
this.player = player;
}
}
@@ -19,7 +19,7 @@
package net.minecraftforge.fml.common.network;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import javax.annotation.Nullable;
@@ -38,7 +38,7 @@ public interface IGuiHandler
* @return A GuiScreen/Container to be displayed to the user, null if none.
*/
@Nullable
Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z);
Object getServerGuiElement(int ID, PlayerEntity player, World world, int x, int y, int z);
/**
* Returns a Container to be displayed to the user. On the client side, this
@@ -54,5 +54,5 @@ public interface IGuiHandler
* @return A GuiScreen/Container to be displayed to the user, null if none.
*/
@Nullable
Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z);
Object getClientGuiElement(int ID, PlayerEntity player, World world, int x, int y, int z);
}
@@ -31,11 +31,11 @@ import java.util.Iterator;
import java.util.List;
import net.minecraft.network.EnumPacketDirection;
import net.minecraft.network.PacketDirection;
import net.minecraft.network.NettyVarint21FrameDecoder;
import net.minecraft.network.NettyVarint21FrameEncoder;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.IPacket;
import net.minecraft.network.PacketBuffer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -46,14 +46,14 @@ public class PacketLoggingHandler
public static void register(NetworkManager manager)
{
ChannelPipeline pipeline = manager.channel().pipeline();
final EnumPacketDirection direction = manager.getDirection();
final PacketDirection direction = manager.getDirection();
if (manager.isLocalChannel())
{
pipeline.addBefore("packet_handler", "splitter", new SimpleChannelInboundHandler<Packet<?>>()
pipeline.addBefore("packet_handler", "splitter", new SimpleChannelInboundHandler<IPacket<?>>()
{
String prefix = (direction == EnumPacketDirection.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C");
String prefix = (direction == PacketDirection.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C");
@Override
protected void channelRead0(ChannelHandlerContext ctx, Packet<?> msg) throws Exception
protected void channelRead0(ChannelHandlerContext ctx, IPacket<?> msg) throws Exception
{
PacketBuffer buf = new PacketBuffer(Unpooled.buffer());
msg.writePacketData(buf);
@@ -63,14 +63,14 @@ public class PacketLoggingHandler
});
pipeline.addBefore("splitter", "prepender", new ChannelOutboundHandlerAdapter()
{
String prefix = (direction == EnumPacketDirection.SERVERBOUND ? "SERVER: S->C" : "CLIENT: C->S");
String prefix = (direction == PacketDirection.SERVERBOUND ? "SERVER: S->C" : "CLIENT: C->S");
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
{
if (msg instanceof Packet<?>)
if (msg instanceof IPacket<?>)
{
PacketBuffer buf = new PacketBuffer(Unpooled.buffer());
((Packet<?>)msg).writePacketData(buf);
((IPacket<?>)msg).writePacketData(buf);
LOGGER.debug("{} {}:\n{}", prefix, msg.getClass().getSimpleName(), ByteBufUtils.getContentDump(buf));
}
ctx.write(msg, promise);
@@ -81,7 +81,7 @@ public class PacketLoggingHandler
{
pipeline.replace("splitter", "splitter", new NettyVarint21FrameDecoder()
{
String prefix = (direction == EnumPacketDirection.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C");
String prefix = (direction == PacketDirection.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C");
@Override
protected void decode(ChannelHandlerContext context, ByteBuf input, List<Object> output) throws Exception
{
@@ -98,7 +98,7 @@ public class PacketLoggingHandler
});
pipeline.replace("prepender", "prepender", new NettyVarint21FrameEncoder()
{
String prefix = (direction == EnumPacketDirection.SERVERBOUND ? "SERVER: S->C" : "CLIENT: C->S");
String prefix = (direction == PacketDirection.SERVERBOUND ? "SERVER: S->C" : "CLIENT: C->S");
@Override
protected void encode(ChannelHandlerContext context, ByteBuf input, ByteBuf output) throws Exception
{
@@ -1,366 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* 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.fml.common.registry;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Random;
import javax.annotation.Nullable;
import org.apache.commons.lang3.Validate;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.minecraft.entity.monster.EntityZombieVillager;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.passive.EntityVillager.ITradeList;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.RegistryNamespaced;
import net.minecraft.world.gen.feature.structure.StructurePiece;
import net.minecraft.world.gen.feature.structure.VillagePieces;
import net.minecraft.world.gen.feature.structure.VillagePieces.PieceWeight;
import net.minecraft.world.gen.feature.structure.VillagePieces.Village;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.ForgeRegistryEntry;
import net.minecraftforge.registries.GameData;
/**
* Registry for villager trading control
*/
public class VillagerRegistry
{
public static final RegistryObject<VillagerProfession> FARMER = RegistryObject.of("minecraft:farmer", ()->VillagerProfession.class);
private static final VillagerRegistry INSTANCE = new VillagerRegistry();
private Map<Class<?>, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap();
private VillagerRegistry()
{
init();
}
/**
* Allow access to the {@link net.minecraft.world.gen.structure.StructureVillagePieces} array controlling new village
* creation so you can insert your own new village pieces
*
* @author cpw
*/
public interface IVillageCreationHandler
{
/**
* Called when {@link net.minecraft.world.gen.structure.MapGenVillage} is creating a new village
*
* @param random
* @param i
*/
VillagePieces.PieceWeight getVillagePieceWeight(Random random, int i);
/**
* The class of the root structure component to add to the village
*/
Class<?> getComponentClass();
/**
* Build an instance of the village component {@link net.minecraft.world.gen.structure.StructureVillagePieces}
*
* @param villagePiece
* @param startPiece
* @param pieces
* @param random
* @param p1
* @param p2
* @param p3
* @param facing
* @param p5
*/
Village buildComponent(VillagePieces.PieceWeight villagePiece, VillagePieces.Start startPiece, List<StructurePiece> pieces, Random random, int p1,
int p2, int p3, EnumFacing facing, int p5);
}
public static VillagerRegistry instance()
{
return INSTANCE;
}
/**
* Register a new village creation handler
*
* @param handler
*/
public void registerVillageCreationHandler(IVillageCreationHandler handler)
{
villageCreationHandlers.put(handler.getComponentClass(), handler);
}
public static void addExtraVillageComponents(List<PieceWeight> list, Random random, int i)
{
List<VillagePieces.PieceWeight> parts = list;
for (IVillageCreationHandler handler : instance().villageCreationHandlers.values())
{
parts.add(handler.getVillagePieceWeight(random, i));
}
}
public static Village getVillageComponent(VillagePieces.PieceWeight villagePiece, VillagePieces.Start startPiece, List<StructurePiece> pieces, Random random,
int p1, int p2, int p3, EnumFacing facing, int p5)
{
return instance().villageCreationHandlers.get(villagePiece.villagePieceClass).buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, facing, p5);
}
RegistryNamespaced<VillagerProfession> REGISTRY = GameData.getWrapper(VillagerProfession.class);
private void register(VillagerProfession prof, int id)
{
REGISTRY.register(id, prof.name, prof);
}
private boolean hasInit = false;
private void init()
{
if (hasInit)
{
return;
}
VillagerProfession prof = new VillagerProfession("minecraft:farmer",
"minecraft:textures/entity/villager/farmer.png",
"minecraft:textures/entity/zombie_villager/zombie_farmer.png");
{
register(prof, 0);
(new VillagerCareer(prof, "farmer")).init(VanillaTrades.trades[0][0]);
(new VillagerCareer(prof, "fisherman")).init(VanillaTrades.trades[0][1]);
(new VillagerCareer(prof, "shepherd")).init(VanillaTrades.trades[0][2]);
(new VillagerCareer(prof, "fletcher")).init(VanillaTrades.trades[0][3]);
}
prof = new VillagerProfession("minecraft:librarian",
"minecraft:textures/entity/villager/librarian.png",
"minecraft:textures/entity/zombie_villager/zombie_librarian.png");
{
register(prof, 1);
(new VillagerCareer(prof, "librarian")).init(VanillaTrades.trades[1][0]);
(new VillagerCareer(prof, "cartographer")).init(VanillaTrades.trades[1][1]);
}
prof = new VillagerProfession("minecraft:priest",
"minecraft:textures/entity/villager/priest.png",
"minecraft:textures/entity/zombie_villager/zombie_priest.png");
{
register(prof, 2);
(new VillagerCareer(prof, "cleric")).init(VanillaTrades.trades[2][0]);
}
prof = new VillagerProfession("minecraft:smith",
"minecraft:textures/entity/villager/smith.png",
"minecraft:textures/entity/zombie_villager/zombie_smith.png");
{
register(prof, 3);
(new VillagerCareer(prof, "armorer")).init(VanillaTrades.trades[3][0]);
(new VillagerCareer(prof, "weapon_smith")).init(VanillaTrades.trades[3][1]);
(new VillagerCareer(prof, "tool_smith")).init(VanillaTrades.trades[3][2]);
}
prof = new VillagerProfession("minecraft:butcher",
"minecraft:textures/entity/villager/butcher.png",
"minecraft:textures/entity/zombie_villager/zombie_butcher.png");
{
register(prof, 4);
(new VillagerCareer(prof, "butcher")).init(VanillaTrades.trades[4][0]);
(new VillagerCareer(prof, "leatherworker")).init(VanillaTrades.trades[4][1]);
}
prof = new VillagerProfession("minecraft:nitwit",
"minecraft:textures/entity/villager/villager.png",
"minecraft:textures/entity/zombie_villager/zombie_villager.png");
{
register(prof, 5);
(new VillagerCareer(prof, "nitwit")).init(VanillaTrades.trades[5][0]);
}
}
public static class VillagerProfession extends ForgeRegistryEntry<VillagerProfession>
{
private ResourceLocation name;
private ResourceLocation texture;
private ResourceLocation zombie;
private List<VillagerCareer> careers = Lists.newArrayList();
public VillagerProfession(String name, String texture, String zombie)
{
this.name = new ResourceLocation(name);
this.texture = new ResourceLocation(texture);
this.zombie = new ResourceLocation(zombie);
this.setRegistryName(this.name);
}
private void register(VillagerCareer career)
{
Validate.isTrue(!careers.contains(career), "Attempted to register career that is already registered.");
Validate.isTrue(career.profession == this, "Attempted to register career for the wrong profession.");
career.id = careers.size();
careers.add(career);
}
public ResourceLocation getSkin() { return this.texture; }
public ResourceLocation getZombieSkin() { return this.zombie; }
public VillagerCareer getCareer(int id)
{
for (VillagerCareer car : this.careers)
{
if (car.id == id)
return car;
}
return this.careers.get(0);
}
public int getRandomCareer(Random rand)
{
return this.careers.get(rand.nextInt(this.careers.size())).id;
}
}
public static class VillagerCareer
{
private VillagerProfession profession;
private String name;
private int id;
private List<List<ITradeList>> trades = Lists.newArrayList();
public VillagerCareer(VillagerProfession parent, String name)
{
this.profession = parent;
this.name = name;
parent.register(this);
}
public String getName()
{
return this.name;
}
public VillagerCareer addTrade(int level, ITradeList... trades)
{
if (level <= 0)
throw new IllegalArgumentException("Levels start at 1");
List<ITradeList> levelTrades = level <= this.trades.size() ? this.trades.get(level - 1) : null;
if (levelTrades == null)
{
while (this.trades.size() < level)
{
levelTrades = Lists.newArrayList();
this.trades.add(levelTrades);
}
}
if (levelTrades == null) //Not sure how this could happen, but screw it
{
levelTrades = Lists.newArrayList();
this.trades.set(level - 1, levelTrades);
}
for (ITradeList t : trades)
levelTrades.add(t);
return this;
}
@Nullable
public List<ITradeList> getTrades(int level)
{
return level >= 0 && level < this.trades.size() ? Collections.unmodifiableList(this.trades.get(level)) : null;
}
private VillagerCareer init(EntityVillager.ITradeList[][] trades)
{
for (int x = 0; x < trades.length; x++)
this.trades.add(Lists.newArrayList(trades[x]));
return this;
}
@Override
public boolean equals(Object o)
{
if (o == this)
{
return true;
}
if (!(o instanceof VillagerCareer))
{
return false;
}
VillagerCareer oc = (VillagerCareer)o;
return name.equals(oc.name) && profession == oc.profession;
}
}
/**
* Hook called when spawning a Villager, sets it's profession to a random registered profession.
*
* @param entity The new entity
* @param rand The world's RNG
*/
public static void setRandomProfession(EntityVillager entity, Random rand)
{
entity.setProfession(INSTANCE.REGISTRY.getRandom(rand));
}
public static void setRandomProfession(EntityZombieVillager entity, Random rand)
{
entity.setProfession(INSTANCE.REGISTRY.getRandom(rand));
}
//Below this is INTERNAL USE ONLY DO NOT USE MODDERS
public static void onSetProfession(EntityVillager entity, int network)
{
VillagerProfession prof = INSTANCE.REGISTRY.get(network);
if (prof == null || INSTANCE.REGISTRY.getId(prof) != network)
{
throw new RuntimeException("Attempted to set villager profession to unregistered profession: " + network + " " + prof);
}
if (prof != entity.getProfessionForge())
entity.setProfession(prof);
}
public static void onSetProfession(EntityZombieVillager entity, int network)
{
VillagerProfession prof = INSTANCE.REGISTRY.get(network);
if (prof == null && network != -1 || INSTANCE.REGISTRY.getId(prof) != network)
{
throw new RuntimeException("Attempted to set villager profession to unregistered profession: " + network + " " + prof);
}
if (prof != entity.getProfessionForge())
entity.setProfession(prof);
}
@Deprecated public static VillagerProfession getById(int network){ return INSTANCE.REGISTRY.get(network); }
@Deprecated public static int getId(@Nullable VillagerProfession prof){ return INSTANCE.REGISTRY.getId(prof); }
//TODO: Figure out a good generic system for this. Put on hold for Patches.
private static class VanillaTrades
{
//This field is moved from EntityVillager over to here.
//Moved to inner class to stop static initializer issues.
//It is nasty I know but it's vanilla.
private static final ITradeList[][][][] trades = EntityVillager.GET_TRADES_DONT_USE();
}
}