mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
World and TileEntity patch work.
TerrtainGen events are removed, 1.13's world gen re-write invalidates them all.
This commit is contained in:
1 parent
b7b5dd5bea
commit
f13465012b
111 files changed
+2790
-5201
No files matched your search
@@ -50,6 +50,7 @@ import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||
import net.minecraft.world.storage.ThreadedFileIOBase;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
@@ -143,18 +144,6 @@ public class ForgeChunkManager
|
||||
}
|
||||
}
|
||||
|
||||
public static Iterator<Chunk> getPersistentChunksIterableFor(final World world, Iterator<Chunk> chunkIterator)
|
||||
{
|
||||
final ImmutableSetMultimap<ChunkPos, Ticket> persistentChunksFor = getPersistentChunksFor(world);
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* All mods requiring chunkloading need to implement this to handle the
|
||||
* re-registration of chunk tickets at world loading time
|
||||
@@ -994,25 +983,29 @@ public class ForgeChunkManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void storeChunkNBT(Chunk chunk, NBTTagCompound nbt)
|
||||
public static void storeChunkNBT(World world, IChunk ichunk, NBTTagCompound nbt)
|
||||
{
|
||||
if (dormantChunkCacheSize == 0) return;
|
||||
|
||||
Cache<Long, ChunkEntry> cache = dormantChunkCache.get(chunk.getWorld());
|
||||
Cache<Long, ChunkEntry> cache = dormantChunkCache.get(world);
|
||||
if (cache == null) return;
|
||||
|
||||
ChunkEntry entry = cache.getIfPresent(ChunkPos.asLong(chunk.x, chunk.z));
|
||||
ChunkEntry entry = cache.getIfPresent(ichunk.getPos().asLong());
|
||||
if (entry != null)
|
||||
{
|
||||
entry.nbt.setTag("Entities", nbt.getList("Entities", Constants.NBT.TAG_COMPOUND));
|
||||
entry.nbt.setTag("TileEntities", nbt.getList("TileEntities", Constants.NBT.TAG_COMPOUND));
|
||||
|
||||
ClassInheritanceMultiMap<Entity>[] entityLists = chunk.getEntityLists();
|
||||
for (int i = 0; i < entityLists.length; ++i)
|
||||
if (ichunk instanceof Chunk)
|
||||
{
|
||||
entityLists[i] = new ClassInheritanceMultiMap<>(Entity.class);
|
||||
Chunk chunk = (Chunk)ichunk;
|
||||
ClassInheritanceMultiMap<Entity>[] entityLists = chunk.getEntityLists();
|
||||
for (int i = 0; i < entityLists.length; ++i)
|
||||
{
|
||||
entityLists[i] = new ClassInheritanceMultiMap<>(Entity.class);
|
||||
}
|
||||
chunk.getTileEntityMap().clear();
|
||||
}
|
||||
chunk.getTileEntityMap().clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -154,12 +154,16 @@ public class ForgeConfig
|
||||
public static int clumpingThreshold() {
|
||||
return ForgeConfig.INSTANCE.configData.<Integer>getOrElse("general.clumpingThreshold", 64);
|
||||
}
|
||||
public static boolean removeErroringEntities() {
|
||||
return ForgeConfig.INSTANCE.configData.<Boolean>getOrElse("general.removeErroringEntities", false);
|
||||
}
|
||||
public static boolean removeErroringTileEntities() {
|
||||
return ForgeConfig.INSTANCE.configData.<Boolean>getOrElse("general.removeErroringTileEntities", false);
|
||||
}
|
||||
}
|
||||
|
||||
//General
|
||||
//public static boolean disableVersionCheck = false;
|
||||
//public static boolean removeErroringEntities = false;
|
||||
//public static boolean removeErroringTileEntities = false;
|
||||
//public static boolean fullBoundingBoxLadders = false;
|
||||
//public static boolean logCascadingWorldGeneration = true; // see Chunk#logCascadingWorldGeneration()
|
||||
//public static boolean fixVanillaCascading = false;
|
||||
|
||||
@@ -43,8 +43,6 @@ public class MinecraftForge
|
||||
* EVENT_BUS for everything else
|
||||
*/
|
||||
public static final IEventBus EVENT_BUS = IEventBus.create();
|
||||
public static final IEventBus TERRAIN_GEN_BUS = IEventBus.create();
|
||||
public static final IEventBus ORE_GEN_BUS = IEventBus.create();
|
||||
|
||||
static final ForgeInternalHandler INTERNAL_HANDLER = new ForgeInternalHandler();
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@@ -22,9 +22,18 @@ package net.minecraftforge.common.extensions;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.audio.MusicTicker;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.dimension.NetherDimension;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.IRenderHandler;
|
||||
@@ -105,12 +114,12 @@ public interface IForgeDimension
|
||||
|
||||
void resetRainAndThunder();
|
||||
|
||||
default boolean canDoLightning(net.minecraft.world.chunk.Chunk chunk)
|
||||
default boolean canDoLightning(Chunk chunk)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
default boolean canDoRainSnowIce(net.minecraft.world.chunk.Chunk chunk)
|
||||
default boolean canDoRainSnowIce(Chunk chunk)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -126,4 +135,152 @@ public interface IForgeDimension
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
default Biome getBiome(BlockPos pos)
|
||||
{
|
||||
return getDimension().getWorld().getBiomeBody(pos);
|
||||
}
|
||||
|
||||
default boolean isDaytime()
|
||||
{
|
||||
return getDimension().getWorld().getSkylightSubtracted() < 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* The current sun brightness factor for this dimension.
|
||||
* 0.0f means no light at all, and 1.0f means maximum sunlight.
|
||||
* This will be used for the "calculateSkylightSubtracted"
|
||||
* which is for Sky light value calculation.
|
||||
*
|
||||
* @return The current brightness factor
|
||||
**/
|
||||
default float getSunBrightnessFactor(float partialTicks)
|
||||
{
|
||||
return getDimension().getWorld().getSunBrightnessFactor(partialTicks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Sun Brightness for rendering sky.
|
||||
* */
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default float getSunBrightness(float partialTicks)
|
||||
{
|
||||
return getDimension().getWorld().getSunBrightnessBody(partialTicks);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default Vec3d getSkyColor(Entity cameraEntity, float partialTicks)
|
||||
{
|
||||
return getDimension().getWorld().getSkyColorBody(cameraEntity, partialTicks);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default Vec3d getCloudColor(float partialTicks)
|
||||
{
|
||||
return getDimension().getWorld().getCloudColorBody(partialTicks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the current moon phase factor.
|
||||
* This factor is effective for slimes.
|
||||
* (This method do not affect the moon rendering)
|
||||
* */
|
||||
default float getCurrentMoonPhaseFactor(long time)
|
||||
{
|
||||
return Dimension.MOON_PHASE_FACTORS[this.getDimension().getMoonPhase(time)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Star Brightness for rendering sky.
|
||||
* */
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default float getStarBrightness(float partialTicks)
|
||||
{
|
||||
float f = getDimension().getWorld().getCelestialAngle(partialTicks);
|
||||
float f1 = 1.0F - (MathHelper.cos(f * ((float)Math.PI * 2F)) * 2.0F + 0.25F);
|
||||
f1 = MathHelper.clamp(f1, 0.0F, 1.0F);
|
||||
return f1 * f1 * 0.5F;
|
||||
}
|
||||
|
||||
default void setAllowedSpawnTypes(boolean allowHostile, boolean allowPeaceful) { }
|
||||
|
||||
default void calculateInitialWeather()
|
||||
{
|
||||
getDimension().getWorld().calculateInitialWeatherBody();
|
||||
}
|
||||
|
||||
default void updateWeather()
|
||||
{
|
||||
getDimension().getWorld().updateWeatherBody();
|
||||
}
|
||||
|
||||
default long getSeed()
|
||||
{
|
||||
return getDimension().getWorld().getWorldInfo().getSeed();
|
||||
}
|
||||
|
||||
default long getWorldTime()
|
||||
{
|
||||
return getDimension().getWorld().getWorldInfo().getDayTime();
|
||||
}
|
||||
|
||||
default void setWorldTime(long time)
|
||||
{
|
||||
getDimension().getWorld().getWorldInfo().setDayTime(time);
|
||||
}
|
||||
|
||||
default BlockPos getSpawnPoint()
|
||||
{
|
||||
WorldInfo info = getDimension().getWorld().getWorldInfo();
|
||||
return new BlockPos(info.getSpawnX(), info.getSpawnY(), info.getSpawnZ());
|
||||
}
|
||||
|
||||
default void setSpawnPoint(BlockPos pos)
|
||||
{
|
||||
getDimension().getWorld().getWorldInfo().setSpawn(pos);
|
||||
}
|
||||
|
||||
default boolean canMineBlock(EntityPlayer player, BlockPos pos)
|
||||
{
|
||||
return getDimension().getWorld().canMineBlockBody(player, pos);
|
||||
}
|
||||
|
||||
default boolean isHighHumidity(BlockPos pos)
|
||||
{
|
||||
return getDimension().getWorld().getBiome(pos).isHighHumidity();
|
||||
}
|
||||
|
||||
default int getHeight()
|
||||
{
|
||||
return 256;
|
||||
}
|
||||
|
||||
default int getActualHeight()
|
||||
{
|
||||
return getDimension().isNether() ? 128 : 256;
|
||||
}
|
||||
|
||||
default double getHorizon()
|
||||
{
|
||||
return getDimension().getWorld().getWorldInfo().getTerrainType().getHorizon(getDimension().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.
|
||||
*
|
||||
* @param entity The entity holding the map, playername, or frame-ENTITYID
|
||||
* @param x X Position
|
||||
* @param z Z Position
|
||||
* @param rotation the regular rotation of the marker
|
||||
* @return True to 'spin' the cursor
|
||||
*/
|
||||
default boolean shouldMapSpin(String entity, double x, double z, double rotation)
|
||||
{
|
||||
return getId() < 0;
|
||||
}
|
||||
}
|
||||
@@ -71,4 +71,12 @@ public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound
|
||||
* @return A compound tag for custom data
|
||||
*/
|
||||
NBTTagCompound getTileData();
|
||||
|
||||
default void onChunkUnloaded(){}
|
||||
|
||||
/**
|
||||
* Called when this is first added to the world (by {@link World#addTileEntity(TileEntity)}).
|
||||
* Override instead of adding {@code if (firstTick)} stuff in update.
|
||||
*/
|
||||
default void onLoad(){}
|
||||
}
|
||||
@@ -19,9 +19,44 @@
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
/**
|
||||
* Used in the getEntitiesWithinAABB functions to expand the search area for entities.
|
||||
* Modders should change this variable to a higher value if it is less then the radius
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user