mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 02:55:17 +00:00
Initial 1.13.2 update. Major thing to note is that Dimensions have been completely revamped.
DimensionType is not unique per Dimension. See DimensionManager for more details. Vanilla now has a chunk loading system, so Forge's will need to be deprecated/adapted.
This commit is contained in:
1 parent
9a1688599a
commit
ca72710937
361 files changed
+3166
-3547
No files matched your search
@@ -28,6 +28,7 @@ import static org.lwjgl.opengl.GL20.*;
|
||||
import java.io.File;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
@@ -55,20 +56,20 @@ import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.BlockFaceUV;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransformVec3f;
|
||||
import net.minecraft.client.renderer.block.model.ModelManager;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.block.model.SimpleBakedModel;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.BlockFaceUV;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemTransformVec3f;
|
||||
import net.minecraft.client.renderer.model.ModelManager;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.model.SimpleBakedModel;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.client.renderer.entity.model.ModelBiped;
|
||||
@@ -140,17 +141,17 @@ public class ForgeHooksClient
|
||||
return result != null ? result : _default;
|
||||
}
|
||||
|
||||
public static boolean onDrawBlockHighlight(RenderGlobal context, EntityPlayer player, RayTraceResult target, int subID, float partialTicks)
|
||||
public static boolean onDrawBlockHighlight(WorldRenderer context, EntityPlayer player, RayTraceResult target, int subID, float partialTicks)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent(context, player, target, subID, partialTicks));
|
||||
}
|
||||
|
||||
public static void dispatchRenderLast(RenderGlobal context, float partialTicks)
|
||||
public static void dispatchRenderLast(WorldRenderer context, float partialTicks)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new RenderWorldLastEvent(context, partialTicks));
|
||||
}
|
||||
|
||||
public static boolean renderFirstPersonHand(RenderGlobal context, float partialTicks)
|
||||
public static boolean renderFirstPersonHand(WorldRenderer context, float partialTicks)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(context, partialTicks));
|
||||
}
|
||||
@@ -234,7 +235,7 @@ public class ForgeHooksClient
|
||||
return fovUpdateEvent.getNewfov();
|
||||
}
|
||||
|
||||
public static double getFOVModifier(EntityRenderer renderer, Entity entity, IBlockState blockState, IFluidState fluidState, double renderPartialTicks, double fov) {
|
||||
public static double getFOVModifier(GameRenderer renderer, Entity entity, IBlockState blockState, IFluidState fluidState, double renderPartialTicks, double fov) {
|
||||
EntityViewRenderEvent.FOVModifier event = new EntityViewRenderEvent.FOVModifier(renderer, entity, blockState, fluidState, renderPartialTicks, fov);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getFOV();
|
||||
@@ -348,26 +349,26 @@ public class ForgeHooksClient
|
||||
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Post(screen, mouseX, mouseY, partialTicks));
|
||||
}
|
||||
|
||||
public static float getFogDensity(FogRenderer fogRenderer, EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, float partial, float density)
|
||||
public static float getFogDensity(FogRenderer fogRenderer, GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, float partial, float density)
|
||||
{
|
||||
EntityViewRenderEvent.FogDensity event = new EntityViewRenderEvent.FogDensity(fogRenderer, renderer, entity, state, fluidState, partial, density);
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) return event.getDensity();
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void onFogRender(FogRenderer fogRenderer, EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, float partial, int mode, float distance)
|
||||
public static void onFogRender(FogRenderer fogRenderer, GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, float partial, int mode, float distance)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new EntityViewRenderEvent.RenderFogEvent(fogRenderer, renderer, entity, state, fluidState, partial, mode, distance));
|
||||
}
|
||||
|
||||
public static void onModelBake(ModelManager modelManager, IRegistry<ModelResourceLocation, IBakedModel> modelRegistry, ModelLoader modelLoader)
|
||||
public static void onModelBake(ModelManager modelManager, Map<ModelResourceLocation, IBakedModel> modelRegistry, ModelLoader modelLoader)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new ModelBakeEvent(modelManager, modelRegistry, modelLoader));
|
||||
modelLoader.onPostBakeEvent(modelRegistry);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Matrix4f getMatrix(net.minecraft.client.renderer.block.model.ItemTransformVec3f transform)
|
||||
public static Matrix4f getMatrix(net.minecraft.client.renderer.model.ItemTransformVec3f transform)
|
||||
{
|
||||
javax.vecmath.Matrix4f m = new javax.vecmath.Matrix4f(), t = new javax.vecmath.Matrix4f();
|
||||
m.setIdentity();
|
||||
@@ -600,7 +601,7 @@ public class ForgeHooksClient
|
||||
return Optional.of(new TRSRTransformation(matrix));
|
||||
}
|
||||
|
||||
public static void loadEntityShader(Entity entity, EntityRenderer entityRenderer)
|
||||
public static void loadEntityShader(Entity entity, GameRenderer entityRenderer)
|
||||
{
|
||||
if (entity != null)
|
||||
{
|
||||
|
||||
@@ -119,10 +119,9 @@ public class GuiIngameForge extends GuiIngame
|
||||
fontrenderer = mc.fontRenderer;
|
||||
//mc.entityRenderer.setupOverlayRendering();
|
||||
GlStateManager.enableBlend();
|
||||
|
||||
if (renderVignette && Minecraft.isFancyGraphicsEnabled())
|
||||
{
|
||||
renderVignette(mc.player.getBrightness());
|
||||
func_212303_b(mc.getRenderViewEntity());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -254,7 +253,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderVignette(float lightLevel)
|
||||
protected void func_212303_b(Entity entity)
|
||||
{
|
||||
if (pre(VIGNETTE))
|
||||
{
|
||||
@@ -263,7 +262,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
return;
|
||||
}
|
||||
super.renderVignette(lightLevel);
|
||||
super.func_212303_b(entity);
|
||||
post(VIGNETTE);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ import javax.annotation.Nullable;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.client.renderer.ItemModelMesher;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelManager;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.model.ModelManager;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
@@ -29,13 +29,13 @@ import java.util.function.Supplier;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.chunk.RenderChunkCache;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ChunkCache;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -102,25 +102,28 @@ public class MinecraftForgeClient
|
||||
}
|
||||
}
|
||||
|
||||
private static final LoadingCache<Pair<World, BlockPos>, ChunkCache> regionCache = CacheBuilder.newBuilder()
|
||||
private static final LoadingCache<Pair<World, BlockPos>, RenderChunkCache> regionCache = CacheBuilder.newBuilder()
|
||||
.maximumSize(500)
|
||||
.concurrencyLevel(5)
|
||||
.expireAfterAccess(1, TimeUnit.SECONDS)
|
||||
.build(new CacheLoader<Pair<World, BlockPos>, ChunkCache>()
|
||||
.build(new CacheLoader<Pair<World, BlockPos>, RenderChunkCache>()
|
||||
{
|
||||
@Override
|
||||
public ChunkCache load(Pair<World, BlockPos> key)
|
||||
public RenderChunkCache load(Pair<World, BlockPos> key)
|
||||
{
|
||||
return new ChunkCache(key.getLeft(), key.getRight().add(-1, -1, -1), key.getRight().add(16, 16, 16), 1);
|
||||
return RenderChunkCache.func_212397_a(key.getLeft(), key.getRight().add(-1, -1, -1), key.getRight().add(16, 16, 16), 1);
|
||||
}
|
||||
});
|
||||
|
||||
public static void onRebuildChunk(World world, BlockPos position, ChunkCache cache)
|
||||
public static void onRebuildChunk(World world, BlockPos position, RenderChunkCache cache)
|
||||
{
|
||||
regionCache.put(Pair.of(world, position), cache);
|
||||
if (cache == null)
|
||||
regionCache.invalidate(Pair.of(world, position));
|
||||
else
|
||||
regionCache.put(Pair.of(world, position), cache);
|
||||
}
|
||||
|
||||
public static ChunkCache getRegionRenderCache(World world, BlockPos pos)
|
||||
public static RenderChunkCache getRegionRenderCache(World world, BlockPos pos)
|
||||
{
|
||||
int x = pos.getX() & ~0xF;
|
||||
int y = pos.getY() & ~0xF;
|
||||
|
||||
@@ -23,18 +23,18 @@ import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
|
||||
@Cancelable
|
||||
public class DrawBlockHighlightEvent extends Event
|
||||
{
|
||||
private final RenderGlobal context;
|
||||
private final WorldRenderer context;
|
||||
private final EntityPlayer player;
|
||||
private final RayTraceResult target;
|
||||
private final int subID;
|
||||
private final float partialTicks;
|
||||
|
||||
public DrawBlockHighlightEvent(RenderGlobal context, EntityPlayer player, RayTraceResult target, int subID, float partialTicks)
|
||||
public DrawBlockHighlightEvent(WorldRenderer context, EntityPlayer player, RayTraceResult target, int subID, float partialTicks)
|
||||
{
|
||||
this.context = context;
|
||||
this.player = player;
|
||||
@@ -43,7 +43,7 @@ public class DrawBlockHighlightEvent extends Event
|
||||
this.partialTicks= partialTicks;
|
||||
}
|
||||
|
||||
public RenderGlobal getContext() { return context; }
|
||||
public WorldRenderer getContext() { return context; }
|
||||
public EntityPlayer getPlayer() { return player; }
|
||||
public RayTraceResult getTarget() { return target; }
|
||||
public int getSubID() { return subID; }
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
@@ -30,18 +30,18 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.Event.HasResult;
|
||||
|
||||
/**
|
||||
* Event that hooks into EntityRenderer, allowing any feature to customize visual attributes
|
||||
* Event that hooks into GameRenderer, allowing any feature to customize visual attributes
|
||||
* the player sees.
|
||||
*/
|
||||
public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private final EntityRenderer renderer;
|
||||
private final GameRenderer renderer;
|
||||
private final Entity entity;
|
||||
private final IBlockState state;
|
||||
private final IFluidState fluidState;
|
||||
private final double renderPartialTicks;
|
||||
|
||||
public EntityViewRenderEvent(EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks)
|
||||
public EntityViewRenderEvent(GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks)
|
||||
{
|
||||
this.renderer = renderer;
|
||||
this.entity = entity;
|
||||
@@ -50,7 +50,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
this.renderPartialTicks = renderPartialTicks;
|
||||
}
|
||||
|
||||
public EntityRenderer getRenderer()
|
||||
public GameRenderer getRenderer()
|
||||
{
|
||||
return renderer;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
{
|
||||
private final FogRenderer fogRenderer;
|
||||
|
||||
protected FogEvent(FogRenderer fogRenderer, EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks)
|
||||
protected FogEvent(FogRenderer fogRenderer, GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks)
|
||||
{
|
||||
super(renderer, entity, state, fluidState, renderPartialTicks);
|
||||
this.fogRenderer = fogRenderer;
|
||||
@@ -97,7 +97,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
{
|
||||
private float density;
|
||||
|
||||
public FogDensity(FogRenderer fogRenderer, EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, float density)
|
||||
public FogDensity(FogRenderer fogRenderer, GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, float density)
|
||||
{
|
||||
super(fogRenderer, renderer, entity, state, fluidState, renderPartialTicks);
|
||||
this.setDensity(density);
|
||||
@@ -123,7 +123,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
private final int fogMode;
|
||||
private final float farPlaneDistance;
|
||||
|
||||
public RenderFogEvent(FogRenderer fogRenderer, EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, int fogMode, float farPlaneDistance)
|
||||
public RenderFogEvent(FogRenderer fogRenderer, GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, int fogMode, float farPlaneDistance)
|
||||
{
|
||||
super(fogRenderer, renderer, entity, state, fluidState, renderPartialTicks);
|
||||
this.fogMode = fogMode;
|
||||
@@ -151,7 +151,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
private float green;
|
||||
private float blue;
|
||||
|
||||
public FogColors(FogRenderer fogRenderer, EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, float red, float green, float blue)
|
||||
public FogColors(FogRenderer fogRenderer, GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, float red, float green, float blue)
|
||||
{
|
||||
super(fogRenderer, renderer, entity, state, fluidState, renderPartialTicks);
|
||||
this.setRed(red);
|
||||
@@ -176,7 +176,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
private float pitch;
|
||||
private float roll;
|
||||
|
||||
public CameraSetup(EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, float yaw, float pitch, float roll)
|
||||
public CameraSetup(GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, float yaw, float pitch, float roll)
|
||||
{
|
||||
super(renderer, entity, state, fluidState, renderPartialTicks);
|
||||
this.setYaw(yaw);
|
||||
@@ -200,7 +200,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
{
|
||||
private double fov;
|
||||
|
||||
public FOVModifier(EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, double fov) {
|
||||
public FOVModifier(GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, double fov) {
|
||||
super(renderer, entity, state, fluidState, renderPartialTicks);
|
||||
this.setFOV(fov);
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelManager;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelManager;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
/**
|
||||
* Fired when the ModelManager is notified of the resource manager reloading.
|
||||
@@ -34,10 +34,10 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
public class ModelBakeEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private final ModelManager modelManager;
|
||||
private final IRegistry<ModelResourceLocation, IBakedModel> modelRegistry;
|
||||
private final Map<ModelResourceLocation, IBakedModel> modelRegistry;
|
||||
private final ModelLoader modelLoader;
|
||||
|
||||
public ModelBakeEvent(ModelManager modelManager, IRegistry<ModelResourceLocation, IBakedModel> modelRegistry, ModelLoader modelLoader)
|
||||
public ModelBakeEvent(ModelManager modelManager, Map<ModelResourceLocation, IBakedModel> modelRegistry, ModelLoader modelLoader)
|
||||
{
|
||||
this.modelManager = modelManager;
|
||||
this.modelRegistry = modelRegistry;
|
||||
@@ -49,7 +49,7 @@ public class ModelBakeEvent extends net.minecraftforge.eventbus.api.Event
|
||||
return modelManager;
|
||||
}
|
||||
|
||||
public IRegistry<ModelResourceLocation, IBakedModel> getModelRegistry()
|
||||
public Map<ModelResourceLocation, IBakedModel> getModelRegistry()
|
||||
{
|
||||
return modelRegistry;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
|
||||
/**
|
||||
* This event is fired on {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}
|
||||
@@ -33,15 +33,15 @@ import net.minecraft.client.renderer.RenderGlobal;
|
||||
@net.minecraftforge.eventbus.api.Cancelable
|
||||
public class RenderHandEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private final RenderGlobal context;
|
||||
private final WorldRenderer context;
|
||||
private final float partialTicks;
|
||||
public RenderHandEvent(RenderGlobal context, float partialTicks)
|
||||
public RenderHandEvent(WorldRenderer context, float partialTicks)
|
||||
{
|
||||
this.context = context;
|
||||
this.partialTicks = partialTicks;
|
||||
}
|
||||
|
||||
public RenderGlobal getContext()
|
||||
public WorldRenderer getContext()
|
||||
{
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -20,19 +20,19 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
|
||||
public class RenderWorldLastEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private final RenderGlobal context;
|
||||
private final WorldRenderer context;
|
||||
private final float partialTicks;
|
||||
public RenderWorldLastEvent(RenderGlobal context, float partialTicks)
|
||||
public RenderWorldLastEvent(WorldRenderer context, float partialTicks)
|
||||
{
|
||||
this.context = context;
|
||||
this.partialTicks = partialTicks;
|
||||
}
|
||||
|
||||
public RenderGlobal getContext()
|
||||
public WorldRenderer getContext()
|
||||
{
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
|
||||
public interface IForgeBakedModel
|
||||
{
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import net.minecraft.client.renderer.chunk.RenderChunkCache;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ChunkCache;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IForgeRenderChunk
|
||||
@@ -38,8 +38,8 @@ public interface IForgeRenderChunk
|
||||
* the cache a 20x20x20 cube, for a total of 8000 states in the cache.
|
||||
* @return new RegionRenderCache instance
|
||||
*/
|
||||
default ChunkCache createRegionRenderCache(World world, BlockPos from, BlockPos to, int subtract)
|
||||
default RenderChunkCache createRegionRenderCache(World world, BlockPos from, BlockPos to, int subtract)
|
||||
{
|
||||
return new ChunkCache(world, from, to, subtract);
|
||||
return RenderChunkCache.func_212397_a(world, from, to, subtract);
|
||||
}
|
||||
}
|
||||
@@ -28,10 +28,10 @@ import java.util.Random;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
@@ -25,10 +25,10 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -29,11 +29,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlockDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.block.model.Variant;
|
||||
import net.minecraft.client.renderer.block.model.VariantList;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelBlockDefinition;
|
||||
import net.minecraft.client.renderer.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.model.Variant;
|
||||
import net.minecraft.client.renderer.model.VariantList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
@@ -28,11 +28,11 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
@@ -38,8 +38,8 @@ import javax.vecmath.Vector3f;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ModelRotation;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.BlockStateLoader.Marker;
|
||||
|
||||
@@ -21,7 +21,7 @@ package net.minecraftforge.client.model;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.resource.IResourceType;
|
||||
|
||||
@@ -26,8 +26,8 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
|
||||
public interface ISmartVariant
|
||||
{
|
||||
|
||||
@@ -23,12 +23,12 @@ import javax.vecmath.Vector4f;
|
||||
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlock;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.ModelBlock;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
|
||||
@@ -28,12 +28,12 @@ import javax.annotation.Nullable;
|
||||
import javax.vecmath.Quat4f;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.PngSizeInfo;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
|
||||
@@ -33,11 +33,11 @@ import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
|
||||
@@ -42,31 +42,31 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockModelShapes;
|
||||
import net.minecraft.client.renderer.ItemModelMesher;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.BlockPart;
|
||||
import net.minecraft.client.renderer.block.model.BlockPartFace;
|
||||
import net.minecraft.client.renderer.block.model.BlockPartRotation;
|
||||
import net.minecraft.client.renderer.block.model.BuiltInModel;
|
||||
import net.minecraft.client.renderer.block.model.FaceBakery;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemModelGenerator;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlock;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlockDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlockDefinition.ContainerHolder;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.block.model.MultipartBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.SimpleBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.Variant;
|
||||
import net.minecraft.client.renderer.block.model.VariantList;
|
||||
import net.minecraft.client.renderer.block.model.WeightedBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.multipart.Multipart;
|
||||
import net.minecraft.client.renderer.block.model.multipart.Selector;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.BlockPart;
|
||||
import net.minecraft.client.renderer.model.BlockPartFace;
|
||||
import net.minecraft.client.renderer.model.BlockPartRotation;
|
||||
import net.minecraft.client.renderer.model.BuiltInModel;
|
||||
import net.minecraft.client.renderer.model.FaceBakery;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemModelGenerator;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.model.ModelBlock;
|
||||
import net.minecraft.client.renderer.model.ModelBlockDefinition;
|
||||
import net.minecraft.client.renderer.model.ModelBlockDefinition.ContainerHolder;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.model.MultipartBakedModel;
|
||||
import net.minecraft.client.renderer.model.SimpleBakedModel;
|
||||
import net.minecraft.client.renderer.model.Variant;
|
||||
import net.minecraft.client.renderer.model.VariantList;
|
||||
import net.minecraft.client.renderer.model.WeightedBakedModel;
|
||||
import net.minecraft.client.renderer.model.multipart.Multipart;
|
||||
import net.minecraft.client.renderer.model.multipart.Selector;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
@@ -951,7 +951,7 @@ public final class ModelLoader extends ModelBakery
|
||||
/**
|
||||
* Internal, do not use.
|
||||
*/
|
||||
public void onPostBakeEvent(IRegistry<ModelResourceLocation, IBakedModel> modelRegistry)
|
||||
public void onPostBakeEvent(Map<ModelResourceLocation, IBakedModel> modelRegistry)
|
||||
{
|
||||
IBakedModel missingModel = modelRegistry.get(MODEL_MISSING);
|
||||
for(Map.Entry<ResourceLocation, Exception> entry : loadingExceptions.entrySet())
|
||||
|
||||
@@ -34,8 +34,8 @@ import com.google.common.collect.Queues;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.resources.IReloadableResourceManager;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -27,12 +27,12 @@ import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
|
||||
@@ -32,12 +32,12 @@ import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
@@ -25,10 +25,10 @@ import java.util.Random;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.client.GameSettings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
|
||||
+5
-5
@@ -22,10 +22,10 @@ package net.minecraftforge.client.model.animation;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverride;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverride;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -68,7 +68,7 @@ public final class AnimationItemOverrideList extends ItemOverrideList
|
||||
public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
|
||||
{
|
||||
return stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)
|
||||
.map(asm ->
|
||||
.map(asm ->
|
||||
{
|
||||
World w = world;
|
||||
// TODO caching?
|
||||
|
||||
@@ -26,10 +26,10 @@ import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.entity.model.ModelBase;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
@@ -40,7 +40,7 @@ import javax.vecmath.Vector3f;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockPart;
|
||||
import net.minecraft.client.renderer.model.BlockPart;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -40,7 +40,7 @@ import net.minecraftforge.common.util.LazyOptional;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Generic {@link TileEntityRenderer} that works with the Forge model system and animations.
|
||||
* Generic {@link TileGameRenderer} that works with the Forge model system and animations.
|
||||
*/
|
||||
public class TileEntityRendererAnimation<T extends TileEntity> extends TileEntityRendererFast<T> implements IEventHandler<T>
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/**
|
||||
* A special case {@link TileEntityRenderer} which can be batched with other
|
||||
* A special case {@link TileGameRenderer} which can be batched with other
|
||||
* renderers that are also instances of this class.
|
||||
* <p>
|
||||
* Advantages:
|
||||
@@ -49,7 +49,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
* <li>All renderers must use the same {@link VertexFormat}
|
||||
* ({@link DefaultVertexFormats#BLOCK})</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @param <T> The type of {@link TileEntity} being rendered.
|
||||
*/
|
||||
public abstract class TileEntityRendererFast<T extends TileEntity> extends TileEntityRenderer<T>
|
||||
|
||||
@@ -35,11 +35,11 @@ import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.resources.IResource;
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -42,11 +42,11 @@ import javax.vecmath.Vector3f;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.resources.IResource;
|
||||
|
||||
@@ -26,8 +26,8 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.BlockModelRenderer;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@@ -21,7 +21,7 @@ package net.minecraftforge.client.model.pipeline;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.model.pipeline;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
|
||||
@@ -22,7 +22,7 @@ package net.minecraftforge.client.model.pipeline;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
|
||||
@@ -16,46 +16,46 @@
|
||||
* 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;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
||||
import it.unimi.dsi.fastutil.ints.IntIterator;
|
||||
import it.unimi.dsi.fastutil.ints.IntLinkedOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntRBTreeSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSets;
|
||||
import it.unimi.dsi.fastutil.ints.IntSortedSet;
|
||||
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.collect.Multiset;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ServerWorldEventHandler;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.WorldServerMulti;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.storage.ISaveHandler;
|
||||
import net.minecraftforge.event.world.RegisterDimensionsEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.registries.ClearableRegistry;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
@@ -67,340 +67,193 @@ public class DimensionManager
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Marker DIMMGR = MarkerManager.getMarker("DIMS");
|
||||
private static class DimensionData
|
||||
{
|
||||
private final DimensionType type;
|
||||
private int ticksWaited;
|
||||
private DimensionData(DimensionType type)
|
||||
{
|
||||
this.type = type;
|
||||
this.ticksWaited = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasInit = false;
|
||||
private static final ClearableRegistry<DimensionType> REGISTRY = new ClearableRegistry<>(new ResourceLocation("dimension_type"));
|
||||
|
||||
private static final Int2ObjectMap<WorldServer> worlds = Int2ObjectMaps.synchronize(new Int2ObjectLinkedOpenHashMap<>());
|
||||
private static final Int2ObjectMap<DimensionData> dimensions = Int2ObjectMaps.synchronize(new Int2ObjectLinkedOpenHashMap<>());
|
||||
private static final IntSet keepLoaded = IntSets.synchronize(new IntOpenHashSet());
|
||||
private static final Int2ObjectMap<Data> dimensions = Int2ObjectMaps.synchronize(new Int2ObjectLinkedOpenHashMap<>());
|
||||
private static final IntSet unloadQueue = IntSets.synchronize(new IntLinkedOpenHashSet());
|
||||
private static final BitSet dimensionMap = new BitSet(Long.SIZE << 4);
|
||||
private static final ConcurrentMap<World, World> weakWorldMap = new MapMaker().weakKeys().weakValues().makeMap();
|
||||
private static final Multiset<Integer> leakedWorlds = HashMultiset.create();
|
||||
private static final Map<ResourceLocation, SavedEntry> savedEntries = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Returns a list of dimensions associated with this DimensionType.
|
||||
* Registers a real unique dimension, Should be called on server init, or when the dimension is created.
|
||||
* On the client, the list will be reset/reloaded every time a InternalServer is refreshed.
|
||||
*
|
||||
* Forge will save this data and keep track of registered values, syncing automatically from the remote server.
|
||||
*
|
||||
* @param name Registry name for this new dimension.
|
||||
* @param type Dimension Type.
|
||||
* @param data Configuration data for this dimension, passed into
|
||||
*/
|
||||
public static int[] getDimensions(DimensionType type)
|
||||
public static void registerDimension(ResourceLocation name, ModDimension type, PacketBuffer data)
|
||||
{
|
||||
int[] ret = new int[dimensions.size()];
|
||||
int x = 0;
|
||||
for (Int2ObjectMap.Entry<DimensionData> ent : dimensions.int2ObjectEntrySet())
|
||||
Validate.notNull(name, "Can not register a dimesnion with null name");
|
||||
Validate.isTrue(!REGISTRY.func_212607_c(name), "Dimension: " + name + " Already registered");
|
||||
Validate.notNull(type, "Can not register a null dimension type");
|
||||
|
||||
int id = REGISTRY.getNextId();
|
||||
SavedEntry old = savedEntries.get(name);
|
||||
if (old != null)
|
||||
{
|
||||
if (ent.getValue().type == type)
|
||||
{
|
||||
ret[x++] = ent.getIntKey();
|
||||
}
|
||||
}
|
||||
|
||||
return Arrays.copyOf(ret, x);
|
||||
}
|
||||
|
||||
public static Map<DimensionType, IntSortedSet> getRegisteredDimensions()
|
||||
{
|
||||
Map<DimensionType, IntSortedSet> map = new IdentityHashMap<>();
|
||||
for (Int2ObjectMap.Entry<DimensionData> entry : dimensions.int2ObjectEntrySet())
|
||||
{
|
||||
map.computeIfAbsent(entry.getValue().type, k -> new IntRBTreeSet()).add(entry.getIntKey());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static void init()
|
||||
{
|
||||
if (hasInit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hasInit = true;
|
||||
|
||||
registerDimension( 0, DimensionType.OVERWORLD);
|
||||
registerDimension(-1, DimensionType.NETHER);
|
||||
registerDimension( 1, DimensionType.THE_END);
|
||||
}
|
||||
|
||||
public static void registerDimension(int id, DimensionType type)
|
||||
{
|
||||
DimensionType.getById(type.getId()); //Check if type is invalid {will throw an error} No clue how it would be invalid tho...
|
||||
if (dimensions.containsKey(id))
|
||||
{
|
||||
throw new IllegalArgumentException(String.format("Failed to register dimension for id %d, One is already registered", id));
|
||||
}
|
||||
dimensions.put(id, new DimensionData(type));
|
||||
if (id >= 0)
|
||||
{
|
||||
dimensionMap.set(id);
|
||||
id = old.getId();
|
||||
if (!type.getRegistryName().equals(old.getType()))
|
||||
LOGGER.info(DIMMGR, "Changing ModDimension for '{}' from '{}' to '{}'", name.toString(), old.getType() == null ? null : old.getType().toString(), type.getRegistryName().toString());
|
||||
savedEntries.remove(name);
|
||||
}
|
||||
DimensionType instance = new DimensionType(id, "", name.getNamespace() + "/" + name.getPath(), type.getFactory(), type, data);
|
||||
REGISTRY.register(id, name, instance);
|
||||
LOGGER.info(DIMMGR, "Registered dimension {} of type {} and id {}", name.toString(), type.getRegistryName().toString(), id);
|
||||
}
|
||||
|
||||
/**
|
||||
* For unregistering a dimension when the save is changed (disconnected from a server or loaded a new save
|
||||
* Configures if the dimension will stay loaded in memory even if all chunks are unloaded.
|
||||
*
|
||||
* @param dim The dimension
|
||||
* @param value True to keep loaded, false to allow unloading
|
||||
* @return The old value for this dimension.
|
||||
*/
|
||||
public static void unregisterDimension(int id)
|
||||
public static boolean keepLoaded(DimensionType dim, boolean value)
|
||||
{
|
||||
if (!dimensions.containsKey(id))
|
||||
{
|
||||
throw new IllegalArgumentException(String.format("Failed to unregister dimension for id %d; No provider registered", id));
|
||||
}
|
||||
dimensions.remove(id);
|
||||
}
|
||||
|
||||
public static boolean isDimensionRegistered(int dim)
|
||||
{
|
||||
return dimensions.containsKey(dim);
|
||||
}
|
||||
|
||||
public static DimensionType getProviderType(int dim)
|
||||
{
|
||||
if (!dimensions.containsKey(dim))
|
||||
{
|
||||
throw new IllegalArgumentException(String.format("Could not get provider type for dimension %d, does not exist", dim));
|
||||
}
|
||||
return dimensions.get(dim).type;
|
||||
}
|
||||
|
||||
public static Dimension getProvider(int dim)
|
||||
{
|
||||
return getWorld(dim).dimension;
|
||||
}
|
||||
|
||||
public static Integer[] getIDs(boolean check)
|
||||
{
|
||||
if (check)
|
||||
{
|
||||
List<World> allWorlds = Lists.newArrayList(weakWorldMap.keySet());
|
||||
allWorlds.removeAll(worlds.values());
|
||||
for (ListIterator<World> li = allWorlds.listIterator(); li.hasNext(); )
|
||||
{
|
||||
World w = li.next();
|
||||
leakedWorlds.add(System.identityHashCode(w));
|
||||
}
|
||||
for (World w : allWorlds)
|
||||
{
|
||||
int leakCount = leakedWorlds.count(System.identityHashCode(w));
|
||||
if (leakCount == 5)
|
||||
{
|
||||
LOGGER.debug(DIMMGR,"The world {} ({}) may have leaked: first encounter (5 occurrences).\n", Integer.toHexString(System.identityHashCode(w)), w.getWorldInfo().getWorldName());
|
||||
}
|
||||
else if (leakCount % 5 == 0)
|
||||
{
|
||||
LOGGER.debug(DIMMGR,"The world {} ({}) may have leaked: seen {} times.\n", Integer.toHexString(System.identityHashCode(w)), w.getWorldInfo().getWorldName(), leakCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
return getIDs();
|
||||
}
|
||||
|
||||
public static Integer[] getIDs()
|
||||
{
|
||||
return worlds.keySet().toArray(new Integer[0]); // Only loaded dims, since usually used to cycle through loaded worlds
|
||||
}
|
||||
|
||||
public static Stream<Integer> getIDStream()
|
||||
{
|
||||
return worlds.keySet().stream();
|
||||
}
|
||||
|
||||
public static void setWorld(int id, @Nullable WorldServer world, MinecraftServer server)
|
||||
{
|
||||
if (world != null)
|
||||
{
|
||||
worlds.put(id, world);
|
||||
weakWorldMap.put(world, world);
|
||||
LOGGER.info(DIMMGR,"Loading dimension {} ({}) ({})", id, world.getWorldInfo().getWorldName(), world.getServer());
|
||||
}
|
||||
else
|
||||
{
|
||||
worlds.remove(id);
|
||||
LOGGER.info(DIMMGR,"Unloading dimension {}", id);
|
||||
}
|
||||
|
||||
ArrayList<WorldServer> tmp = new ArrayList<WorldServer>();
|
||||
if (worlds.get( 0) != null)
|
||||
tmp.add(worlds.get( 0));
|
||||
if (worlds.get(-1) != null)
|
||||
tmp.add(worlds.get(-1));
|
||||
if (worlds.get( 1) != null)
|
||||
tmp.add(worlds.get( 1));
|
||||
|
||||
for (Int2ObjectMap.Entry<WorldServer> entry : worlds.int2ObjectEntrySet())
|
||||
{
|
||||
int dim = entry.getIntKey();
|
||||
if (dim >= -1 && dim <= 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
tmp.add(entry.getValue());
|
||||
}
|
||||
|
||||
server.worlds = tmp.toArray(new WorldServer[0]);
|
||||
}
|
||||
|
||||
public static void initDimension(int dim)
|
||||
{
|
||||
WorldServer overworld = getWorld(0);
|
||||
if (overworld == null)
|
||||
{
|
||||
throw new RuntimeException("Cannot Hotload Dim: Overworld is not Loaded!");
|
||||
}
|
||||
try
|
||||
{
|
||||
DimensionManager.getProviderType(dim);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error(DIMMGR,"Cannot Hotload Dim: {}", dim, e);
|
||||
return; // If a provider hasn't been registered then we can't hotload the dim
|
||||
}
|
||||
MinecraftServer mcServer = overworld.getServer();
|
||||
ISaveHandler savehandler = overworld.getSaveHandler();
|
||||
//WorldSettings worldSettings = new WorldSettings(overworld.getWorldInfo());
|
||||
|
||||
WorldServer world = (dim == 0 ? overworld : (WorldServer)(new WorldServerMulti(mcServer, savehandler, dim, overworld, mcServer.profiler).init()));
|
||||
world.addEventListener(new ServerWorldEventHandler(mcServer, world));
|
||||
MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
|
||||
if (!mcServer.isSinglePlayer())
|
||||
{
|
||||
world.getWorldInfo().setGameType(mcServer.getGameType());
|
||||
}
|
||||
|
||||
mcServer.setDifficultyForAllWorlds(mcServer.getDifficulty());
|
||||
}
|
||||
|
||||
public static WorldServer getWorld(int id)
|
||||
{
|
||||
return getWorld(id, false);
|
||||
}
|
||||
|
||||
public static WorldServer getWorld(int id, boolean resetUnloadDelay)
|
||||
{
|
||||
return getWorld(id, resetUnloadDelay, false);
|
||||
}
|
||||
|
||||
public static WorldServer getWorld(int id, boolean resetUnloadDelay, boolean forceLoad)
|
||||
{
|
||||
if (resetUnloadDelay && unloadQueue.contains(id))
|
||||
{
|
||||
dimensions.get(id).ticksWaited = 0;
|
||||
}
|
||||
WorldServer ret = worlds.get(id);
|
||||
if (ret == null && forceLoad)
|
||||
{
|
||||
initDimension(id);
|
||||
ret = worlds.get(id);
|
||||
}
|
||||
Validate.notNull(dim, "Dimension type must not be null");
|
||||
Data data = getData(dim);
|
||||
boolean ret = data.keepLoaded;
|
||||
data.keepLoaded = value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static WorldServer[] getWorlds()
|
||||
/**
|
||||
* Determines if the dimension will stay loaded in memory even if all chunks are unloaded.
|
||||
* @param dim The dimension
|
||||
* @return True if the dimension will stay loaded with no chunks loaded.
|
||||
*/
|
||||
public static boolean keepLoaded(DimensionType dim)
|
||||
{
|
||||
return worlds.values().toArray(new WorldServer[0]);
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
init();
|
||||
Validate.notNull(dim, "Dimension type must not be null");
|
||||
Data data = dimensions.get(dim.getId());
|
||||
return data == null ? false : data.keepLoaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not public API: used internally to get dimensions that should load at
|
||||
* server startup
|
||||
* Retrieves the world from the server allowing for null return, and optionally resetting it's unload timer.
|
||||
*
|
||||
* @param server The server that controlls this world.
|
||||
* @param dim Dimension to load.
|
||||
* @param resetUnloadDelay True to reset the unload timer, which is a delay that is used to prevent constant world loading/unloading cycle.
|
||||
* @param forceLoad True to attempt to load the dimension if the server has it unloaded.
|
||||
* @return The world, null if unloaded and not loadable.
|
||||
*/
|
||||
public static Integer[] getStaticDimensionIDs()
|
||||
@Nullable
|
||||
public static WorldServer getWorld(MinecraftServer server, DimensionType dim, boolean resetUnloadDelay, boolean forceLoad)
|
||||
{
|
||||
return dimensions.keySet().toArray(new Integer[0]);
|
||||
Validate.notNull(server, "Must provide server when creating world");
|
||||
Validate.notNull(dim, "Dimension type must not be null");
|
||||
|
||||
if (resetUnloadDelay && unloadQueue.contains(dim.getId()))
|
||||
getData(dim).ticksWaited = 0;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
WorldServer ret = server.forgeGetWorldMap().get(dim);
|
||||
if (ret == null && forceLoad)
|
||||
ret = initWorld(server, dim);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Dimension createProviderFor(int dim)
|
||||
//==========================================================================================================
|
||||
// FORGE INTERNAL
|
||||
//==========================================================================================================
|
||||
|
||||
public static void unregisterDimension(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dimensions.containsKey(dim))
|
||||
{
|
||||
Dimension ret = getProviderType(dim).create();
|
||||
ret.setId(dim);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException(String.format("No WorldProvider bound for dimension %d", dim)); //It's going to crash anyway at this point. Might as well be informative
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error(DIMMGR,"An error occurred trying to create an instance of WorldProvider {} ({})",
|
||||
dim, getProviderType(dim), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Validate.isTrue(dimensions.containsKey(id), String.format("Failed to unregister dimension for id %d; No provider registered", id));
|
||||
dimensions.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if a dimension should stay loaded.
|
||||
* @param dim the dimension ID
|
||||
* @param keep whether or not the dimension should be kept loaded
|
||||
* @return true iff the dimension's status changed
|
||||
*/
|
||||
public static boolean keepDimensionLoaded(int dim, boolean keep)
|
||||
public static void registerDimensionInternal(int id, ResourceLocation name, ModDimension type, PacketBuffer data)
|
||||
{
|
||||
return keep ? keepLoaded.add(dim) : keepLoaded.remove(dim);
|
||||
Validate.notNull(name, "Can not register a dimesnion with null name");
|
||||
Validate.notNull(type, "Can not register a null dimension type");
|
||||
Validate.isTrue(!REGISTRY.func_212607_c(name), "Dimension: " + name + " Already registered");
|
||||
Validate.isTrue(REGISTRY.get(id) == null, "Dimension with id " + id + " already registered as name " + REGISTRY.getKey(REGISTRY.get(id)));
|
||||
|
||||
DimensionType instance = new DimensionType(id, "", name.getNamespace() + "/" + name.getPath(), type.getFactory(), type, data);
|
||||
REGISTRY.register(id, name, instance);
|
||||
LOGGER.info(DIMMGR, "Registered dimension {} of type {} and id {}", name.toString(), type.getRegistryName().toString(), id);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static WorldServer initWorld(MinecraftServer server, DimensionType dim)
|
||||
{
|
||||
Validate.isTrue(dim != DimensionType.OVERWORLD, "Can not hotload overworld. This must be loaded at all times by main Server.");
|
||||
Validate.notNull(server, "Must provide server when creating world");
|
||||
Validate.notNull(dim, "Must provide dimension when creating world");
|
||||
|
||||
WorldServer overworld = getWorld(server, DimensionType.OVERWORLD, false, false);
|
||||
Validate.notNull(overworld, "Cannot Hotload Dim: Overworld is not Loaded!");
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
WorldServer world = new WorldServerMulti(server, overworld.getSaveHandler(), dim, overworld, server.profiler).func_212251_i__();
|
||||
world.addEventListener(new ServerWorldEventHandler(server, world));
|
||||
if (!server.isSinglePlayer())
|
||||
world.getWorldInfo().setGameType(server.getGameType());
|
||||
server.forgeGetWorldMap().put(dim, world);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
|
||||
|
||||
server.setDifficultyForAllWorlds(server.getDifficulty());
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
private static boolean canUnloadWorld(WorldServer world)
|
||||
{
|
||||
return ForgeChunkManager.getPersistentChunksFor(world).isEmpty()
|
||||
return world.func_212412_ag().isEmpty()
|
||||
&& world.playerEntities.isEmpty()
|
||||
&& !world.dimension.getType().shouldLoadSpawn()
|
||||
&& !keepLoaded.contains(world.dimension.getId());
|
||||
//&& !world.dimension.getType().shouldLoadSpawn()
|
||||
&& !getData(world.getDimension().getType()).keepLoaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queues a dimension to unload, if it can be unloaded.
|
||||
* @param id The id of the dimension
|
||||
*/
|
||||
public static void unloadWorld(int id)
|
||||
public static void unloadWorld(WorldServer world)
|
||||
{
|
||||
WorldServer world = worlds.get(id);
|
||||
if (world == null || !canUnloadWorld(world)) return;
|
||||
if (world == null || !canUnloadWorld(world))
|
||||
return;
|
||||
|
||||
int id = world.getDimension().getType().getId();
|
||||
if (unloadQueue.add(id))
|
||||
{
|
||||
LOGGER.debug(DIMMGR,"Queueing dimension {} to unload", id);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWorldQueuedToUnload(int id)
|
||||
{
|
||||
return unloadQueue.contains(id);
|
||||
}
|
||||
|
||||
/*
|
||||
* To be called by the server at the appropriate time, do not call from mod code.
|
||||
*/
|
||||
public static void unloadWorlds()
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void unloadWorlds(MinecraftServer server, boolean checkLeaks)
|
||||
{
|
||||
IntIterator queueIterator = unloadQueue.iterator();
|
||||
while (queueIterator.hasNext())
|
||||
{
|
||||
int id = queueIterator.nextInt();
|
||||
DimensionData dimension = dimensions.get(id);
|
||||
DimensionType dim = DimensionType.getById(id);
|
||||
|
||||
if (dim == null)
|
||||
{
|
||||
LOGGER.warn(DIMMGR, "Dimension with unknown type '{}' added to unload queue, removing", id);
|
||||
queueIterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
Data dimension = dimensions.computeIfAbsent(id, k -> new Data());
|
||||
if (dimension.ticksWaited < ForgeConfig.SERVER.dimensionUnloadQueueDelay.get())
|
||||
{
|
||||
dimension.ticksWaited++;
|
||||
continue;
|
||||
}
|
||||
WorldServer w = worlds.get(id);
|
||||
|
||||
queueIterator.remove();
|
||||
|
||||
WorldServer w = server.forgeGetWorldMap().get(dim);
|
||||
|
||||
dimension.ticksWaited = 0;
|
||||
// Don't unload the world if the status changed
|
||||
if (w == null || !canUnloadWorld(w))
|
||||
@@ -420,97 +273,179 @@ public class DimensionManager
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(w));
|
||||
w.close();
|
||||
setWorld(id, null, w.getServer());
|
||||
server.forgeGetWorldMap().remove(dim);
|
||||
}
|
||||
}
|
||||
|
||||
if (checkLeaks)
|
||||
{
|
||||
List<World> allWorlds = Lists.newArrayList(weakWorldMap.keySet());
|
||||
allWorlds.removeAll(server.forgeGetWorldMap().values());
|
||||
allWorlds.stream().map(System::identityHashCode).forEach(leakedWorlds::add);
|
||||
|
||||
for (World w : allWorlds)
|
||||
{
|
||||
int hash = System.identityHashCode(w);
|
||||
int leakCount = leakedWorlds.count(hash);
|
||||
if (leakCount == 5)
|
||||
LOGGER.debug(DIMMGR,"The world {} ({}) may have leaked: first encounter (5 occurrences).\n", Integer.toHexString(hash), w.getWorldInfo().getWorldName());
|
||||
else if (leakCount % 5 == 0)
|
||||
LOGGER.debug(DIMMGR,"The world {} ({}) may have leaked: seen {} times.\n", Integer.toHexString(hash), w.getWorldInfo().getWorldName(), leakCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the next free dimension ID. Note: you are not guaranteed a contiguous
|
||||
* block of free ids. Always call for each individual ID you wish to get.
|
||||
* @return the next free dimension ID
|
||||
*/
|
||||
public static int getNextFreeDimId() {
|
||||
int next = 0;
|
||||
while (true)
|
||||
public static void writeRegistry(NBTTagCompound data)
|
||||
{
|
||||
data.setInt("version", 1);
|
||||
List<SavedEntry> list = new ArrayList<>();
|
||||
for (DimensionType type : REGISTRY)
|
||||
list.add(new SavedEntry(type));
|
||||
savedEntries.values().forEach(list::add);
|
||||
|
||||
Collections.sort(list, (a, b) -> a.id - b.id);
|
||||
NBTTagList lst = new NBTTagList();
|
||||
list.forEach(e -> lst.add(e.write()));
|
||||
|
||||
data.setTag("entries", lst);
|
||||
}
|
||||
|
||||
public static void readRegistry(NBTTagCompound data)
|
||||
{
|
||||
int version = data.getInt("version");
|
||||
if (version != 1)
|
||||
throw new IllegalStateException("Attempted to load world with unknown Dimension data format: " + version);
|
||||
|
||||
LOGGER.debug(DIMMGR, "Reading Dimension Entries.");
|
||||
Map<ResourceLocation, DimensionType> vanilla = REGISTRY.stream().filter(DimensionType::isVanilla).collect(Collectors.toMap(REGISTRY::getKey, v -> v));
|
||||
REGISTRY.clear();
|
||||
vanilla.forEach((key, value) -> {
|
||||
LOGGER.debug(DIMMGR, "Registering vanilla entry ID: {} Name: {} Value: {}", value.getId() + 1, key.toString(), value.toString());
|
||||
REGISTRY.register(value.getId() + 1, key, value);
|
||||
});
|
||||
|
||||
savedEntries.clear();
|
||||
|
||||
boolean error = false;
|
||||
NBTTagList list = data.getList("entries", 10);
|
||||
for (int x = 0; x < list.size(); x++)
|
||||
{
|
||||
next = dimensionMap.nextClearBit(next);
|
||||
if (dimensions.containsKey(next))
|
||||
SavedEntry entry = new SavedEntry(list.getCompound(x));
|
||||
if (entry.type == null)
|
||||
{
|
||||
dimensionMap.set(next);
|
||||
DimensionType type = REGISTRY.func_212608_b(entry.name);
|
||||
if (type == null)
|
||||
{
|
||||
LOGGER.error(DIMMGR, "Vanilla entry '{}' id {} in save file not found in registry.", entry.name.toString(), entry.id);
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
int id = REGISTRY.getId(type);
|
||||
if (id != entry.id)
|
||||
{
|
||||
LOGGER.error(DIMMGR, "Vanilla entry '{}' id {} in save file has incorrect in {} in registry.", entry.name.toString(), entry.id, id);
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static NBTTagCompound saveDimensionDataMap()
|
||||
{
|
||||
int[] data = new int[(dimensionMap.length() + Integer.SIZE - 1 )/ Integer.SIZE];
|
||||
NBTTagCompound dimMap = new NBTTagCompound();
|
||||
for (int i = 0; i < data.length; i++)
|
||||
{
|
||||
int val = 0;
|
||||
for (int j = 0; j < Integer.SIZE; j++)
|
||||
{
|
||||
val |= dimensionMap.get(i * Integer.SIZE + j) ? (1 << j) : 0;
|
||||
}
|
||||
data[i] = val;
|
||||
}
|
||||
dimMap.setIntArray("DimensionArray", data);
|
||||
return dimMap;
|
||||
}
|
||||
|
||||
public static void loadDimensionDataMap(@Nullable NBTTagCompound compoundTag)
|
||||
{
|
||||
dimensionMap.clear();
|
||||
if (compoundTag == null)
|
||||
{
|
||||
IntIterator iterator = dimensions.keySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
int id = iterator.nextInt();
|
||||
if (id >= 0)
|
||||
ModDimension mod = ForgeRegistries.MOD_DIMENSIONS.getValue(entry.type);
|
||||
if (mod == null)
|
||||
{
|
||||
dimensionMap.set(id);
|
||||
LOGGER.error(DIMMGR, "Modded dimension entry '{}' id {} in save file missing ModDimension.", entry.name.toString(), entry.id, entry.type.toString());
|
||||
savedEntries.put(entry.name, entry);
|
||||
continue;
|
||||
}
|
||||
registerDimensionInternal(entry.id, entry.name, mod, entry.data == null ? null : new PacketBuffer(Unpooled.wrappedBuffer(entry.data)));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
//Allow modders to register dimensions/claim the missing.
|
||||
MinecraftForge.EVENT_BUS.post(new RegisterDimensionsEvent(savedEntries));
|
||||
|
||||
if (!savedEntries.isEmpty())
|
||||
{
|
||||
int[] intArray = compoundTag.getIntArray("DimensionArray");
|
||||
for (int i = 0; i < intArray.length; i++)
|
||||
{
|
||||
for (int j = 0; j < Integer.SIZE; j++)
|
||||
{
|
||||
dimensionMap.set(i * Integer.SIZE + j, (intArray[i] & (1 << j)) != 0);
|
||||
}
|
||||
}
|
||||
savedEntries.values().forEach(entry -> {
|
||||
LOGGER.warn(DIMMGR, "Missing Dimension Name: '{}' Id: {} Type: '{}", entry.name.toString(), entry.id, entry.type.toString());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current root directory for the world save. Accesses getSaveHandler from the overworld
|
||||
* @return the root directory of the save
|
||||
*/
|
||||
@Nullable
|
||||
public static File getCurrentSaveRootDirectory()
|
||||
@Deprecated //Forge: Internal use only.
|
||||
public static IRegistry<DimensionType> getRegistry()
|
||||
{
|
||||
if (DimensionManager.getWorld(0) != null)
|
||||
return REGISTRY;
|
||||
}
|
||||
|
||||
private static Data getData(DimensionType dim)
|
||||
{
|
||||
return dimensions.computeIfAbsent(dim.getId(), k -> new Data());
|
||||
}
|
||||
|
||||
private static class Data
|
||||
{
|
||||
int ticksWaited = 0;
|
||||
boolean keepLoaded = false;
|
||||
}
|
||||
|
||||
public static class SavedEntry
|
||||
{
|
||||
int id;
|
||||
ResourceLocation name;
|
||||
ResourceLocation type;
|
||||
byte[] data;
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return DimensionManager.getWorld(0).getSaveHandler().getWorldDirectory();
|
||||
}/*
|
||||
else if (MinecraftServer.getServer() != null)
|
||||
return id;
|
||||
}
|
||||
|
||||
public ResourceLocation getName()
|
||||
{
|
||||
MinecraftServer srv = MinecraftServer.getServer();
|
||||
SaveHandler saveHandler = (SaveHandler) srv.getActiveAnvilConverter().getSaveLoader(srv.getFolderName(), false);
|
||||
return saveHandler.getWorldDirectory();
|
||||
}*/
|
||||
else
|
||||
return name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ResourceLocation getType()
|
||||
{
|
||||
return null;
|
||||
return type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public byte[] getData()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
private SavedEntry(NBTTagCompound data)
|
||||
{
|
||||
this.id = data.getInt("id");
|
||||
this.name = new ResourceLocation(data.getString("name"));
|
||||
this.type = data.contains("type", 8) ? new ResourceLocation(data.getString("type")) : null;
|
||||
this.data = data.contains("data", 7) ? data.getByteArray("data") : null;
|
||||
}
|
||||
|
||||
private SavedEntry(DimensionType data)
|
||||
{
|
||||
this.id = REGISTRY.getId(data);
|
||||
this.name = REGISTRY.getKey(data);
|
||||
if (data.getModType() != null)
|
||||
this.type = data.getModType().getRegistryName();
|
||||
if (data.getData() != null)
|
||||
this.data = data.getData().array();
|
||||
}
|
||||
|
||||
private NBTTagCompound write()
|
||||
{
|
||||
NBTTagCompound ret = new NBTTagCompound();
|
||||
ret.setInt("id", id);
|
||||
ret.setString("name", name.toString());
|
||||
if (type != null)
|
||||
ret.setString("type", type.toString());
|
||||
if (data != null)
|
||||
ret.setByteArray("data", data);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,74 +41,74 @@ public class ForgeConfig
|
||||
public static class Server {
|
||||
public final BooleanValue removeErroringEntities;
|
||||
public final BooleanValue removeErroringTileEntities;
|
||||
|
||||
|
||||
public final BooleanValue fullBoundingBoxLadders;
|
||||
|
||||
|
||||
public final DoubleValue zombieBaseSummonChance;
|
||||
public final DoubleValue zombieBabyChance;
|
||||
|
||||
|
||||
public final BooleanValue logCascadingWorldGeneration;
|
||||
public final BooleanValue fixVanillaCascading;
|
||||
|
||||
|
||||
public final IntValue dimensionUnloadQueueDelay;
|
||||
|
||||
|
||||
public final IntValue clumpingThreshold;
|
||||
|
||||
|
||||
Server(ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("Server configuration settings")
|
||||
.push("server");
|
||||
|
||||
|
||||
removeErroringEntities = builder
|
||||
.comment("Set this to true to remove any Entity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES.")
|
||||
.translation("forge.configgui.removeErroringEntities")
|
||||
.worldRestart()
|
||||
.define("removeErroringEntities", false);
|
||||
|
||||
|
||||
removeErroringTileEntities = builder
|
||||
.comment("Set this to true to remove any TileEntity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES.")
|
||||
.translation("forge.configgui.removeErroringTileEntities")
|
||||
.worldRestart()
|
||||
.define("removeErroringTileEntities", false);
|
||||
|
||||
|
||||
fullBoundingBoxLadders = builder
|
||||
.comment("Set this to true to check the entire entity's collision bounding box for ladders instead of just the block they are in. Causes noticeable differences in mechanics so default is vanilla behavior. Default: false")
|
||||
.translation("forge.configgui.fullBoundingBoxLadders")
|
||||
.worldRestart()
|
||||
.define("fullBoundingBoxLadders", false);
|
||||
|
||||
|
||||
zombieBaseSummonChance = builder
|
||||
.comment("Base zombie summoning spawn chance. Allows changing the bonus zombie summoning mechanic.")
|
||||
.translation("forge.configgui.zombieBaseSummonChance")
|
||||
.worldRestart()
|
||||
.defineInRange("zombieBaseSummonChance", 0.1D, 0.0D, 1.0D);
|
||||
|
||||
|
||||
zombieBabyChance = builder
|
||||
.comment("Chance that a zombie (or subclass) is a baby. Allows changing the zombie spawning mechanic.")
|
||||
.translation("forge.configgui.zombieBabyChance")
|
||||
.worldRestart()
|
||||
.defineInRange("zombieBabyChance", 0.05D, 0.0D, 1.0D);
|
||||
|
||||
|
||||
logCascadingWorldGeneration = builder
|
||||
.comment("Log cascading chunk generation issues during terrain population.")
|
||||
.translation("forge.configgui.logCascadingWorldGeneration")
|
||||
.define("logCascadingWorldGeneration", true);
|
||||
|
||||
|
||||
fixVanillaCascading = builder
|
||||
.comment("Fix vanilla issues that cause worldgen cascading. This DOES change vanilla worldgen so DO NOT report bugs related to world differences if this flag is on.")
|
||||
.translation("forge.configgui.fixVanillaCascading")
|
||||
.define("fixVanillaCascading", false);
|
||||
|
||||
|
||||
dimensionUnloadQueueDelay = builder
|
||||
.comment("The time in ticks the server will wait when a dimension was queued to unload. This can be useful when rapidly loading and unloading dimensions, like e.g. throwing items through a nether portal a few time per second.")
|
||||
.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);
|
||||
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
}
|
||||
@@ -120,55 +120,55 @@ public class ForgeConfig
|
||||
public final BooleanValue zoomInMissingModelTextInGui;
|
||||
|
||||
public final BooleanValue forgeCloudsEnabled;
|
||||
|
||||
|
||||
public final BooleanValue disableStairSlabCulling;
|
||||
|
||||
public final BooleanValue alwaysSetupTerrainOffThread;
|
||||
|
||||
public final BooleanValue forgeLightPipelineEnabled;
|
||||
|
||||
|
||||
public final BooleanValue selectiveResourceReloadEnabled;
|
||||
|
||||
|
||||
Client(ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("Client only settings, mostly things related to rendering")
|
||||
.push("client");
|
||||
|
||||
|
||||
zoomInMissingModelTextInGui = builder
|
||||
.comment("Toggle off to make missing model text in the gui fit inside the slot.")
|
||||
.translation("forge.configgui.zoomInMissingModelTextInGui")
|
||||
.define("zoomInMissingModelTextInGui", false);
|
||||
|
||||
|
||||
forgeCloudsEnabled = builder
|
||||
.comment("Enable uploading cloud geometry to the GPU for faster rendering.")
|
||||
.translation("forge.configgui.forgeCloudsEnabled")
|
||||
.define("forgeCloudsEnabled", true);
|
||||
|
||||
|
||||
disableStairSlabCulling = builder
|
||||
.comment("Disable culling of hidden faces next to stairs and slabs. Causes extra rendering, but may fix some resource packs that exploit this vanilla mechanic.")
|
||||
.translation("forge.configgui.disableStairSlabCulling")
|
||||
.define("disableStairSlabCulling", false);
|
||||
|
||||
alwaysSetupTerrainOffThread = builder
|
||||
|
||||
alwaysSetupTerrainOffThread = builder
|
||||
.comment("Enable forge to queue all chunk updates to the Chunk Update thread.",
|
||||
"May increase FPS significantly, but may also cause weird rendering lag.",
|
||||
"Not recommended for computers without a significant number of cores available.")
|
||||
.translation("forge.configgui.alwaysSetupTerrainOffThread")
|
||||
.define("alwaysSetupTerrainOffThread", false);
|
||||
|
||||
|
||||
forgeLightPipelineEnabled = builder
|
||||
.comment("Enable the forge block rendering pipeline - fixes the lighting of custom models.")
|
||||
.translation("forge.configgui.forgeLightPipelineEnabled")
|
||||
.define("forgeLightPipelineEnabled", true);
|
||||
|
||||
|
||||
selectiveResourceReloadEnabled = builder
|
||||
.comment("When enabled, makes specific reload tasks such as language changing quicker to run.")
|
||||
.translation("forge.configgui.selectiveResourceReloadEnabled")
|
||||
.define("selectiveResourceReloadEnabled", true);
|
||||
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static final ForgeConfigSpec clientSpec;
|
||||
public static final Client CLIENT;
|
||||
static {
|
||||
|
||||
@@ -101,6 +101,7 @@ import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
@@ -749,7 +750,7 @@ public class ForgeHooks
|
||||
return stack.isEmpty() || !stack.getItem().onLeftClickEntity(stack, player, target);
|
||||
}
|
||||
|
||||
public static boolean onTravelToDimension(Entity entity, int dimension)
|
||||
public static boolean onTravelToDimension(Entity entity, DimensionType dimension)
|
||||
{
|
||||
EntityTravelToDimensionEvent event = new EntityTravelToDimensionEvent(entity, dimension);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
@@ -1100,7 +1101,7 @@ public class ForgeHooks
|
||||
return event.getVanillaNoteId();
|
||||
}
|
||||
|
||||
public static int canEntitySpawn(EntityLiving entity, IWorld world, float x, float y, float z, MobSpawnerBaseLogic spawner) {
|
||||
public static int canEntitySpawn(EntityLiving entity, IWorld world, double x, double y, double z, MobSpawnerBaseLogic spawner) {
|
||||
Result res = ForgeEventFactory.canEntitySpawn(entity, world, x, y, z, null);
|
||||
return res == Result.DEFAULT ? 0 : res == Result.DENY ? -1 : 1;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
public static boolean forgeLightPipelineEnabled = true;
|
||||
public static boolean zoomInMissingModelTextInGui = false;
|
||||
public static boolean disableStairSlabCulling = false; // Also known as the "DontCullStairsBecauseIUseACrappyTexturePackThatBreaksBasicBlockShapesSoICantTrustBasicBlockCulling" flag
|
||||
public static boolean alwaysSetupTerrainOffThread = false; // In RenderGlobal.setupTerrain, always force the chunk render updates to be queued to the thread
|
||||
public static boolean alwaysSetupTerrainOffThread = false; // In WorldRenderer.setupTerrain, always force the chunk render updates to be queued to the thread
|
||||
public static boolean logCascadingWorldGeneration = true; // see Chunk#logCascadingWorldGeneration()
|
||||
public static boolean fixVanillaCascading = false; // There are various places in vanilla that cause cascading worldgen. Enabling this WILL change where blocks are placed to prevent this.
|
||||
// DO NOT contact Forge about worldgen not 'matching' vanilla if this flag is set.
|
||||
@@ -130,7 +130,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
|
||||
public void playerLogin(PlayerEvent.PlayerLoggedInEvent event)
|
||||
{
|
||||
UsernameCache.setUsername(event.player.getUniqueID(), event.player.getGameProfile().getName());
|
||||
UsernameCache.setUsername(event.getPlayer().getUniqueID(), event.getPlayer().getGameProfile().getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -204,8 +204,10 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info)
|
||||
{
|
||||
NBTTagCompound forgeData = new NBTTagCompound();
|
||||
NBTTagCompound dimData = DimensionManager.saveDimensionDataMap();
|
||||
forgeData.setTag("DimensionData", dimData);
|
||||
NBTTagCompound dims = new NBTTagCompound();
|
||||
DimensionManager.writeRegistry(dims);
|
||||
if (!dims.isEmpty())
|
||||
forgeData.setTag("dims", dims);
|
||||
// TODO fluids FluidRegistry.writeDefaultFluidList(forgeData);
|
||||
return forgeData;
|
||||
}
|
||||
@@ -213,7 +215,8 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
@Override
|
||||
public void readData(SaveHandler handler, WorldInfo info, NBTTagCompound tag)
|
||||
{
|
||||
DimensionManager.loadDimensionDataMap(tag.hasKey("DimensionData") ? tag.getCompound("DimensionData") : null);
|
||||
if (tag.contains("dims", 10))
|
||||
DimensionManager.readRegistry(tag.getCompound("dims"));
|
||||
// TODO fluids FluidRegistry.loadFluidDefaults(tag);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.common;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
|
||||
/**
|
||||
* In 1.13.2, Mojang made DimensionType as the unique holder/identifier for each Dimension.
|
||||
* We used to be able to create custom Dimensions separate from DimensionType.
|
||||
* But now that they are hard linked to a single instance, this is the new class that
|
||||
* defines the 'template' for new dimensions.
|
||||
*/
|
||||
public abstract class ModDimension extends ForgeRegistryEntry<ModDimension>
|
||||
{
|
||||
public abstract Function<DimensionType, ? extends Dimension> getFactory();
|
||||
|
||||
/**
|
||||
* Serialize any necessary data, this is called both when saving the world on the server.
|
||||
* And when sent over the network to the client.
|
||||
*
|
||||
* @param buffer The data buffer to write to.
|
||||
* @param network true when sent over the network, so you can only data needed by the client.
|
||||
*/
|
||||
public void write(PacketBuffer buffer, boolean network){}
|
||||
|
||||
/**
|
||||
* Deserialize any necessary data, this is called both when saving the world on the server.
|
||||
* And when sent over the network to the client.
|
||||
*
|
||||
* @param buffer The data buffer to write to.
|
||||
* @param network true when sent over the network, so you can only data needed by the client.
|
||||
*/
|
||||
public void read(PacketBuffer buffer, boolean network){}
|
||||
}
|
||||
@@ -1,113 +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.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
|
||||
import net.minecraft.world.chunk.storage.IChunkLoader;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.gen.feature.template.TemplateManager;
|
||||
import net.minecraft.world.storage.IPlayerFileData;
|
||||
import net.minecraft.world.storage.ISaveHandler;
|
||||
import net.minecraft.world.storage.SessionLockException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
//Class used internally to provide the world specific data directories.
|
||||
|
||||
public class WorldSpecificSaveHandler implements ISaveHandler
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private WorldServer world;
|
||||
private ISaveHandler parent;
|
||||
private File dataDir;
|
||||
|
||||
public WorldSpecificSaveHandler(WorldServer world, ISaveHandler parent)
|
||||
{
|
||||
this.world = world;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override public WorldInfo loadWorldInfo() { return parent.loadWorldInfo(); }
|
||||
@Override public void checkSessionLock() throws SessionLockException { parent.checkSessionLock(); }
|
||||
@Override public IChunkLoader getChunkLoader(Dimension var1) { return parent.getChunkLoader(var1); }
|
||||
@Override public void saveWorldInfoWithPlayer(WorldInfo var1, NBTTagCompound var2) { parent.saveWorldInfoWithPlayer(var1, var2); }
|
||||
@Override public void saveWorldInfo(WorldInfo var1){ parent.saveWorldInfo(var1); }
|
||||
@Override public IPlayerFileData getPlayerNBTManager() { return parent.getPlayerNBTManager(); }
|
||||
@Override public void flush() { parent.flush(); }
|
||||
@Override public File getWorldDirectory() { return parent.getWorldDirectory(); }
|
||||
@Override public DataFixer getFixer() { return parent.getFixer(); }
|
||||
|
||||
@Override
|
||||
public File getMapFileFromName(String name)
|
||||
{
|
||||
if (dataDir == null) //Delayed down here do that world has time to be initialized first.
|
||||
{
|
||||
dataDir = new File(world.getChunkSaveLocation(), "data");
|
||||
dataDir.mkdirs();
|
||||
}
|
||||
File file = new File(dataDir, name + ".dat");
|
||||
if (!file.exists())
|
||||
{
|
||||
switch (world.dimension.getId())
|
||||
{
|
||||
case -1:
|
||||
if (name.equalsIgnoreCase("FORTRESS")) copyFile(name, file);
|
||||
break;
|
||||
case 1:
|
||||
if (name.equalsIgnoreCase("VILLAGES_END")) copyFile(name, file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
private void copyFile(String name, File to)
|
||||
{
|
||||
File parentFile = parent.getMapFileFromName(name);
|
||||
if (parentFile.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
Files.copy(parentFile, to);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.error("A critical error occurred copying {} to world specific dat folder - new file will be created.", parentFile.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateManager getStructureTemplateManager()
|
||||
{
|
||||
return parent.getStructureTemplateManager();
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import com.google.common.collect.Maps;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.gen.ChunkProviderServer;
|
||||
|
||||
public class ChunkIOExecutor
|
||||
@@ -124,7 +125,7 @@ public class ChunkIOExecutor
|
||||
ChunkIOProvider task = tasks.get(key);
|
||||
if (task == null)
|
||||
{
|
||||
LOGGER.warn("Attempted to dequeue chunk that wasn't queued? {} @ ({}, {})", world.dimension.getId(), x, z);
|
||||
LOGGER.warn("Attempted to dequeue chunk that wasn't queued? {} @ ({}, {})", DimensionType.func_212678_a(world.dimension.getType()).toString(), x, z);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package net.minecraftforge.common.chunkio;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
class QueuedChunk {
|
||||
final int x;
|
||||
@@ -57,7 +58,7 @@ class QueuedChunk {
|
||||
result.append(" x: " + x + NEW_LINE);
|
||||
result.append(" z: " + z + NEW_LINE);
|
||||
result.append(" world: " + world.getWorldInfo().getWorldName() + NEW_LINE);
|
||||
result.append(" dimension: " + world.dimension.getId() + NEW_LINE);
|
||||
result.append(" dimension: " + DimensionType.func_212678_a(world.dimension.getType()).toString() + NEW_LINE);
|
||||
result.append(" provider: " + world.dimension.getClass().getName() + NEW_LINE);
|
||||
result.append("}");
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
|
||||
@@ -26,7 +26,7 @@ import javax.annotation.Nullable;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
@@ -24,6 +24,7 @@ import javax.annotation.Nullable;
|
||||
import net.minecraft.client.audio.MusicTicker;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@@ -31,6 +32,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.dimension.NetherDimension;
|
||||
import net.minecraft.world.dimension.OverworldDimension;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
@@ -44,7 +46,7 @@ public interface IForgeDimension
|
||||
{
|
||||
return (Dimension) this;
|
||||
}
|
||||
|
||||
|
||||
World getWorld();
|
||||
|
||||
/**
|
||||
@@ -81,7 +83,7 @@ public interface IForgeDimension
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this method returns true, then chunks received by the client will
|
||||
* have {@link net.minecraft.world.chunk.Chunk#resetRelightChecks} called
|
||||
@@ -98,17 +100,6 @@ public interface IForgeDimension
|
||||
return !(this instanceof OverworldDimension);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the providers current dimension ID, used in default getSaveFolder()
|
||||
* Added to allow default providers to be registered for multiple dimensions.
|
||||
* This is to denote the exact dimension ID opposed to the 'type' in WorldType
|
||||
*
|
||||
* @param id Dimension ID
|
||||
*/
|
||||
void setId(int id);
|
||||
|
||||
int getId();
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Nullable
|
||||
IRenderHandler getSkyRenderer();
|
||||
@@ -129,7 +120,7 @@ public interface IForgeDimension
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
void setWeatherRenderer(IRenderHandler renderer);
|
||||
|
||||
|
||||
/**
|
||||
* Allows for manipulating the coloring of the lightmap texture.
|
||||
* Will be called for each 16*16 combination of sky/block light values.
|
||||
@@ -140,7 +131,7 @@ public interface IForgeDimension
|
||||
* @param blockLight Block light brightness factor.
|
||||
* @param colors The color values that will be used: [r, g, b].
|
||||
*
|
||||
* @see net.minecraft.client.renderer.EntityRenderer#updateLightmap(float)
|
||||
* @see net.minecraft.client.renderer.GameRenderer#updateLightmap(float)
|
||||
*/
|
||||
default void getLightmapColors(float partialTicks, float sunBrightness, float skyLight, float blockLight, float[] colors) {}
|
||||
|
||||
@@ -167,7 +158,7 @@ public interface IForgeDimension
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines if the player can sleep in this world (or if the bed should explode for example).
|
||||
*
|
||||
@@ -316,11 +307,6 @@ public interface IForgeDimension
|
||||
return getWorld().getWorldInfo().getTerrainType().getHorizon(getWorld());
|
||||
}
|
||||
|
||||
default String getSaveFolder()
|
||||
{
|
||||
return getId() == 0 ? null : "DIM" + getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the cursor on the map should 'spin' when rendered, like it does for the player in the nether.
|
||||
*
|
||||
@@ -332,7 +318,7 @@ public interface IForgeDimension
|
||||
*/
|
||||
default boolean shouldMapSpin(String entity, double x, double z, double rotation)
|
||||
{
|
||||
return getId() < 0;
|
||||
return getDimension().getType() == DimensionType.NETHER;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,7 +327,7 @@ public interface IForgeDimension
|
||||
* @param player The player that is respawning
|
||||
* @return The dimension to respawn the player in
|
||||
*/
|
||||
default int getRespawnDimension(net.minecraft.entity.player.EntityPlayerMP player)
|
||||
default DimensionType getRespawnDimension(EntityPlayerMP player)
|
||||
{
|
||||
return player.getSpawnDimension();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ package net.minecraftforge.common.extensions;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
|
||||
@@ -21,7 +21,7 @@ package net.minecraftforge.common.extensions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -36,7 +37,6 @@ import net.minecraft.entity.passive.HorseArmorType;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.IItemPropertyGetter;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
@@ -44,14 +44,13 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.registry.RegistrySimple;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.animation.ITimeValue;
|
||||
|
||||
// TODO review most of the methods in this "patch"
|
||||
public interface IForgeItem
|
||||
@@ -679,16 +678,10 @@ public interface IForgeItem
|
||||
return null;
|
||||
}
|
||||
|
||||
default com.google.common.collect.ImmutableMap<String, net.minecraftforge.common.animation.ITimeValue> getAnimationParameters(final ItemStack stack,
|
||||
final World world, final EntityLivingBase entity)
|
||||
default ImmutableMap<String, ITimeValue> getAnimationParameters(final ItemStack stack, final World world, final EntityLivingBase entity)
|
||||
{
|
||||
com.google.common.collect.ImmutableMap.Builder<String, net.minecraftforge.common.animation.ITimeValue> builder = com.google.common.collect.ImmutableMap
|
||||
.builder();
|
||||
for (ResourceLocation location : ((RegistrySimple<ResourceLocation, IItemPropertyGetter>) getItem().properties).getKeys())
|
||||
{
|
||||
final IItemPropertyGetter parameter = getItem().properties.get(location);
|
||||
builder.put(location.toString(), input -> parameter.call(stack, world, entity));
|
||||
}
|
||||
com.google.common.collect.ImmutableMap.Builder<String, ITimeValue> builder = ImmutableMap.builder();
|
||||
getItem().properties.forEach((k,v) -> builder.put(k.toString(), input -> v.call(stack, world, entity)));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,17 +19,6 @@
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
|
||||
public interface IForgeWorld extends ICapabilityProvider
|
||||
@@ -40,23 +29,4 @@ public interface IForgeWorld extends ICapabilityProvider
|
||||
* of one of there entities.
|
||||
*/
|
||||
public static double MAX_ENTITY_RADIUS = 2.0D;
|
||||
|
||||
default ImmutableSetMultimap<ChunkPos, ForgeChunkManager.Ticket> getPersistentChunks()
|
||||
{
|
||||
return ForgeChunkManager.getPersistentChunksFor((World)this);
|
||||
}
|
||||
|
||||
default Iterator<Chunk> getPersistentChunkIterable(Iterator<Chunk> chunkIterator)
|
||||
{
|
||||
@SuppressWarnings("resource")
|
||||
World world = (World)this;
|
||||
final ImmutableSetMultimap<ChunkPos, Ticket> persistentChunksFor = getPersistentChunks();
|
||||
final ImmutableSet.Builder<Chunk> builder = ImmutableSet.builder();
|
||||
world.profiler.startSection("forcedChunkLoading");
|
||||
builder.addAll(persistentChunksFor.keys().stream().filter(Objects::nonNull).map(input -> world.getChunk(input.x, input.z)).iterator());
|
||||
world.profiler.endStartSection("regularChunkLoading");
|
||||
builder.addAll(chunkIterator);
|
||||
world.profiler.endSection();
|
||||
return builder.build().iterator();
|
||||
}
|
||||
}
|
||||
@@ -35,8 +35,8 @@ import javax.vecmath.Tuple4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ItemTransformVec3f;
|
||||
import net.minecraft.client.renderer.block.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.model.ItemTransformVec3f;
|
||||
import net.minecraft.client.renderer.model.ModelRotation;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -536,7 +536,7 @@ public final class TRSRTransformation implements IModelState, ITransformation
|
||||
*/
|
||||
@Deprecated
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public net.minecraft.client.renderer.block.model.ItemTransformVec3f toItemTransform()
|
||||
public net.minecraft.client.renderer.model.ItemTransformVec3f toItemTransform()
|
||||
{
|
||||
return new ItemTransformVec3f(toMojang(toXYZDegrees(getLeftRot())), toMojang(getTranslation()), toMojang(getScale()));
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ package net.minecraftforge.common.model.animation;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -21,10 +21,8 @@ package net.minecraftforge.common.network;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.network.ForgeMessage.DimensionRegisterMessage;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -36,9 +34,9 @@ public class DimensionMessageHandler extends SimpleChannelInboundHandler<ForgeMe
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, DimensionRegisterMessage msg) throws Exception
|
||||
{
|
||||
if (!DimensionManager.isDimensionRegistered(msg.dimensionId))
|
||||
if (DimensionManager.getRegistry().get(msg.id) == null)
|
||||
{
|
||||
DimensionManager.registerDimension(msg.dimensionId, DimensionType.valueOf(msg.providerId));
|
||||
DimensionManager.registerDimensionInternal(msg.id + 1, msg.name, msg.dim, msg.data);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -20,54 +20,71 @@
|
||||
package net.minecraftforge.common.network;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ModDimension;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public abstract class ForgeMessage {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public static class DimensionRegisterMessage extends ForgeMessage {
|
||||
/** The dimension ID to register on client */
|
||||
int dimensionId;
|
||||
/** The provider ID to register with dimension on client */
|
||||
String providerId;
|
||||
int id;
|
||||
ResourceLocation name;
|
||||
ModDimension dim;
|
||||
@Nullable
|
||||
PacketBuffer data;
|
||||
|
||||
public DimensionRegisterMessage(){}
|
||||
public DimensionRegisterMessage(int dimensionId, String providerId)
|
||||
public DimensionRegisterMessage(int id, ResourceLocation name, ModDimension dim, @Nullable PacketBuffer data)
|
||||
{
|
||||
this.dimensionId = dimensionId;
|
||||
this.providerId = providerId;
|
||||
this.id = id;
|
||||
this.dim = dim;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
void toBytes(ByteBuf bytes)
|
||||
void toBytes(ByteBuf buff)
|
||||
{
|
||||
bytes.writeInt(this.dimensionId);
|
||||
byte[] data = this.providerId.getBytes(StandardCharsets.UTF_8);
|
||||
bytes.writeShort(data.length);
|
||||
bytes.writeBytes(data);
|
||||
PacketBuffer output = new PacketBuffer(buff);
|
||||
output.writeInt(id);
|
||||
output.writeResourceLocation(name);
|
||||
output.writeResourceLocation(dim.getRegistryName());
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
output.writeShort(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ByteBuf dup = data.duplicate();
|
||||
output.writeShort(dup.readableBytes());
|
||||
output.writeBytes(dup);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void fromBytes(ByteBuf bytes)
|
||||
void fromBytes(ByteBuf buff)
|
||||
{
|
||||
dimensionId = bytes.readInt();
|
||||
byte[] data = new byte[bytes.readShort()];
|
||||
bytes.readBytes(data);
|
||||
providerId = new String(data, StandardCharsets.UTF_8);
|
||||
PacketBuffer input = new PacketBuffer(buff);
|
||||
id = input.readInt();
|
||||
name = input.readResourceLocation();
|
||||
dim = ForgeRegistries.MOD_DIMENSIONS.getValue(input.readResourceLocation());
|
||||
|
||||
int len = input.readShort();
|
||||
if (len != 0)
|
||||
{
|
||||
data = new PacketBuffer(Unpooled.buffer());
|
||||
input.readBytes(data, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* TODO fluids
|
||||
|
||||
@@ -63,7 +63,7 @@ public class BlockSnapshot
|
||||
public BlockSnapshot(World world, BlockPos pos, IBlockState state, @Nullable NBTTagCompound nbt)
|
||||
{
|
||||
this.setWorld(world);
|
||||
this.dimId = world.dimension.getId();
|
||||
this.dimId = world.dimension.getType().getId();
|
||||
this.pos = pos.toImmutable();
|
||||
this.setReplacedBlock(state);
|
||||
this.registryName = state.getBlock().getRegistryName();
|
||||
|
||||
@@ -26,12 +26,12 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.play.client.CPacketClientSettings;
|
||||
import net.minecraft.server.management.PlayerInteractionManager;
|
||||
import net.minecraft.stats.StatBase;
|
||||
import net.minecraft.stats.Stat;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
//Preliminary, simple Fake Player class
|
||||
public class FakePlayer extends EntityPlayerMP
|
||||
@@ -44,12 +44,12 @@ public class FakePlayer extends EntityPlayerMP
|
||||
@Override public Vec3d getPositionVector(){ return new Vec3d(0, 0, 0); }
|
||||
@Override public void sendStatusMessage(ITextComponent chatComponent, boolean actionBar){}
|
||||
@Override public void sendMessage(ITextComponent component) {}
|
||||
@Override public void addStat(StatBase par1StatBase, int par2){}
|
||||
@Override public void addStat(Stat par1StatBase, int par2){}
|
||||
//@Override public void openGui(Object mod, int modGuiId, World world, int x, int y, int z){}
|
||||
@Override public boolean isInvulnerableTo(DamageSource source){ return true; }
|
||||
@Override public boolean canAttackPlayer(EntityPlayer player){ return false; }
|
||||
@Override public void onDeath(DamageSource source){ return; }
|
||||
@Override public void tick(){ return; }
|
||||
@Override public Entity changeDimension(int dim, ITeleporter teleporter){ return this; }
|
||||
@Override public Entity changeDimension(DimensionType dim, ITeleporter teleporter){ return this; }
|
||||
@Override public void handleClientSettings(CPacketClientSettings pkt){ return; }
|
||||
}
|
||||
@@ -175,7 +175,7 @@ public class ForgeEventFactory
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack, hand));
|
||||
}
|
||||
|
||||
public static Result canEntitySpawn(EntityLiving entity, IWorld world, float x, float y, float z, MobSpawnerBaseLogic spawner)
|
||||
public static Result canEntitySpawn(EntityLiving entity, IWorld world, double x, double y, double z, MobSpawnerBaseLogic spawner)
|
||||
{
|
||||
if (entity == null)
|
||||
return Result.DEFAULT;
|
||||
@@ -188,7 +188,7 @@ public class ForgeEventFactory
|
||||
{
|
||||
Result result = canEntitySpawn(entity, world, x, y, z, spawner);
|
||||
if (result == Result.DEFAULT)
|
||||
return entity.getCanSpawnHere() && entity.isNotColliding(); // vanilla logic
|
||||
return entity.canSpawn(world, true) && entity.isNotColliding(); // vanilla logic
|
||||
else
|
||||
return result == Result.ALLOW;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package net.minecraftforge.event.entity;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event.HasResult;
|
||||
@@ -39,15 +40,15 @@ import net.minecraftforge.eventbus.api.Event.HasResult;
|
||||
@Cancelable
|
||||
public class EntityTravelToDimensionEvent extends EntityEvent
|
||||
{
|
||||
private final int dimension;
|
||||
private final DimensionType dimension;
|
||||
|
||||
public EntityTravelToDimensionEvent(Entity entity, int dimension)
|
||||
public EntityTravelToDimensionEvent(Entity entity, DimensionType dimension)
|
||||
{
|
||||
super(entity);
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
||||
public int getDimension()
|
||||
public DimensionType getDimension()
|
||||
{
|
||||
return dimension;
|
||||
}
|
||||
|
||||
@@ -45,11 +45,11 @@ import net.minecraftforge.eventbus.api.Event.HasResult;
|
||||
public class LivingSpawnEvent extends LivingEvent
|
||||
{
|
||||
private final IWorld world;
|
||||
private final float x;
|
||||
private final float y;
|
||||
private final float z;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
|
||||
public LivingSpawnEvent(EntityLiving entity, IWorld world, float x, float y, float z)
|
||||
public LivingSpawnEvent(EntityLiving entity, IWorld world, double x, double y, double z)
|
||||
{
|
||||
super(entity);
|
||||
this.world = world;
|
||||
@@ -59,9 +59,9 @@ public class LivingSpawnEvent extends LivingEvent
|
||||
}
|
||||
|
||||
public IWorld getWorld() { return world; }
|
||||
public float getX() { return x; }
|
||||
public float getY() { return y; }
|
||||
public float getZ() { return z; }
|
||||
public double getX() { return x; }
|
||||
public double getY() { return y; }
|
||||
public double getZ() { return z; }
|
||||
/**
|
||||
* Fires before mob spawn events.
|
||||
*
|
||||
@@ -87,7 +87,7 @@ public class LivingSpawnEvent extends LivingEvent
|
||||
* @param spawner position of the MobSpawner
|
||||
* null if it this spawn is coming from a WorldSpawner
|
||||
*/
|
||||
public CheckSpawn(EntityLiving entity, IWorld world, float x, float y, float z, @Nullable MobSpawnerBaseLogic spawner)
|
||||
public CheckSpawn(EntityLiving entity, IWorld world, double x, double y, double z, @Nullable MobSpawnerBaseLogic spawner)
|
||||
{
|
||||
super(entity, world, x, y, z);
|
||||
this.spawner = spawner;
|
||||
@@ -127,7 +127,7 @@ public class LivingSpawnEvent extends LivingEvent
|
||||
/**
|
||||
* @param spawner the position of a tileentity or approximate position of an entity that initiated the spawn if any
|
||||
*/
|
||||
public SpecialSpawn(EntityLiving entity, World world, float x, float y, float z, @Nullable MobSpawnerBaseLogic spawner)
|
||||
public SpecialSpawn(EntityLiving entity, World world, double x, double y, double z, @Nullable MobSpawnerBaseLogic spawner)
|
||||
{
|
||||
super(entity, world, x, y, z);
|
||||
this.spawner = spawner;
|
||||
@@ -158,7 +158,7 @@ public class LivingSpawnEvent extends LivingEvent
|
||||
{
|
||||
public AllowDespawn(EntityLiving entity)
|
||||
{
|
||||
super(entity, entity.world, (float)entity.posX, (float)entity.posY, (float)entity.posZ);
|
||||
super(entity, entity.world, entity.posX, entity.posY, entity.posZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.event.world;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.DimensionManager.SavedEntry;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
/**
|
||||
* Register all of your custom ModDimensons here, fired during server loading when
|
||||
* dimension data is read from the world file.
|
||||
*
|
||||
* Contains a list of missing entries. Registering an entry with the DimensionManger
|
||||
* will remove the matching entry from the missing list.
|
||||
*/
|
||||
public class RegisterDimensionsEvent extends Event
|
||||
{
|
||||
private final Map<ResourceLocation, SavedEntry> missing;
|
||||
private final Set<ResourceLocation> keys;
|
||||
|
||||
public RegisterDimensionsEvent(Map<ResourceLocation, SavedEntry> missing)
|
||||
{
|
||||
this.missing = missing;
|
||||
this.keys = Collections.unmodifiableSet(this.missing.keySet());
|
||||
}
|
||||
|
||||
public Set<ResourceLocation> getMissingNames()
|
||||
{
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SavedEntry getEntry(ResourceLocation key)
|
||||
{
|
||||
return missing.get(key);
|
||||
}
|
||||
}
|
||||
@@ -40,9 +40,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
@@ -50,8 +48,6 @@ import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.Item.Builder;
|
||||
|
||||
/**
|
||||
* A universal bucket that can hold any liquid
|
||||
*/
|
||||
@@ -63,9 +59,9 @@ public class UniversalBucket extends Item
|
||||
private final ItemStack empty; // empty item to return and recognize when filling
|
||||
private final boolean nbtSensitive;
|
||||
|
||||
public UniversalBucket(Builder builder)
|
||||
public UniversalBucket(Properties properties)
|
||||
{
|
||||
this(builder, Fluid.BUCKET_VOLUME, new ItemStack(Items.BUCKET), false);
|
||||
this(properties, Fluid.BUCKET_VOLUME, new ItemStack(Items.BUCKET), false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,13 +69,13 @@ public class UniversalBucket extends Item
|
||||
* @param empty Item used for filling with the bucket event and returned when emptied
|
||||
* @param nbtSensitive Whether the empty item is NBT sensitive (usually true if empty and full are the same items)
|
||||
*/
|
||||
public UniversalBucket(Builder builder, int capacity, @Nonnull ItemStack empty, boolean nbtSensitive)
|
||||
public UniversalBucket(Properties properties, int capacity, @Nonnull ItemStack empty, boolean nbtSensitive)
|
||||
{
|
||||
super(builder);
|
||||
super(properties);
|
||||
this.capacity = capacity;
|
||||
this.empty = empty;
|
||||
this.nbtSensitive = nbtSensitive;
|
||||
|
||||
|
||||
/* TODO move to builder construction
|
||||
this.setMaxStackSize(1);
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ public class ItemFluidContainer extends Item
|
||||
/**
|
||||
* @param capacity The maximum capacity of this fluid container.
|
||||
*/
|
||||
public ItemFluidContainer(Item.Builder builder, int capacity)
|
||||
public ItemFluidContainer(Item.Properties properties, int capacity)
|
||||
{
|
||||
super(builder);
|
||||
super(properties);
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ClientRegistry
|
||||
*/
|
||||
public static synchronized <T extends TileEntity> void bindTileEntitySpecialRenderer(Class<T> tileEntityClass, TileEntityRenderer<? super T> specialRenderer)
|
||||
{
|
||||
TileEntityRendererDispatcher.instance.renderers.put(tileEntityClass, specialRenderer);
|
||||
TileEntityRendererDispatcher.instance.setSpecialRenderer(tileEntityClass, specialRenderer);
|
||||
specialRenderer.setRendererDispatcher(TileEntityRendererDispatcher.instance);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,17 +23,23 @@ import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class PlayerEvent extends Event {
|
||||
public final EntityPlayer player;
|
||||
private final EntityPlayer player;
|
||||
private PlayerEvent(EntityPlayer player)
|
||||
{
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayer()
|
||||
{
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public static class ItemPickupEvent extends PlayerEvent {
|
||||
/**
|
||||
* Original EntityItem with current remaining stack size
|
||||
@@ -61,23 +67,40 @@ public class PlayerEvent extends Event {
|
||||
|
||||
public static class ItemCraftedEvent extends PlayerEvent {
|
||||
@Nonnull
|
||||
public final ItemStack crafting;
|
||||
public final IInventory craftMatrix;
|
||||
private final ItemStack crafting;
|
||||
private final IInventory craftMatrix;
|
||||
public ItemCraftedEvent(EntityPlayer player, @Nonnull ItemStack crafting, IInventory craftMatrix)
|
||||
{
|
||||
super(player);
|
||||
this.crafting = crafting;
|
||||
this.craftMatrix = craftMatrix;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ItemStack getCrafting()
|
||||
{
|
||||
return this.crafting;
|
||||
}
|
||||
|
||||
public IInventory getInventory()
|
||||
{
|
||||
return this.craftMatrix;
|
||||
}
|
||||
}
|
||||
public static class ItemSmeltedEvent extends PlayerEvent {
|
||||
@Nonnull
|
||||
public final ItemStack smelting;
|
||||
private final ItemStack smelting;
|
||||
public ItemSmeltedEvent(EntityPlayer player, @Nonnull ItemStack crafting)
|
||||
{
|
||||
super(player);
|
||||
this.smelting = crafting;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ItemStack getSmelting()
|
||||
{
|
||||
return this.smelting;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlayerLoggedInEvent extends PlayerEvent {
|
||||
@@ -116,13 +139,23 @@ public class PlayerEvent extends Event {
|
||||
}
|
||||
|
||||
public static class PlayerChangedDimensionEvent extends PlayerEvent {
|
||||
public final int fromDim;
|
||||
public final int toDim;
|
||||
public PlayerChangedDimensionEvent(EntityPlayer player, int fromDim, int toDim)
|
||||
private final DimensionType fromDim;
|
||||
private final DimensionType toDim;
|
||||
public PlayerChangedDimensionEvent(EntityPlayer player, DimensionType fromDim, DimensionType toDim)
|
||||
{
|
||||
super(player);
|
||||
this.fromDim = fromDim;
|
||||
this.toDim = toDim;
|
||||
}
|
||||
|
||||
public DimensionType getFrom()
|
||||
{
|
||||
return this.fromDim;
|
||||
}
|
||||
|
||||
public DimensionType getTo()
|
||||
{
|
||||
return this.toDim;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public class VillagerRegistry
|
||||
return instance().villageCreationHandlers.get(villagePiece.villagePieceClass).buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, facing, p5);
|
||||
}
|
||||
|
||||
RegistryNamespaced<ResourceLocation, VillagerProfession> REGISTRY = GameData.getWrapper(VillagerProfession.class);
|
||||
RegistryNamespaced<VillagerProfession> REGISTRY = GameData.getWrapper(VillagerProfession.class);
|
||||
|
||||
private void register(VillagerProfession prof, int id)
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.client.model.animation.Animation;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
@@ -43,7 +44,7 @@ public class BasicEventHooks
|
||||
MinecraftForge.EVENT_BUS.post(new InputEvent.KeyInputEvent());
|
||||
}
|
||||
|
||||
public static void firePlayerChangedDimensionEvent(EntityPlayer player, int fromDim, int toDim)
|
||||
public static void firePlayerChangedDimensionEvent(EntityPlayer player, DimensionType fromDim, DimensionType toDim)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerChangedDimensionEvent(player, fromDim, toDim));
|
||||
}
|
||||
|
||||
@@ -22,10 +22,9 @@ package net.minecraftforge.fml.network;
|
||||
import io.netty.util.AttributeKey;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.server.network.NetHandlerLoginServer;
|
||||
import net.minecraft.network.NetHandlerLoginServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.fml.Logging;
|
||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
import net.minecraftforge.fml.util.ThreeConsumer;
|
||||
import net.minecraftforge.registries.RegistryManager;
|
||||
|
||||
@@ -29,6 +29,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.ExtensionPoint;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -50,7 +51,7 @@ public class FMLPlayMessages
|
||||
SpawnEntity(Entity e)
|
||||
{
|
||||
this.entity = e;
|
||||
this.typeId = EntityType.REGISTRY.getId(e.getType());
|
||||
this.typeId = IRegistry.field_212629_r.getId(e.getType());
|
||||
this.entityId = e.getEntityId();
|
||||
this.uuid = e.getUniqueID();
|
||||
this.posX = e.posX;
|
||||
@@ -121,7 +122,7 @@ public class FMLPlayMessages
|
||||
public static void handle(SpawnEntity msg, Supplier<NetworkEvent.Context> ctx)
|
||||
{
|
||||
ctx.get().enqueueWork(() -> {
|
||||
EntityType<?> type = EntityType.REGISTRY.get(msg.typeId);
|
||||
EntityType<?> type = IRegistry.field_212629_r.get(msg.typeId);
|
||||
if (type == null)
|
||||
{
|
||||
throw new RuntimeException(String.format("Could not spawn entity (id %d) with unknown type at (%f, %f, %f)", msg.entityId, msg.posX, msg.posY, msg.posZ));
|
||||
|
||||
@@ -28,7 +28,7 @@ import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.handshake.client.CPacketHandshake;
|
||||
import net.minecraft.server.network.NetHandlerLoginServer;
|
||||
import net.minecraft.network.NetHandlerLoginServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IInteractionObject;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.BlockModelShapes;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* 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.registries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
import net.minecraft.util.IntIdentityHashBiMap;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
|
||||
/**
|
||||
* A IRegistry implementation that allows for removing of objects. This is a internal helper
|
||||
* class used by Forge for managing things that reset during Server initialization.
|
||||
*/
|
||||
public class ClearableRegistry<V> implements IRegistry<V>
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Marker REGISTRY = MarkerManager.getMarker("REGISTRY");
|
||||
|
||||
private final IntIdentityHashBiMap<V> ids = new IntIdentityHashBiMap<>(256);
|
||||
private final BiMap<ResourceLocation, V> map = HashBiMap.create();
|
||||
private final Set<ResourceLocation> keys = Collections.unmodifiableSet(map.keySet());
|
||||
private List<V> values = new ArrayList<>();
|
||||
private final ResourceLocation name;
|
||||
private int nextId = 0;
|
||||
|
||||
public ClearableRegistry(ResourceLocation name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ResourceLocation getKey(V value)
|
||||
{
|
||||
return map.inverse().get(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(ResourceLocation key)
|
||||
{
|
||||
throw new UnsupportedOperationException("No default value");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation func_212609_b()
|
||||
{
|
||||
throw new UnsupportedOperationException("No default key");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public int getId(V value)
|
||||
{
|
||||
return ids.getId(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public V get(int id)
|
||||
{
|
||||
return ids.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<V> iterator()
|
||||
{
|
||||
return ids.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public V func_212608_b(ResourceLocation key)
|
||||
{
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(int id, ResourceLocation key, V value)
|
||||
{
|
||||
Validate.isTrue(id >= 0, "Invalid ID, can not be < 0");
|
||||
Validate.notNull(key);
|
||||
Validate.notNull(value);
|
||||
|
||||
V old = map.get(key);
|
||||
if (old != null)
|
||||
{
|
||||
LOGGER.debug(REGISTRY, "{}: Adding suplicate key '{}' to registry. Old: {} New: {}", name, key, old, value);
|
||||
values.remove(old);
|
||||
}
|
||||
|
||||
map.put(key, value);
|
||||
ids.put(value, id);
|
||||
values.add(value);
|
||||
if (nextId <= id)
|
||||
nextId = id + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(ResourceLocation key, V value)
|
||||
{
|
||||
register(nextId, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ResourceLocation> getKeys()
|
||||
{
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return map.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public V getRandom(Random random)
|
||||
{
|
||||
return values.isEmpty() ? null : values.get(random.nextInt(values.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_212607_c(ResourceLocation key)
|
||||
{
|
||||
return map.containsKey(key);
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
LOGGER.debug(REGISTRY, "{}: Clearing registry", name);
|
||||
map.clear();
|
||||
values.clear();
|
||||
ids.clear();
|
||||
nextId = 0;
|
||||
}
|
||||
|
||||
public int getNextId()
|
||||
{
|
||||
return nextId;
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import net.minecraft.potion.PotionType;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.common.ModDimension;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
|
||||
@@ -52,8 +53,9 @@ public class ForgeRegistries
|
||||
public static final IForgeRegistry<PotionType> POTION_TYPES = RegistryManager.ACTIVE.getRegistry(PotionType.class);
|
||||
public static final IForgeRegistry<Enchantment> ENCHANTMENTS = RegistryManager.ACTIVE.getRegistry(Enchantment.class);
|
||||
public static final IForgeRegistry<VillagerProfession> VILLAGER_PROFESSIONS = RegistryManager.ACTIVE.getRegistry(VillagerProfession.class);
|
||||
public static final IForgeRegistry<EntityType<?>> ENTITIES = (IForgeRegistry)RegistryManager.ACTIVE.getRegistry(EntityType.class);
|
||||
public static final IForgeRegistry<TileEntityType<?>> TILE_ENTITIES = (IForgeRegistry)RegistryManager.ACTIVE.getRegistry(TileEntityType.class);
|
||||
public static final IForgeRegistry<EntityType<?>> ENTITIES = RegistryManager.ACTIVE.getRegistry(EntityType.class);
|
||||
public static final IForgeRegistry<TileEntityType<?>> TILE_ENTITIES = RegistryManager.ACTIVE.getRegistry(TileEntityType.class);
|
||||
public static final IForgeRegistry<ModDimension> MOD_DIMENSIONS = RegistryManager.ACTIVE.getRegistry(ModDimension.class);
|
||||
/**
|
||||
* This function is just to make sure static inializers in other classes have run and setup their registries before we query them.
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,8 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraftforge.fml.loading.AdvancedLogMessageAdapter;
|
||||
@@ -272,6 +274,12 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
|
||||
Validate.notNull(this.defaultValue, "Missing default of ForgeRegistry: " + this.defaultKey + " Type: " + this.superType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ResourceLocation getDefaultKey()
|
||||
{
|
||||
return this.defaultKey;
|
||||
}
|
||||
|
||||
ForgeRegistry<V> copy(RegistryManager stage)
|
||||
{
|
||||
return new ForgeRegistry<>(stage, name, builder);
|
||||
@@ -358,7 +366,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
|
||||
return idToUse;
|
||||
}
|
||||
|
||||
private V getRaw(ResourceLocation key)
|
||||
public V getRaw(ResourceLocation key)
|
||||
{
|
||||
V ret = this.names.get(key);
|
||||
key = this.aliases.get(key);
|
||||
|
||||
@@ -39,6 +39,7 @@ import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.ModDimension;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.RegistryEvent.MissingMappings;
|
||||
import net.minecraftforge.fml.LifecycleEventProvider;
|
||||
@@ -84,15 +85,16 @@ public class GameData
|
||||
public static final ResourceLocation ENTITIES = new ResourceLocation("minecraft:entities");
|
||||
public static final ResourceLocation TILEENTITIES = new ResourceLocation("minecraft:tileentities");
|
||||
public static final ResourceLocation PROFESSIONS = new ResourceLocation("minecraft:villagerprofessions");
|
||||
public static final ResourceLocation MODDIMENSIONS = new ResourceLocation("forge:moddimensions");
|
||||
private static final int MAX_REGISTRY_SIZE = Integer.MAX_VALUE >> 5;
|
||||
private static final int MAX_BLOCK_ID = 4095;
|
||||
private static final int MIN_ITEM_ID = MAX_BLOCK_ID + 1;
|
||||
private static final int MAX_ITEM_ID = 31999;
|
||||
private static final int MAX_POTION_ID = 255; // SPacketEntityEffect sends bytes, we can only use 255
|
||||
private static final int MAX_BIOME_ID = 255; // Maximum number in a byte in the chunk
|
||||
private static final int MAX_SOUND_ID = Integer.MAX_VALUE >> 5; // Varint (SPacketSoundEffect)
|
||||
private static final int MAX_POTIONTYPE_ID = Integer.MAX_VALUE >> 5; // Int (SPacketEffect)
|
||||
private static final int MAX_POTIONTYPE_ID = MAX_REGISTRY_SIZE; // Int (SPacketEffect)
|
||||
private static final int MAX_ENCHANTMENT_ID = Short.MAX_VALUE - 1; // Short - serialized as a short in ItemStack NBTs.
|
||||
private static final int MAX_ENTITY_ID = Integer.MAX_VALUE >> 5; // Varint (SPacketSpawnMob)
|
||||
private static final int MAX_ENTITY_ID = MAX_REGISTRY_SIZE; // Varint (SPacketSpawnMob)
|
||||
private static final int MAX_TILE_ENTITY_ID = Integer.MAX_VALUE; //Doesnt seem to be serialized anywhere, so no max.
|
||||
private static final int MAX_PROFESSION_ID = 1024; //TODO: Is this serialized anywhere anymore?
|
||||
|
||||
@@ -118,7 +120,7 @@ public class GameData
|
||||
return;
|
||||
hasInit = true;
|
||||
makeRegistry(BLOCKS, Block.class, MAX_BLOCK_ID, new ResourceLocation("air")).addCallback(BlockCallbacks.INSTANCE).create();
|
||||
makeRegistry(ITEMS, Item.class, MIN_ITEM_ID, MAX_ITEM_ID).addCallback(ItemCallbacks.INSTANCE).create();
|
||||
makeRegistry(ITEMS, Item.class, MAX_ITEM_ID).addCallback(ItemCallbacks.INSTANCE).create();
|
||||
makeRegistry(POTIONS, Potion.class, MAX_POTION_ID).create();
|
||||
makeRegistry(BIOMES, Biome.class, MAX_BIOME_ID).create();
|
||||
makeRegistry(SOUNDEVENTS, SoundEvent.class, MAX_SOUND_ID).create();
|
||||
@@ -128,12 +130,9 @@ public class GameData
|
||||
// TODO do we need the callback and the static field anymore?
|
||||
makeRegistry(ENTITIES, EntityType.class, MAX_ENTITY_ID).create();
|
||||
makeRegistry(TILEENTITIES, TileEntityType.class, MAX_TILE_ENTITY_ID).disableSaving().create();
|
||||
makeRegistry(MODDIMENSIONS, ModDimension.class, MAX_REGISTRY_SIZE).disableSaving().create();
|
||||
}
|
||||
|
||||
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, int max)
|
||||
{
|
||||
return new RegistryBuilder<T>().setName(name).setType(type).setMaxID(max).addCallback(new NamespacedWrapper.Factory<T>());
|
||||
@@ -143,22 +142,22 @@ public class GameData
|
||||
return new RegistryBuilder<T>().setName(name).setType(type).setMaxID(max).addCallback(new NamespacedDefaultedWrapper.Factory<T>()).setDefaultKey(_default);
|
||||
}
|
||||
|
||||
public static <V extends IForgeRegistryEntry<V>> RegistryNamespacedDefaultedByKey<ResourceLocation, V> getWrapperDefaulted(Class<V> cls)
|
||||
public static <V extends IForgeRegistryEntry<V>> RegistryNamespacedDefaultedByKey<V> getWrapperDefaulted(Class<V> cls)
|
||||
{
|
||||
IForgeRegistry<V> reg = RegistryManager.ACTIVE.getRegistry(cls);
|
||||
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + cls.toString());
|
||||
@SuppressWarnings("unchecked")
|
||||
RegistryNamespacedDefaultedByKey<ResourceLocation, V> ret = reg.getSlaveMap(NamespacedDefaultedWrapper.Factory.ID, NamespacedDefaultedWrapper.class);
|
||||
RegistryNamespacedDefaultedByKey<V> ret = reg.getSlaveMap(NamespacedDefaultedWrapper.Factory.ID, NamespacedDefaultedWrapper.class);
|
||||
Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + cls.toString());
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static <V extends IForgeRegistryEntry<V>> RegistryNamespaced<ResourceLocation, V> getWrapper(Class<V> cls)
|
||||
public static <V extends IForgeRegistryEntry<V>> RegistryNamespaced<V> getWrapper(Class<V> cls)
|
||||
{
|
||||
IForgeRegistry<V> reg = RegistryManager.ACTIVE.getRegistry(cls);
|
||||
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + cls.toString());
|
||||
@SuppressWarnings("unchecked")
|
||||
RegistryNamespaced<ResourceLocation, V> ret = reg.getSlaveMap(NamespacedWrapper.Factory.ID, NamespacedWrapper.class);
|
||||
RegistryNamespaced<V> ret = reg.getSlaveMap(NamespacedWrapper.Factory.ID, NamespacedWrapper.class);
|
||||
Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + cls.toString());
|
||||
return ret;
|
||||
}
|
||||
@@ -382,7 +381,7 @@ public class GameData
|
||||
@Override
|
||||
public Block createDummy(ResourceLocation key)
|
||||
{
|
||||
Block ret = new BlockDummyAir(Block.Builder.create(Material.AIR));
|
||||
Block ret = new BlockDummyAir(Block.Properties.create(Material.AIR));
|
||||
GameData.forceRegistryName(ret, key);
|
||||
return ret;
|
||||
}
|
||||
@@ -404,9 +403,9 @@ public class GameData
|
||||
|
||||
private static class BlockDummyAir extends BlockAir //A named class so DummyBlockReplacementTest can detect if its a dummy
|
||||
{
|
||||
private BlockDummyAir(Block.Builder builder)
|
||||
private BlockDummyAir(Block.Properties properties)
|
||||
{
|
||||
super(builder);
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,6 +47,7 @@ public interface IForgeRegistry<V extends IForgeRegistryEntry<V>> extends Iterab
|
||||
|
||||
@Nullable V getValue(ResourceLocation key);
|
||||
@Nullable ResourceLocation getKey(V value);
|
||||
@Nullable ResourceLocation getDefaultKey();
|
||||
|
||||
@Nonnull Set<ResourceLocation> getKeys();
|
||||
@Nonnull Collection<V> getValues();
|
||||
|
||||
@@ -33,7 +33,7 @@ import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamespacedDefaultedByKey<ResourceLocation, V> implements ILockableRegistry
|
||||
class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamespacedDefaultedByKey<V> implements ILockableRegistry
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private boolean locked = false;
|
||||
@@ -66,18 +66,19 @@ class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends Regis
|
||||
register(-1, key, value);
|
||||
}
|
||||
|
||||
// Reading Functions
|
||||
@Override
|
||||
public void validateKey()
|
||||
@Nullable
|
||||
public V func_212608_b(@Nullable ResourceLocation name)
|
||||
{
|
||||
this.delegate.validateKey();
|
||||
return this.delegate.getRaw(name); //get without default
|
||||
}
|
||||
|
||||
// Reading Functions
|
||||
@Override
|
||||
@Nullable
|
||||
public V get(@Nullable ResourceLocation name)
|
||||
{
|
||||
return this.delegate.getValue(name);
|
||||
return this.delegate.getValue(name); //getOrDefault
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,7 +89,7 @@ class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends Regis
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(ResourceLocation key)
|
||||
public boolean func_212607_c(ResourceLocation key)
|
||||
{
|
||||
return this.delegate.containsKey(key);
|
||||
}
|
||||
@@ -126,6 +127,12 @@ class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends Regis
|
||||
return values.stream().skip(random.nextInt(values.size())).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation func_212609_b()
|
||||
{
|
||||
return this.delegate.getDefaultKey();
|
||||
}
|
||||
|
||||
//internal
|
||||
@Override
|
||||
public void lock(){ this.locked = true; }
|
||||
|
||||
@@ -33,7 +33,7 @@ import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
class NamespacedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamespaced<ResourceLocation, V> implements ILockableRegistry
|
||||
class NamespacedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamespaced<V> implements ILockableRegistry
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private boolean locked = false;
|
||||
@@ -70,9 +70,9 @@ class NamespacedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamesp
|
||||
// Reading Functions
|
||||
@Override
|
||||
@Nullable
|
||||
public V get(@Nullable ResourceLocation name)
|
||||
public V func_212608_b(@Nullable ResourceLocation name)
|
||||
{
|
||||
return this.delegate.getValue(name);
|
||||
return this.delegate.getRaw(name); //get without default
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,7 +83,7 @@ class NamespacedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamesp
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(ResourceLocation key)
|
||||
public boolean func_212607_c(ResourceLocation key)
|
||||
{
|
||||
return this.delegate.containsKey(key);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.storage.SessionLockException;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.WorldWorkerManager.IWorker;
|
||||
@@ -40,7 +41,7 @@ public class ChunkGenWorker implements IWorker
|
||||
private final CommandSource listener;
|
||||
protected final BlockPos start;
|
||||
protected final int total;
|
||||
private final int dim;
|
||||
private final DimensionType dim;
|
||||
private final Queue<BlockPos> queue;
|
||||
private final int notificationFrequency;
|
||||
private int lastNotification = 0;
|
||||
@@ -48,7 +49,7 @@ public class ChunkGenWorker implements IWorker
|
||||
private int genned = 0;
|
||||
private Boolean keepingLoaded;
|
||||
|
||||
public ChunkGenWorker(CommandSource listener, BlockPos start, int total, int dim, int interval)
|
||||
public ChunkGenWorker(CommandSource listener, BlockPos start, int total, DimensionType dim, int interval)
|
||||
{
|
||||
this.listener = listener;
|
||||
this.start = start;
|
||||
@@ -99,11 +100,10 @@ public class ChunkGenWorker implements IWorker
|
||||
@Override
|
||||
public boolean doWork()
|
||||
{
|
||||
WorldServer world = DimensionManager.getWorld(dim);
|
||||
WorldServer world = DimensionManager.getWorld(listener.getServer(), dim, false, false);
|
||||
if (world == null)
|
||||
{
|
||||
DimensionManager.initDimension(dim);
|
||||
world = DimensionManager.getWorld(dim);
|
||||
world = DimensionManager.initWorld(listener.getServer(), dim);
|
||||
if (world == null)
|
||||
{
|
||||
listener.sendFeedback(new TextComponentTranslation("commands.forge.gen.dim_fail", dim), true);
|
||||
@@ -131,7 +131,7 @@ public class ChunkGenWorker implements IWorker
|
||||
// While we work we don't want to cause world load spam so pause unloading the world.
|
||||
if (keepingLoaded == null)
|
||||
{
|
||||
keepingLoaded = DimensionManager.keepDimensionLoaded(dim, true);
|
||||
keepingLoaded = DimensionManager.keepLoaded(dim, true);
|
||||
}
|
||||
|
||||
if (++lastNotification >= notificationFrequency || lastNotifcationTime < System.currentTimeMillis() - 60*1000)
|
||||
@@ -180,9 +180,9 @@ public class ChunkGenWorker implements IWorker
|
||||
if (queue.size() == 0)
|
||||
{
|
||||
listener.sendFeedback(new TextComponentTranslation("commands.forge.gen.complete", genned, total, dim), true);
|
||||
if (keepingLoaded != null && keepingLoaded)
|
||||
if (keepingLoaded != null && !keepingLoaded)
|
||||
{
|
||||
DimensionManager.keepDimensionLoaded(dim, false);
|
||||
DimensionManager.keepLoaded(dim, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,15 +19,16 @@
|
||||
|
||||
package net.minecraftforge.server.command;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntSortedSet;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||
|
||||
@@ -39,10 +40,15 @@ public class CommandDimensions
|
||||
.requires(cs->cs.hasPermissionLevel(0)) //permission
|
||||
.executes(ctx -> {
|
||||
ctx.getSource().sendFeedback(new TextComponentTranslation("commands.forge.dimensions.list"), true);
|
||||
for (Map.Entry<DimensionType, IntSortedSet> entry : DimensionManager.getRegisteredDimensions().entrySet())
|
||||
{
|
||||
ctx.getSource().sendFeedback(new TextComponentString(entry.getKey().getName() + ": " + entry.getValue()), true);
|
||||
Map<String, List<String>> types = new HashMap<>();
|
||||
for (DimensionType dim : DimensionType.func_212681_b()) {
|
||||
String key = dim.getModType() == null ? "Vanilla" : dim.getModType().getRegistryName().toString();
|
||||
types.computeIfAbsent(key, k -> new ArrayList<>()).add(DimensionType.func_212678_a(dim).toString());
|
||||
}
|
||||
|
||||
types.keySet().stream().sorted().forEach(key -> {
|
||||
ctx.getSource().sendFeedback(new TextComponentString(key + ": " + types.get(key).stream().sorted().collect(Collectors.joining(", "))), true);
|
||||
});
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
|
||||
package net.minecraftforge.server.command;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -29,27 +27,23 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.command.ISuggestionProvider;
|
||||
import net.minecraft.command.arguments.BlockPosArgument;
|
||||
import net.minecraft.command.arguments.DimensionArgument;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@@ -75,16 +69,15 @@ class CommandEntity
|
||||
.requires(cs->cs.hasPermissionLevel(2)) //permission
|
||||
.then(Commands.argument("filter", StringArgumentType.string())
|
||||
.suggests((ctx, builder) -> ISuggestionProvider.suggest(ForgeRegistries.ENTITIES.getKeys().stream().map(id -> id.toString()), builder))
|
||||
.then(Commands.argument("dim", IntegerArgumentType.integer())
|
||||
.suggests((ctx, builder) -> ISuggestionProvider.suggest(DimensionManager.getIDStream().sorted().map(id -> id.toString()), builder))
|
||||
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), IntegerArgumentType.getInteger(ctx, "dim")))
|
||||
.then(Commands.argument("dim", DimensionArgument.func_212595_a())
|
||||
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), DimensionArgument.func_212592_a(ctx, "dim")))
|
||||
)
|
||||
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), ctx.getSource().getWorld().dimension.getId()))
|
||||
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), ctx.getSource().getWorld().dimension.getType()))
|
||||
)
|
||||
.executes(ctx -> execute(ctx.getSource(), "*", ctx.getSource().getWorld().dimension.getId()));
|
||||
.executes(ctx -> execute(ctx.getSource(), "*", ctx.getSource().getWorld().dimension.getType()));
|
||||
}
|
||||
|
||||
private static int execute(CommandSource sender, String filter, int dim) throws CommandSyntaxException
|
||||
private static int execute(CommandSource sender, String filter, DimensionType dim) throws CommandSyntaxException
|
||||
{
|
||||
final String cleanFilter = filter.replace("?", ".?").replace("*", ".*?");
|
||||
|
||||
@@ -93,7 +86,7 @@ class CommandEntity
|
||||
if (names.isEmpty())
|
||||
throw INVALID_FILTER.create();
|
||||
|
||||
WorldServer world = DimensionManager.getWorld(dim);
|
||||
WorldServer world = DimensionManager.getWorld(sender.getServer(), dim, false, false);
|
||||
if (world == null)
|
||||
throw INVALID_DIMENSION.create(dim);
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.command.ISuggestionProvider;
|
||||
import net.minecraft.command.arguments.BlockPosArgument;
|
||||
import net.minecraft.command.arguments.DimensionArgument;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
@@ -52,14 +53,13 @@ class CommandGenerate
|
||||
.requires(cs->cs.hasPermissionLevel(4)) //permission
|
||||
.then(Commands.argument("pos", BlockPosArgument.blockPos())
|
||||
.then(Commands.argument("count", IntegerArgumentType.integer(1))
|
||||
.then(Commands.argument("dim", IntegerArgumentType.integer())
|
||||
.suggests((ctx, builder) -> ISuggestionProvider.suggest(DimensionManager.getIDStream().sorted().map(id -> id.toString()), builder))
|
||||
.then(Commands.argument("dim", DimensionArgument.func_212595_a())
|
||||
.then(Commands.argument("interval", IntegerArgumentType.integer())
|
||||
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), getInt(ctx, "dim"), getInt(ctx, "interval")))
|
||||
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.func_212592_a(ctx, "dim"), getInt(ctx, "interval")))
|
||||
)
|
||||
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), getInt(ctx, "dim"), -1))
|
||||
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.func_212592_a(ctx, "dim"), -1))
|
||||
)
|
||||
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), ctx.getSource().getWorld().dimension.getId(), -1))
|
||||
.executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), ctx.getSource().getWorld().dimension.getType(), -1))
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -69,14 +69,14 @@ class CommandGenerate
|
||||
return IntegerArgumentType.getInteger(ctx, name);
|
||||
}
|
||||
|
||||
private static int execute(CommandSource source, BlockPos pos, int count, int dim, int interval) throws CommandException
|
||||
private static int execute(CommandSource source, BlockPos pos, int count, DimensionType dim, int interval) throws CommandException
|
||||
{
|
||||
BlockPos chunkpos = new BlockPos(pos.getX() >> 4, 0, pos.getZ() >> 4);
|
||||
|
||||
ChunkGenWorker worker = new ChunkGenWorker(source, chunkpos, count, dim, interval);
|
||||
source.sendFeedback(worker.getStartMessage(source), true);
|
||||
WorldWorkerManager.addWorker(worker);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -19,36 +19,24 @@
|
||||
|
||||
package net.minecraftforge.server.command;
|
||||
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.command.ISuggestionProvider;
|
||||
import net.minecraft.command.arguments.BlockPosArgument;
|
||||
import net.minecraft.command.arguments.DimensionArgument;
|
||||
import net.minecraft.command.arguments.EntityArgument;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.ITeleporter;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntSortedSet;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommandSetDimension
|
||||
{
|
||||
@@ -59,24 +47,23 @@ public class CommandSetDimension
|
||||
return Commands.literal("setdimension")
|
||||
.requires(cs->cs.hasPermissionLevel(2)) //permission
|
||||
.then(Commands.argument("targets", EntityArgument.multipleEntities())
|
||||
.then(Commands.argument("dim", IntegerArgumentType.integer())
|
||||
.suggests((ctx, builder) -> ISuggestionProvider.suggest(DimensionManager.getIDStream().sorted().map(id -> id.toString()), builder))
|
||||
.then(Commands.argument("dim", DimensionArgument.func_212595_a())
|
||||
.then(Commands.argument("pos", BlockPosArgument.blockPos())
|
||||
.executes(ctx -> execute(ctx.getSource(), EntityArgument.getEntitiesAllowingNone(ctx, "targets"), IntegerArgumentType.getInteger(ctx, "dim"), BlockPosArgument.getBlockPos(ctx, "pos")))
|
||||
.executes(ctx -> execute(ctx.getSource(), EntityArgument.getEntitiesAllowingNone(ctx, "targets"), DimensionArgument.func_212592_a(ctx, "dim"), BlockPosArgument.getBlockPos(ctx, "pos")))
|
||||
)
|
||||
.executes(ctx -> execute(ctx.getSource(), EntityArgument.getEntitiesAllowingNone(ctx, "targets"), IntegerArgumentType.getInteger(ctx, "dim"), new BlockPos(ctx.getSource().getPos())))
|
||||
.executes(ctx -> execute(ctx.getSource(), EntityArgument.getEntitiesAllowingNone(ctx, "targets"), DimensionArgument.func_212592_a(ctx, "dim"), new BlockPos(ctx.getSource().getPos())))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private static int execute(CommandSource sender, Collection<? extends Entity> entities, int dim, BlockPos pos) throws CommandSyntaxException
|
||||
private static int execute(CommandSource sender, Collection<? extends Entity> entities, DimensionType dim, BlockPos pos) throws CommandSyntaxException
|
||||
{
|
||||
entities.removeIf(CommandSetDimension::checkEntity);
|
||||
if (entities.isEmpty())
|
||||
throw NO_ENTITIES.create();
|
||||
|
||||
if (!DimensionManager.isDimensionRegistered(dim))
|
||||
throw INVALID_DIMENSION.create(dim);
|
||||
//if (!DimensionManager.isDimensionRegistered(dim))
|
||||
// throw INVALID_DIMENSION.create(dim);
|
||||
|
||||
final ITeleporter teleporter = new CommandTeleporter(pos);
|
||||
entities.stream().filter(e -> e.dimension == dim).forEach(e -> sender.sendFeedback(new TextComponentTranslation("commands.forge.setdim.invalid.nochange", e.getDisplayName(), dim), true));
|
||||
|
||||
@@ -21,33 +21,31 @@ package net.minecraftforge.server.command;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.command.ISuggestionProvider;
|
||||
import net.minecraft.command.arguments.DimensionArgument;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
class CommandTps
|
||||
{
|
||||
private static final DynamicCommandExceptionType INVALID_DIMENSION = new DynamicCommandExceptionType(dim -> new TextComponentTranslation("commands.forge.tps.invalid", dim, DimensionManager.getIDStream().sorted().map(id -> id.toString()).collect(Collectors.joining(", "))));
|
||||
private static final DynamicCommandExceptionType INVALID_DIMENSION = new DynamicCommandExceptionType(dim -> new TextComponentTranslation("commands.forge.tps.invalid", dim, StreamSupport.stream(DimensionType.func_212681_b().spliterator(), false).map(d -> DimensionType.func_212678_a(d).toString()).sorted().collect(Collectors.joining(", "))));
|
||||
private static final DecimalFormat TIME_FORMATTER = new DecimalFormat("########0.000");
|
||||
|
||||
static ArgumentBuilder<CommandSource, ?> register()
|
||||
{
|
||||
return Commands.literal("tps")
|
||||
.requires(cs->cs.hasPermissionLevel(0)) //permission
|
||||
.then(Commands.argument("dim", IntegerArgumentType.integer())
|
||||
.suggests((ctx, builder) -> ISuggestionProvider.suggest(DimensionManager.getIDStream().sorted().map(id -> id.toString()), builder))
|
||||
.executes(ctx -> sendTime(ctx.getSource(), IntegerArgumentType.getInteger(ctx, "dim")))
|
||||
.then(Commands.argument("dim", DimensionArgument.func_212595_a())
|
||||
.executes(ctx -> sendTime(ctx.getSource(), DimensionArgument.func_212592_a(ctx, "dim")))
|
||||
)
|
||||
.executes(ctx -> {
|
||||
for (Integer dim : (Iterable<Integer>)DimensionManager.getIDStream().sorted()::iterator)
|
||||
for (DimensionType dim : DimensionType.func_212681_b())
|
||||
sendTime(ctx.getSource(), dim);
|
||||
|
||||
double meanTickTime = mean(ctx.getSource().getServer().tickTimeArray) * 1.0E-6D;
|
||||
@@ -59,26 +57,16 @@ class CommandTps
|
||||
);
|
||||
}
|
||||
|
||||
private static long[] getTimes(int dim)
|
||||
private static int sendTime(CommandSource cs, DimensionType dim) throws CommandSyntaxException
|
||||
{
|
||||
//TODO: Implement, needs patch.
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int sendTime(CommandSource cs, int dim) throws CommandSyntaxException
|
||||
{
|
||||
long[] times = getTimes(dim);
|
||||
long[] times = cs.getServer().getTickTime(dim);
|
||||
|
||||
if (times == null)
|
||||
throw INVALID_DIMENSION.create(dim);
|
||||
throw INVALID_DIMENSION.create(DimensionType.func_212678_a(dim));
|
||||
|
||||
double worldTickTime = mean(times) * 1.0E-6D;
|
||||
double worldTPS = Math.min(1000.0 / worldTickTime, 20);
|
||||
DimensionType type = DimensionManager.getProviderType(dim);
|
||||
if (type == null)
|
||||
cs.sendFeedback(new TextComponentTranslation("commands.forge.tps.summary.basic", dim, TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), true);
|
||||
else
|
||||
cs.sendFeedback(new TextComponentTranslation("commands.forge.tps.summary.named", dim, type.getName(), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), true);
|
||||
cs.sendFeedback(new TextComponentTranslation("commands.forge.tps.summary.named", dim.getId(), DimensionType.func_212678_a(dim), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), true);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
@@ -154,21 +155,6 @@ class CommandTrack
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates a world dimension ID into a name
|
||||
*
|
||||
* @param dimId The dimension ID
|
||||
* @return The name of the dimension
|
||||
*/
|
||||
protected static String getWorldName(int dimId)
|
||||
{
|
||||
DimensionType type = DimensionManager.getProviderType(dimId);
|
||||
if (type == null)
|
||||
return "Dim " + dimId;
|
||||
else
|
||||
return type.getName();
|
||||
}
|
||||
}
|
||||
|
||||
private static class TrackResultsEntity
|
||||
@@ -185,7 +171,7 @@ class CommandTrack
|
||||
double averageTimings = data.getAverageTimings();
|
||||
String tickTime = (averageTimings > 1000 ? TIME_FORMAT.format(averageTimings / 1000) : TIME_FORMAT.format(averageTimings)) + (averageTimings < 1000 ? "�s" : "ms");
|
||||
|
||||
return new TextComponentTranslation("commands.forge.tracking.timing_entry", entity.getType().getRegistryName(), TrackResults.getWorldName(entity.world.dimension.getId()), pos.getX(), pos.getY(), pos.getZ(), tickTime);
|
||||
return new TextComponentTranslation("commands.forge.tracking.timing_entry", entity.getType().getRegistryName(), DimensionType.func_212678_a(entity.world.dimension.getType()), pos.getX(), pos.getY(), pos.getZ(), tickTime);
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -205,7 +191,7 @@ class CommandTrack
|
||||
|
||||
double averageTimings = data.getAverageTimings();
|
||||
String tickTime = (averageTimings > 1000 ? TIME_FORMAT.format(averageTimings / 1000) : TIME_FORMAT.format(averageTimings)) + (averageTimings < 1000 ? "�s" : "ms");
|
||||
return new TextComponentTranslation("commands.forge.tracking.timing_entry", te.getType().getRegistryName(), TrackResults.getWorldName(te.getWorld().dimension.getId()), pos.getX(), pos.getY(), pos.getZ(), tickTime);
|
||||
return new TextComponentTranslation("commands.forge.tracking.timing_entry", te.getType().getRegistryName(), DimensionType.func_212678_a(te.getWorld().dimension.getType()), pos.getX(), pos.getY(), pos.getZ(), tickTime);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user