commit
36882363b9
31 changed files with 1056 additions and 1657 deletions
|
@ -10,9 +10,8 @@ import net.minecraft.potion.PotionEffect;
|
|||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
public class Spells
|
||||
{
|
||||
public EntityPlayer player;
|
||||
public class Spells {
|
||||
/*public EntityPlayer player;
|
||||
public int spellID;
|
||||
public int castingTime=0;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public class BlockDimWallPerm extends Block {
|
|||
destinationX += (destinationX >> 4);
|
||||
destinationZ += (destinationZ >> 4);
|
||||
|
||||
int destinationY = yCoordHelper.getFirstUncovered(overworld, destinationX, 63, destinationZ, true);
|
||||
int destinationY = yCoordHelper.getFirstUncovered(overworld, new BlockPos(destinationX, 63, destinationZ), true);
|
||||
|
||||
BlockPos destPos = new BlockPos(destinationX, destinationY, destinationZ);
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
|
@ -14,13 +15,11 @@ public class CommandDeleteRifts extends DDCommandBase
|
|||
{
|
||||
private static CommandDeleteRifts instance = null;
|
||||
|
||||
private CommandDeleteRifts()
|
||||
{
|
||||
private CommandDeleteRifts() {
|
||||
super("dd-deleterifts", "[dimension number]");
|
||||
}
|
||||
|
||||
public static CommandDeleteRifts instance()
|
||||
{
|
||||
public static CommandDeleteRifts instance() {
|
||||
if (instance == null)
|
||||
instance = new CommandDeleteRifts();
|
||||
|
||||
|
@ -28,58 +27,41 @@ public class CommandDeleteRifts extends DDCommandBase
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
|
||||
int linksRemoved = 0;
|
||||
int targetDimension;
|
||||
|
||||
if (command.length > 1)
|
||||
{
|
||||
if (command.length > 1) {
|
||||
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||
}
|
||||
if (command.length == 0)
|
||||
{
|
||||
targetDimension = sender.worldObj.provider.dimensionId;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
if (command.length == 0) {
|
||||
targetDimension = sender.worldObj.provider.getDimensionId();
|
||||
} else {
|
||||
try {
|
||||
targetDimension = Integer.parseInt(command[0]);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
} catch (NumberFormatException e) {
|
||||
return DDCommandResult.INVALID_DIMENSION_ID;
|
||||
}
|
||||
}
|
||||
|
||||
World world = PocketManager.loadDimension(targetDimension);
|
||||
if (world == null)
|
||||
{
|
||||
if (world == null) {
|
||||
return DDCommandResult.UNREGISTERED_DIMENSION;
|
||||
}
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
BlockPos pos;
|
||||
Point4D location;
|
||||
DimData dimension = PocketManager.createDimensionData(world);
|
||||
ArrayList<DimLink> links = dimension.getAllLinks();
|
||||
for (DimLink link : links)
|
||||
{
|
||||
for (DimLink link : links) {
|
||||
location = link.source();
|
||||
x = location.getX();
|
||||
y = location.getY();
|
||||
z = location.getZ();
|
||||
if (world.getBlock(x, y, z) == DimDoors.blockRift)
|
||||
{
|
||||
pos = location.toBlockPos();
|
||||
if (world.getBlockState(pos).getBlock() == DimDoors.blockRift) {
|
||||
// Remove the rift and its link
|
||||
world.setBlockToAir(x, y, z);
|
||||
world.setBlockToAir(pos);
|
||||
dimension.deleteLink(link);
|
||||
linksRemoved++;
|
||||
}
|
||||
else if (!DimDoors.blockRift.isBlockImmune(world, x, y, z))
|
||||
{
|
||||
} else if (!DimDoors.blockRift.isBlockImmune(world, pos)) {
|
||||
// If a block is not immune, then it must not be a DD block.
|
||||
// The link would regenerate into a rift eventually.
|
||||
// We only need to remove the link.
|
||||
|
|
|
@ -366,8 +366,7 @@ public class DDTeleporter {
|
|||
* @param link - the link the player is using to teleport; sends the player to its destination
|
||||
* @param entity - the instance of the player to be teleported
|
||||
*/
|
||||
public static void traverseDimDoor(World world, DimLink link,
|
||||
Entity entity, Block door) throws IllegalArgumentException {
|
||||
public static void traverseDimDoor(World world, DimLink link, Entity entity, Block door) throws IllegalArgumentException {
|
||||
if(world.isRemote) return;
|
||||
if(world == null) throw new IllegalArgumentException("world cannot be null.");
|
||||
if(link == null) throw new IllegalArgumentException("link cannot be null.");
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.zixiken.dimdoors.DimDoors;
|
|||
import com.zixiken.dimdoors.watcher.IUpdateWatcher;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
@ -32,10 +33,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
* player, and creating/registering new dimensions as well as loading old
|
||||
* dimensions on startup
|
||||
*/
|
||||
public class PocketManager
|
||||
{
|
||||
private static class InnerDimData extends DimData
|
||||
{
|
||||
public class PocketManager {
|
||||
private static class InnerDimData extends DimData {
|
||||
// This class allows us to instantiate DimData indirectly without
|
||||
// exposing
|
||||
// a public constructor from DimData. It's meant to stop us from
|
||||
|
@ -45,42 +44,36 @@ public class PocketManager
|
|||
// that any link destinations must be real dimensions controlled by
|
||||
// PocketManager.
|
||||
|
||||
public InnerDimData(int id, InnerDimData parent, DimensionType type, IUpdateWatcher<ClientLinkData> linkWatcher)
|
||||
{
|
||||
public InnerDimData(int id, InnerDimData parent, DimensionType type, IUpdateWatcher<ClientLinkData> linkWatcher) {
|
||||
super(id, parent, type, linkWatcher);
|
||||
}
|
||||
|
||||
public InnerDimData(int id, DimData root, DimensionType type)
|
||||
{
|
||||
public InnerDimData(int id, DimData root, DimensionType type) {
|
||||
// This constructor is meant for client-side code only
|
||||
super(id, root, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class ClientLinkWatcher implements IUpdateWatcher<ClientLinkData>
|
||||
{
|
||||
public static class ClientLinkWatcher implements IUpdateWatcher<ClientLinkData> {
|
||||
@Override
|
||||
public void onCreated(ClientLinkData link)
|
||||
{
|
||||
public void onCreated(ClientLinkData link) {
|
||||
Point4D source = link.point;
|
||||
DimData dimension = getDimensionData(source.getDimension());
|
||||
if (dimension != null && dimension.getLink(source.getX(), source.getY(), source.getZ()) == null)
|
||||
dimension.createLink(source, LinkType.CLIENT, 0, link.lock);
|
||||
if (dimension != null && dimension.getLink(source.toBlockPos()) == null)
|
||||
dimension.createLink(source, LinkType.CLIENT, EnumFacing.SOUTH, link.lock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(ClientLinkData link)
|
||||
{
|
||||
public void onDeleted(ClientLinkData link) {
|
||||
Point4D source = link.point;
|
||||
DimData dimension = getDimensionData(source.getDimension());
|
||||
if (dimension != null && dimension.getLink(source.getX(),source.getY(),source.getZ()) != null)
|
||||
dimension.deleteLink(source.getX(), source.getY(), source.getZ());
|
||||
if (dimension != null && dimension.getLink(source.toBlockPos()) != null)
|
||||
dimension.deleteLink(source.toBlockPos());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ClientLinkData link)
|
||||
{
|
||||
public void update(ClientLinkData link) {
|
||||
Point4D source = link.point;
|
||||
DimData dimension = getDimensionData(source.getDimension());
|
||||
if (dimension != null) {
|
||||
|
@ -90,29 +83,22 @@ public class PocketManager
|
|||
}
|
||||
}
|
||||
|
||||
public static class ClientDimWatcher implements IUpdateWatcher<ClientDimData>
|
||||
{
|
||||
public static class ClientDimWatcher implements IUpdateWatcher<ClientDimData> {
|
||||
@Override
|
||||
public void onCreated(ClientDimData data)
|
||||
{
|
||||
public void onCreated(ClientDimData data) {
|
||||
registerClientDimension(data.ID, data.rootID, data.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(ClientDimData data)
|
||||
{
|
||||
public void onDeleted(ClientDimData data) {
|
||||
deletePocket(getDimensionData(data.ID), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ClientDimData message)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
public void update(ClientDimData message) {}
|
||||
}
|
||||
|
||||
private static class DimRegistrationCallback implements IDimRegistrationCallback
|
||||
{
|
||||
private static class DimRegistrationCallback implements IDimRegistrationCallback {
|
||||
// We use this class to provide Compactor with the ability to send us
|
||||
// dim data without
|
||||
// having to instantiate a bunch of data containers and without exposing
|
||||
|
@ -122,8 +108,7 @@ public class PocketManager
|
|||
// exposing a private constructor ONLY to a very specific trusted class.
|
||||
|
||||
@Override
|
||||
public DimData registerDimension(int dimensionID, int rootID, DimensionType type)
|
||||
{
|
||||
public DimData registerDimension(int dimensionID, int rootID, DimensionType type) {
|
||||
return registerClientDimension(dimensionID, rootID, type);
|
||||
}
|
||||
}
|
||||
|
@ -151,8 +136,7 @@ public class PocketManager
|
|||
// Stores all the personal pocket mappings
|
||||
private static HashMap<String, DimData> personalPocketsMapping = null;
|
||||
|
||||
public static boolean isLoaded()
|
||||
{
|
||||
public static boolean isLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
|
@ -162,14 +146,11 @@ public class PocketManager
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public static void load()
|
||||
{
|
||||
if (isLoaded)
|
||||
{
|
||||
public static void load() {
|
||||
if (isLoaded) {
|
||||
throw new IllegalStateException("Pocket dimensions have already been loaded!");
|
||||
}
|
||||
if (isLoading)
|
||||
{
|
||||
if (isLoading) {
|
||||
return;
|
||||
}
|
||||
isLoading = true;
|
||||
|
@ -179,8 +160,7 @@ public class PocketManager
|
|||
dimensionIDBlackList = new ArrayList<Integer>();
|
||||
personalPocketsMapping = new HashMap<String, DimData>();
|
||||
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
// Shouldnt try to load everything if we are a client
|
||||
// This was preventing onPacket from loading properly
|
||||
isLoading = false;
|
||||
|
@ -200,37 +180,32 @@ public class PocketManager
|
|||
isLoading = false;
|
||||
}
|
||||
|
||||
public static boolean registerPackedDimData(PackedDimData packedData)
|
||||
{
|
||||
public static boolean registerPackedDimData(PackedDimData packedData) {
|
||||
InnerDimData dimData;
|
||||
DimensionType type = DimensionType.getTypeFromIndex(packedData.DimensionType);
|
||||
if (type == null)
|
||||
{
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("Invalid dimension type");
|
||||
}
|
||||
|
||||
// register roots
|
||||
if (packedData.ID == packedData.ParentID)
|
||||
{
|
||||
if (packedData.ID == packedData.ParentID) {
|
||||
dimData = new InnerDimData(packedData.ID, null, type, linkWatcher);
|
||||
dimData.root = dimData;
|
||||
dimData.parent = dimData;
|
||||
dimData.depth = packedData.Depth;
|
||||
dimData.isFilled = packedData.IsFilled;
|
||||
dimData.origin = new Point4D(packedData.Origin.getX(), packedData.Origin.getY(), packedData.Origin.getZ(), packedData.ID);
|
||||
dimData.origin = new Point4D(packedData.Origin, packedData.ID);
|
||||
|
||||
PocketManager.rootDimensions.add(dimData);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
// register children
|
||||
{
|
||||
InnerDimData test = PocketManager.dimensionData.get(packedData.ParentID);
|
||||
dimData = new InnerDimData(packedData.ID, test, type, linkWatcher);
|
||||
dimData.isFilled = packedData.IsFilled;
|
||||
dimData.origin = new Point4D(packedData.Origin.getX(), packedData.Origin.getY(), packedData.Origin.getZ(), packedData.ID);
|
||||
dimData.origin = new Point4D(packedData.Origin, packedData.ID);
|
||||
dimData.root = PocketManager.createDimensionData(packedData.RootID);
|
||||
|
||||
if (packedData.DungeonData != null)
|
||||
{
|
||||
if (packedData.DungeonData != null) {
|
||||
dimData.dungeon = DDSaveHandler.unpackDungeonData(packedData.DungeonData);
|
||||
}
|
||||
|
||||
|
@ -241,18 +216,15 @@ public class PocketManager
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean deletePocket(DimData target, boolean deleteFolder)
|
||||
{
|
||||
public static boolean deletePocket(DimData target, boolean deleteFolder) {
|
||||
// We can't delete the dimension if it's currently loaded or if it's not
|
||||
// actually a pocket.
|
||||
// We cast to InnerDimData so that if anyone tries to be a smartass and
|
||||
// create their
|
||||
// own version of DimData, this will throw an exception.
|
||||
InnerDimData dimension = (InnerDimData) target;
|
||||
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null)
|
||||
{
|
||||
if (deleteFolder)
|
||||
{
|
||||
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null) {
|
||||
if (deleteFolder) {
|
||||
deleteDimensionFiles(dimension);
|
||||
}
|
||||
// Note: We INTENTIONALLY don't unregister the dimensions that we
|
||||
|
@ -267,8 +239,7 @@ public class PocketManager
|
|||
return false;
|
||||
}
|
||||
|
||||
private static void deleteDimensionFiles(InnerDimData dimension)
|
||||
{
|
||||
private static void deleteDimensionFiles(InnerDimData dimension) {
|
||||
// We assume that the caller checks if the dimension is loaded, for the
|
||||
// sake of efficiency. Don't call this on a loaded dimension or bad
|
||||
// things will happen!
|
||||
|
@ -279,45 +250,32 @@ public class PocketManager
|
|||
dataFile.delete();
|
||||
}
|
||||
|
||||
private static void deleteDimensionData(InnerDimData dimension)
|
||||
{
|
||||
private static void deleteDimensionData(InnerDimData dimension) {
|
||||
// We assume that the caller checks if the dimension is loaded, for the
|
||||
// sake of efficiency. Don't call this on a loaded dimension or bad
|
||||
// things will happen!
|
||||
if (dimensionData.remove(dimension.id()) != null)
|
||||
{
|
||||
if (dimensionData.remove(dimension.id()) != null) {
|
||||
// Raise the dim deleted event
|
||||
getDimwatcher().onDeleted(new ClientDimData(dimension));
|
||||
dimension.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// This should never happen. A simple sanity check.
|
||||
throw new IllegalArgumentException("The specified dimension is not listed with PocketManager.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerPockets(DDProperties properties)
|
||||
{
|
||||
for (DimData dimension : dimensionData.values())
|
||||
{
|
||||
if (dimension.isPocketDimension())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dimension.type() == DimensionType.PERSONAL)
|
||||
{
|
||||
private static void registerPockets(DDProperties properties) {
|
||||
for (DimData dimension : dimensionData.values()) {
|
||||
if (dimension.isPocketDimension()) {
|
||||
try {
|
||||
if (dimension.type() == DimensionType.PERSONAL) {
|
||||
if (!DimensionManager.isDimensionRegistered(dimension.id())){
|
||||
DimensionManager.registerDimension(dimension.id(), properties.PersonalPocketProviderID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
DimensionManager.registerDimension(dimension.id(), properties.PocketProviderID);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
System.err.println("Could not register pocket dimension #" + dimension.id()
|
||||
+ ". Probably caused by a version update/save data corruption/other mods.");
|
||||
e.printStackTrace();
|
||||
|
@ -326,30 +284,23 @@ public class PocketManager
|
|||
}
|
||||
}
|
||||
|
||||
private static void unregisterPockets()
|
||||
{
|
||||
for (DimData dimension : dimensionData.values())
|
||||
{
|
||||
if (dimension.isPocketDimension())
|
||||
{
|
||||
try
|
||||
{
|
||||
private static void unregisterPockets() {
|
||||
for (DimData dimension : dimensionData.values()) {
|
||||
if (dimension.isPocketDimension()) {
|
||||
try {
|
||||
DimensionManager.unregisterDimension(dimension.id());
|
||||
}
|
||||
catch (Exception e)
|
||||
} catch (Exception e)
|
||||
{
|
||||
System.err.println("An unexpected error occurred while unregistering pocket dimension #" + dimension.id() + ":");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Integer dimID : dimensionIDBlackList)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
for (Integer dimID : dimensionIDBlackList) {
|
||||
try {
|
||||
DimensionManager.unregisterDimension(dimID);
|
||||
}
|
||||
catch (Exception e)
|
||||
} catch (Exception e)
|
||||
{
|
||||
System.err.println("An unexpected error occurred while unregistering blacklisted dim #" + dimID + ":");
|
||||
e.printStackTrace();
|
||||
|
@ -361,27 +312,21 @@ public class PocketManager
|
|||
* loads the dim data from the saved hashMap. Also handles compatibility
|
||||
* with old saves, see OldSaveHandler
|
||||
*/
|
||||
private static void loadInternal()
|
||||
{
|
||||
private static void loadInternal() {
|
||||
File saveDir = DimensionManager.getCurrentSaveRootDirectory();
|
||||
if (saveDir != null)
|
||||
{
|
||||
if (saveDir != null) {
|
||||
// Try to import data from old DD versions
|
||||
// TODO - remove this code in a few versions
|
||||
File oldSaveData = new File(saveDir + "/DimensionalDoorsData");
|
||||
if (oldSaveData.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (oldSaveData.exists()) {
|
||||
try {
|
||||
System.out.println("Importing old DD save data...");
|
||||
OldSaveImporter.importOldSave(oldSaveData);
|
||||
|
||||
oldSaveData.renameTo(new File(oldSaveData.getAbsolutePath() + "_IMPORTED"));
|
||||
|
||||
System.out.println("Import Succesful!");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
// TODO handle fail cases
|
||||
System.out.println("Import failed!");
|
||||
e.printStackTrace();
|
||||
|
@ -391,66 +336,51 @@ public class PocketManager
|
|||
|
||||
// Load save data
|
||||
System.out.println("Loading Dimensional Doors save data...");
|
||||
if (DDSaveHandler.loadAll())
|
||||
{
|
||||
if (DDSaveHandler.loadAll()) {
|
||||
System.out.println("Loaded successfully!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(boolean checkModified)
|
||||
{
|
||||
if (!isLoaded)
|
||||
{
|
||||
public static void save(boolean checkModified) {
|
||||
if (!isLoaded) {
|
||||
return;
|
||||
}
|
||||
// Check this last to make sure we set the flag shortly after.
|
||||
if (isSaving)
|
||||
{
|
||||
if (isSaving) {
|
||||
return;
|
||||
}
|
||||
isSaving = true;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
DDSaveHandler.saveAll(dimensionData.values(), dimensionIDBlackList, checkModified);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
// Wrap the exception in a RuntimeException so functions that call
|
||||
// PocketManager.save() don't need to catch it. We want MC to
|
||||
// crash if something really bad happens rather than ignoring it!
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
} finally {
|
||||
isSaving = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static WorldServer loadDimension(int id)
|
||||
{
|
||||
if (!DimensionManager.isDimensionRegistered(id))
|
||||
{
|
||||
public static WorldServer loadDimension(int id) {
|
||||
if (!DimensionManager.isDimensionRegistered(id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
WorldServer world = DimensionManager.getWorld(id);
|
||||
if (world == null)
|
||||
{
|
||||
if (world == null) {
|
||||
DimensionManager.initDimension(id);
|
||||
world = DimensionManager.getWorld(id);
|
||||
}
|
||||
else if (world.provider == null)
|
||||
{
|
||||
} else if (world.provider == null) {
|
||||
DimensionManager.initDimension(id);
|
||||
world = DimensionManager.getWorld(id);
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
public static DimData registerDimension(World world)
|
||||
{
|
||||
public static DimData registerDimension(World world) {
|
||||
return registerDimension(world.provider.getDimensionId(), null, DimensionType.ROOT);
|
||||
}
|
||||
|
||||
|
@ -462,10 +392,8 @@ public class PocketManager
|
|||
* @param playername
|
||||
* @return
|
||||
*/
|
||||
public static DimData registerPocket(DimData parent, DimensionType type, String playername)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
public static DimData registerPocket(DimData parent, DimensionType type, String playername) {
|
||||
if (parent == null) {
|
||||
throw new IllegalArgumentException("parent cannot be null. A pocket dimension must always have a parent dimension.");
|
||||
}
|
||||
|
||||
|
@ -473,22 +401,18 @@ public class PocketManager
|
|||
int dimensionID = DimensionManager.getNextFreeDimId();
|
||||
|
||||
// register a personal pocket
|
||||
if (type == DimensionType.PERSONAL)
|
||||
{
|
||||
if (playername == null)
|
||||
{
|
||||
if (type == DimensionType.PERSONAL) {
|
||||
if (playername == null) {
|
||||
throw new IllegalArgumentException("A personal pocket must be attached to a playername");
|
||||
}
|
||||
DimensionManager.registerDimension(dimensionID, properties.PersonalPocketProviderID);
|
||||
DimData data = registerDimension(dimensionID, (InnerDimData) parent, type);
|
||||
personalPocketsMapping.put(playername, data);
|
||||
return data;
|
||||
}
|
||||
else
|
||||
{ // register a pocket as personal if its parents are personal, but
|
||||
} else
|
||||
{ // register a pocket as personal if its parents are personal, but
|
||||
// without a mapping.
|
||||
if (parent.type == DimensionType.PERSONAL)
|
||||
{
|
||||
if (parent.type == DimensionType.PERSONAL) {
|
||||
DimensionManager.registerDimension(dimensionID, properties.PersonalPocketProviderID);
|
||||
DimData data = registerDimension(dimensionID, (InnerDimData) parent, DimensionType.PERSONAL);
|
||||
return data;
|
||||
|
@ -501,8 +425,7 @@ public class PocketManager
|
|||
|
||||
}
|
||||
|
||||
public static DimData registerPocket(DimData parent, DimensionType type)
|
||||
{
|
||||
public static DimData registerPocket(DimData parent, DimensionType type) {
|
||||
return registerPocket(parent, type, null);
|
||||
}
|
||||
|
||||
|
@ -514,20 +437,16 @@ public class PocketManager
|
|||
* @param type
|
||||
* @return
|
||||
*/
|
||||
private static DimData registerDimension(int dimensionID, InnerDimData parent, DimensionType type)
|
||||
{
|
||||
if (dimensionData.containsKey(dimensionID))
|
||||
{
|
||||
if (PocketManager.dimensionIDBlackList.contains(dimensionID))
|
||||
{
|
||||
private static DimData registerDimension(int dimensionID, InnerDimData parent, DimensionType type) {
|
||||
if (dimensionData.containsKey(dimensionID)) {
|
||||
if (PocketManager.dimensionIDBlackList.contains(dimensionID)) {
|
||||
throw new IllegalArgumentException("Cannot register a dimension with ID = " + dimensionID + " because it has been blacklisted.");
|
||||
}
|
||||
throw new IllegalArgumentException("Cannot register a dimension with ID = " + dimensionID + " because it has already been registered.");
|
||||
}
|
||||
InnerDimData dimension = new InnerDimData(dimensionID, parent, type, linkWatcher);
|
||||
dimensionData.put(dimensionID, dimension);
|
||||
if (!dimension.isPocketDimension())
|
||||
{
|
||||
if (!dimension.isPocketDimension()) {
|
||||
rootDimensions.add(dimension);
|
||||
}
|
||||
getDimwatcher().onCreated(new ClientDimData(dimension));
|
||||
|
@ -536,9 +455,7 @@ public class PocketManager
|
|||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static DimData registerClientDimension(int dimensionID, int rootID, DimensionType type)
|
||||
|
||||
{
|
||||
private static DimData registerClientDimension(int dimensionID, int rootID, DimensionType type) {
|
||||
// No need to raise events heres since this code should only run on the
|
||||
// client side. createDimensionData() always handles root dimensions
|
||||
// properly, even if they weren't defined before.
|
||||
|
@ -550,21 +467,17 @@ public class PocketManager
|
|||
InnerDimData root = (InnerDimData) createDimensionData(rootID);
|
||||
InnerDimData dimension;
|
||||
|
||||
if (rootID != dimensionID)
|
||||
{
|
||||
if (rootID != dimensionID) {
|
||||
dimension = dimensionData.get(dimensionID);
|
||||
if (dimension == null)
|
||||
{
|
||||
if (dimension == null) {
|
||||
dimension = new InnerDimData(dimensionID, root, type);
|
||||
dimensionData.put(dimension.id(), dimension);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dimension = root;
|
||||
}
|
||||
if (dimension.isPocketDimension() && !DimensionManager.isDimensionRegistered(dimension.id()))
|
||||
{
|
||||
|
||||
if (dimension.isPocketDimension() && !DimensionManager.isDimensionRegistered(dimension.id())) {
|
||||
// Im registering pocket dims here. I *think* we can assume that if
|
||||
// its a pocket and we are
|
||||
// registering its dim data, we also need to register it with forge.
|
||||
|
@ -581,23 +494,19 @@ public class PocketManager
|
|||
return dimension;
|
||||
}
|
||||
|
||||
public static DimData getDimensionData(int dimensionID)
|
||||
{
|
||||
public static DimData getDimensionData(int dimensionID) {
|
||||
return PocketManager.dimensionData.get(dimensionID);
|
||||
}
|
||||
|
||||
public static DimData getDimensionData(World dimension)
|
||||
{
|
||||
public static DimData getDimensionData(World dimension) {
|
||||
return PocketManager.dimensionData.get(dimension.provider.getDimensionId());
|
||||
}
|
||||
|
||||
public static DimData createDimensionData(World world)
|
||||
{
|
||||
public static DimData createDimensionData(World world) {
|
||||
return createDimensionData(world.provider.getDimensionId());
|
||||
}
|
||||
|
||||
public static DimData createDimensionDataDangerously(int dimensionID)
|
||||
{
|
||||
public static DimData createDimensionDataDangerously(int dimensionID) {
|
||||
// Same as createDimensionData(int), but public. Meant to discourage
|
||||
// anyone from
|
||||
// using it unless absolutely needed! We'll probably phase this out
|
||||
|
@ -605,8 +514,7 @@ public class PocketManager
|
|||
return createDimensionData(dimensionID);
|
||||
}
|
||||
|
||||
protected static DimData createDimensionData(int dimensionID)
|
||||
{
|
||||
protected static DimData createDimensionData(int dimensionID) {
|
||||
// Retrieve the data for a dimension. If we don't have a record for that
|
||||
// dimension,
|
||||
// assume it's a non-pocket dimension that hasn't been initialized with
|
||||
|
@ -615,21 +523,18 @@ public class PocketManager
|
|||
DimData dimension = PocketManager.dimensionData.get(dimensionID);
|
||||
|
||||
// if we do not have a record of it, then it must be a root
|
||||
if (dimension == null)
|
||||
{
|
||||
if (dimension == null) {
|
||||
dimension = registerDimension(dimensionID, null, DimensionType.ROOT);
|
||||
}
|
||||
return dimension;
|
||||
}
|
||||
|
||||
public static Iterable<? extends DimData> getDimensions()
|
||||
{
|
||||
public static Iterable<? extends DimData> getDimensions() {
|
||||
return dimensionData.values();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ArrayList<DimData> getRootDimensions()
|
||||
{
|
||||
public static ArrayList<DimData> getRootDimensions() {
|
||||
return (ArrayList<DimData>) rootDimensions.clone();
|
||||
}
|
||||
|
||||
|
@ -640,11 +545,9 @@ public class PocketManager
|
|||
isLoaded = false;
|
||||
}
|
||||
|
||||
public static void unload()
|
||||
{
|
||||
public static void unload() {
|
||||
System.out.println("Unloading Pocket Dimensions...");
|
||||
if (!isLoaded)
|
||||
{
|
||||
if (!isLoaded) {
|
||||
throw new IllegalStateException("Pocket dimensions have already been unloaded!");
|
||||
}
|
||||
|
||||
|
@ -656,89 +559,69 @@ public class PocketManager
|
|||
isConnected = false;
|
||||
}
|
||||
|
||||
public static DimLink getLink(BlockPos pos, World world)
|
||||
{
|
||||
public static DimLink getLink(BlockPos pos, World world) {
|
||||
return getLink(pos, world.provider.getDimensionId());
|
||||
}
|
||||
|
||||
public static DimLink getLink(Point4D point)
|
||||
{
|
||||
return getLink(point.getX(), point.getY(), point.getZ(), point.getDimension());
|
||||
public static DimLink getLink(Point4D point) {
|
||||
return getLink(point.toBlockPos(), point.getDimension());
|
||||
}
|
||||
|
||||
public static DimLink getLink(int x, int y, int z, int dimensionID)
|
||||
{
|
||||
public static DimLink getLink(BlockPos pos, int dimensionID) {
|
||||
if (!isLoaded())
|
||||
return null;
|
||||
|
||||
DimData dimension = dimensionData.get(dimensionID);
|
||||
if (dimension != null)
|
||||
{
|
||||
return dimension.getLink(x, y, z);
|
||||
if (dimension != null) {
|
||||
return dimension.getLink(pos);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static DimLink getLink(BlockPos pos, int dimensionId) {
|
||||
return getLink(pos.getX(), pos.getY(), pos.getZ(), dimensionId);
|
||||
}
|
||||
|
||||
public static boolean isBlackListed(int dimensionID)
|
||||
{
|
||||
public static boolean isBlackListed(int dimensionID) {
|
||||
return PocketManager.dimensionIDBlackList.contains(dimensionID);
|
||||
}
|
||||
|
||||
public static void registerDimWatcher(IUpdateWatcher<ClientDimData> watcher)
|
||||
{
|
||||
public static void registerDimWatcher(IUpdateWatcher<ClientDimData> watcher) {
|
||||
getDimwatcher().registerReceiver(watcher);
|
||||
}
|
||||
|
||||
public static boolean unregisterDimWatcher(IUpdateWatcher<ClientDimData> watcher)
|
||||
{
|
||||
public static boolean unregisterDimWatcher(IUpdateWatcher<ClientDimData> watcher) {
|
||||
return getDimwatcher().unregisterReceiver(watcher);
|
||||
}
|
||||
|
||||
public static void registerLinkWatcher(IUpdateWatcher<ClientLinkData> watcher)
|
||||
{
|
||||
public static void registerLinkWatcher(IUpdateWatcher<ClientLinkData> watcher) {
|
||||
linkWatcher.registerReceiver(watcher);
|
||||
}
|
||||
|
||||
public static boolean unregisterLinkWatcher(IUpdateWatcher<ClientLinkData> watcher)
|
||||
{
|
||||
public static boolean unregisterLinkWatcher(IUpdateWatcher<ClientLinkData> watcher) {
|
||||
return linkWatcher.unregisterReceiver(watcher);
|
||||
}
|
||||
|
||||
public static void writePacket(ByteBuf output) throws IOException
|
||||
{
|
||||
public static void writePacket(ByteBuf output) throws IOException {
|
||||
// Write a very compact description of our dimensions and links to be
|
||||
// sent to a client
|
||||
Compactor.write(dimensionData.values(), output);
|
||||
}
|
||||
|
||||
public static boolean isRegisteredInternally(int dimensionID)
|
||||
{
|
||||
public static boolean isRegisteredInternally(int dimensionID) {
|
||||
return dimensionData.containsKey(dimensionID);
|
||||
}
|
||||
|
||||
public static void createAndRegisterBlacklist(List<Integer> blacklist)
|
||||
{
|
||||
public static void createAndRegisterBlacklist(List<Integer> blacklist) {
|
||||
// TODO - create a special blacklist provider
|
||||
for (Integer dimID : blacklist)
|
||||
{
|
||||
for (Integer dimID : blacklist) {
|
||||
PocketManager.dimensionIDBlackList.add(dimID);
|
||||
DimensionManager.registerDimension(dimID, DDProperties.instance().PocketProviderID);
|
||||
}
|
||||
}
|
||||
|
||||
public static void readPacket(ByteBuf input) throws IOException
|
||||
{
|
||||
public static void readPacket(ByteBuf input) throws IOException {
|
||||
// TODO- figure out why this is getting called so frequently
|
||||
if (isLoaded)
|
||||
{
|
||||
if (isLoaded) {
|
||||
return;
|
||||
}
|
||||
if (isLoading)
|
||||
{
|
||||
if (isLoading) {
|
||||
throw new IllegalStateException("Pocket dimensions are already loading!");
|
||||
}
|
||||
// Load compacted client-side dimension data
|
||||
|
@ -750,33 +633,26 @@ public class PocketManager
|
|||
isConnected = true;
|
||||
}
|
||||
|
||||
public static UpdateWatcherProxy<ClientDimData> getDimwatcher()
|
||||
{
|
||||
public static UpdateWatcherProxy<ClientDimData> getDimwatcher() {
|
||||
return dimWatcher;
|
||||
}
|
||||
|
||||
public static UpdateWatcherProxy<ClientLinkData> getLinkWatcher()
|
||||
{
|
||||
public static UpdateWatcherProxy<ClientLinkData> getLinkWatcher() {
|
||||
return linkWatcher;
|
||||
}
|
||||
|
||||
public static DimData getPersonalDimensionForPlayer(String name)
|
||||
{
|
||||
if (personalPocketsMapping.containsKey(name))
|
||||
{
|
||||
public static DimData getPersonalDimensionForPlayer(String name) {
|
||||
if (personalPocketsMapping.containsKey(name)) {
|
||||
return personalPocketsMapping.get(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setPersonalPocketsMapping(HashMap<String, DimData> ppMap)
|
||||
{
|
||||
public static void setPersonalPocketsMapping(HashMap<String, DimData> ppMap) {
|
||||
personalPocketsMapping = ppMap;
|
||||
}
|
||||
|
||||
public static HashMap<String, DimData> getPersonalPocketMapping()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
public static HashMap<String, DimData> getPersonalPocketMapping() {
|
||||
return personalPocketsMapping;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.zixiken.dimdoors.experimental;
|
|||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStoneBrick;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -11,220 +13,160 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
|||
import com.zixiken.dimdoors.Point3D;
|
||||
|
||||
public class MazeBuilder {
|
||||
private MazeBuilder() { }
|
||||
|
||||
public static void generate(World world, int x, int y, int z, Random random) {
|
||||
MazeDesign design = MazeDesigner.generate(random);
|
||||
BlockPos offset = new BlockPos(x - design.width() / 2, y - design.height() - 1, z - design.length() / 2);
|
||||
SphereDecayOperation decay = new SphereDecayOperation(random, Blocks.air, 0, Blocks.stonebrick, 2);
|
||||
|
||||
buildRooms(design.getRoomGraph(), world, offset);
|
||||
carveDoorways(design.getRoomGraph(), world, offset, decay, random);
|
||||
|
||||
//placeDoors(design, world, offset);
|
||||
|
||||
applyRandomDestruction(design, world, offset, decay, random);
|
||||
}
|
||||
|
||||
private static void applyRandomDestruction(MazeDesign design, World world,
|
||||
BlockPos offset, SphereDecayOperation decay, Random random)
|
||||
{
|
||||
//final int DECAY_BOX_SIZE = 8
|
||||
}
|
||||
private MazeBuilder() {
|
||||
}
|
||||
|
||||
private static void buildRooms(DirectedGraph<PartitionNode, DoorwayData> roomGraph, World world, BlockPos offset)
|
||||
{
|
||||
for (IGraphNode<PartitionNode, DoorwayData> node : roomGraph.nodes())
|
||||
{
|
||||
PartitionNode room = node.data();
|
||||
buildBox(world, offset, room.minCorner(), room.maxCorner(), Blocks.stonebrick, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static void carveDoorways(DirectedGraph<PartitionNode, DoorwayData> roomGraph, World world,
|
||||
BlockPos offset, SphereDecayOperation decay, Random random)
|
||||
{
|
||||
char axis;
|
||||
BlockPos lower;
|
||||
DoorwayData doorway;
|
||||
|
||||
for (IGraphNode<PartitionNode, DoorwayData> node : roomGraph.nodes())
|
||||
{
|
||||
for (IEdge<PartitionNode, DoorwayData> passage : node.outbound())
|
||||
{
|
||||
doorway = passage.data();
|
||||
axis = doorway.axis();
|
||||
lower = doorway.minCorner();
|
||||
carveDoorway(world, axis, offset.getX() + lower.getX(), offset.getY() + lower.getY(),
|
||||
offset.getZ() + lower.getZ(), doorway.width(), doorway.height(), doorway.length(),
|
||||
decay, random);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void carveDoorway(World world, char axis, int x, int y, int z, int width, int height,
|
||||
int length, SphereDecayOperation decay, Random random)
|
||||
{
|
||||
final int MIN_DOUBLE_DOOR_SPAN = 10;
|
||||
|
||||
int gap;
|
||||
switch (axis)
|
||||
{
|
||||
case DoorwayData.X_AXIS:
|
||||
if (length >= MIN_DOUBLE_DOOR_SPAN)
|
||||
{
|
||||
gap = (length - 2) / 3;
|
||||
carveDoorAlongX(world, x, y + 1, z + gap);
|
||||
carveDoorAlongX(world, x, y + 1, z + length - gap - 1);
|
||||
}
|
||||
else if (length > 3)
|
||||
{
|
||||
switch (random.nextInt(3))
|
||||
{
|
||||
case 0:
|
||||
carveDoorAlongX(world, x, y + 1, z + (length - 1) / 2);
|
||||
break;
|
||||
case 1:
|
||||
carveDoorAlongX(world, x, y + 1, z + 2);
|
||||
break;
|
||||
case 2:
|
||||
carveDoorAlongX(world, x, y + 1, z + length - 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
carveDoorAlongX(world, x, y + 1, z + 1);
|
||||
}
|
||||
break;
|
||||
case DoorwayData.Z_AXIS:
|
||||
if (width >= MIN_DOUBLE_DOOR_SPAN)
|
||||
{
|
||||
gap = (width - 2) / 3;
|
||||
carveDoorAlongZ(world, x + gap, y + 1, z);
|
||||
carveDoorAlongZ(world, x + width - gap - 1, y + 1, z);
|
||||
}
|
||||
else if (length > 3)
|
||||
{
|
||||
switch (random.nextInt(3))
|
||||
{
|
||||
case 0:
|
||||
carveDoorAlongZ(world, x + (width - 1) / 2, y + 1, z);
|
||||
break;
|
||||
case 1:
|
||||
carveDoorAlongZ(world, x + 2, y + 1, z);
|
||||
break;
|
||||
case 2:
|
||||
carveDoorAlongZ(world, x + width - 3, y + 1, z);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
carveDoorAlongZ(world, x + 1, y + 1, z);
|
||||
}
|
||||
break;
|
||||
case DoorwayData.Y_AXIS:
|
||||
gap = Math.min(width, length) - 2;
|
||||
if (gap > 1)
|
||||
{
|
||||
if (gap > 6)
|
||||
{
|
||||
gap = 6;
|
||||
}
|
||||
decay.apply(world,
|
||||
x + random.nextInt(width - gap - 1) + 1, y - 1,
|
||||
z + random.nextInt(length - gap - 1) + 1, gap, 4, gap);
|
||||
}
|
||||
else
|
||||
{
|
||||
carveHole(world, x + 1, y, z + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void carveDoorAlongX(World world, int x, int y, int z)
|
||||
{
|
||||
setBlockDirectly(world, x, y, z, Blocks.air, 0);
|
||||
setBlockDirectly(world, x, y + 1, z, Blocks.air, 0);
|
||||
setBlockDirectly(world, x + 1, y, z, Blocks.air, 0);
|
||||
setBlockDirectly(world, x + 1, y + 1, z, Blocks.air, 0);
|
||||
}
|
||||
|
||||
private static void carveDoorAlongZ(World world, int x, int y, int z)
|
||||
{
|
||||
setBlockDirectly(world, x, y, z, Blocks.air, 0);
|
||||
setBlockDirectly(world, x, y + 1, z, Blocks.air, 0);
|
||||
setBlockDirectly(world, x, y, z + 1, Blocks.air, 0);
|
||||
setBlockDirectly(world, x, y + 1, z + 1, Blocks.air, 0);
|
||||
}
|
||||
|
||||
private static void carveHole(World world, int x, int y, int z)
|
||||
{
|
||||
setBlockDirectly(world, x, y, z, Blocks.air, 0);
|
||||
setBlockDirectly(world, x, y + 1, z, Blocks.air, 0);
|
||||
}
|
||||
public static void generate(World world, int x, int y, int z, Random random) {
|
||||
MazeDesign design = MazeDesigner.generate(random);
|
||||
BlockPos offset = new BlockPos(x - design.width() / 2, y - design.height() - 1, z - design.length() / 2);
|
||||
SphereDecayOperation decay = new SphereDecayOperation(random, Blocks.air.setBlockUnbreakable().getDefaultState(), Blocks.stonebrick.setBlockUnbreakable().getDefaultState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.CRACKED));
|
||||
|
||||
|
||||
private static void buildBox(World world, BlockPos offset, BlockPos minCorner, BlockPos maxCorner, Block block, int metadata)
|
||||
{
|
||||
int minX = minCorner.getX() + offset.getX();
|
||||
int minY = minCorner.getY() + offset.getY();
|
||||
int minZ = minCorner.getZ() + offset.getZ();
|
||||
|
||||
int maxX = maxCorner.getX() + offset.getX();
|
||||
int maxY = maxCorner.getY() + offset.getY();
|
||||
int maxZ = maxCorner.getZ() + offset.getZ();
|
||||
|
||||
int x, y, z;
|
||||
|
||||
for (x = minX; x <= maxX; x++)
|
||||
{
|
||||
for (z = minZ; z <= maxZ; z++)
|
||||
{
|
||||
setBlockDirectly(world, x, minY, z, block, metadata);
|
||||
setBlockDirectly(world, x, maxY, z, block, metadata);
|
||||
}
|
||||
}
|
||||
for (x = minX; x <= maxX; x++)
|
||||
{
|
||||
for (y = minY; y <= maxY; y++)
|
||||
{
|
||||
setBlockDirectly(world, x, y, minZ, block, metadata);
|
||||
setBlockDirectly(world, x, y, maxZ, block, metadata);
|
||||
}
|
||||
}
|
||||
for (z = minZ; z <= maxZ; z++)
|
||||
{
|
||||
for (y = minY; y <= maxY; y++)
|
||||
{
|
||||
setBlockDirectly(world, minX, y, z, block, metadata);
|
||||
setBlockDirectly(world, maxX, y, z, block, metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setBlockDirectly(World world, int x, int y, int z, Block block, int metadata)
|
||||
{
|
||||
int cX = x >> 4;
|
||||
int cZ = z >> 4;
|
||||
int cY = y >> 4;
|
||||
Chunk chunk;
|
||||
buildRooms(design.getRoomGraph(), world, offset);
|
||||
carveDoorways(design.getRoomGraph(), world, offset, decay, random);
|
||||
|
||||
int localX = (x % 16) < 0 ? (x % 16) + 16 : (x % 16);
|
||||
int localZ = (z % 16) < 0 ? (z % 16) + 16 : (z % 16);
|
||||
ExtendedBlockStorage extBlockStorage;
|
||||
//placeDoors(design, world, offset);
|
||||
|
||||
chunk = world.getChunkFromChunkCoords(cX, cZ);
|
||||
extBlockStorage = chunk.getBlockStorageArray()[cY];
|
||||
if (extBlockStorage == null)
|
||||
{
|
||||
extBlockStorage = new ExtendedBlockStorage(cY << 4, !world.provider.hasNoSky);
|
||||
chunk.getBlockStorageArray()[cY] = extBlockStorage;
|
||||
}
|
||||
extBlockStorage.func_150818_a(localX, y & 15, localZ, block);
|
||||
extBlockStorage.setExtBlockMetadata(localX, y & 15, localZ, metadata);
|
||||
chunk.setChunkModified();
|
||||
}
|
||||
}
|
||||
applyRandomDestruction(design, world, offset, decay, random);
|
||||
}
|
||||
|
||||
private static void applyRandomDestruction(MazeDesign design, World world, BlockPos offset, SphereDecayOperation decay, Random random) {
|
||||
//final int DECAY_BOX_SIZE = 8
|
||||
}
|
||||
|
||||
private static void buildRooms(DirectedGraph<PartitionNode, DoorwayData> roomGraph, World world, BlockPos offset) {
|
||||
for (IGraphNode<PartitionNode, DoorwayData> node : roomGraph.nodes()) {
|
||||
PartitionNode room = node.data();
|
||||
buildBox(world, offset, room.minCorner(), room.maxCorner(), Blocks.stonebrick.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
||||
private static void carveDoorways(DirectedGraph<PartitionNode, DoorwayData> roomGraph, World world, BlockPos offset, SphereDecayOperation decay, Random random) {
|
||||
char axis;
|
||||
BlockPos lower;
|
||||
DoorwayData doorway;
|
||||
|
||||
for (IGraphNode<PartitionNode, DoorwayData> node : roomGraph.nodes()) {
|
||||
for (IEdge<PartitionNode, DoorwayData> passage : node.outbound()) {
|
||||
doorway = passage.data();
|
||||
axis = doorway.axis();
|
||||
lower = doorway.minCorner();
|
||||
carveDoorway(world, axis, offset.add(lower), doorway.volume(), decay, random);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void carveDoorway(World world, char axis, BlockPos pos, BlockPos volume, SphereDecayOperation decay, Random random) {
|
||||
final int MIN_DOUBLE_DOOR_SPAN = 10;
|
||||
int gap;
|
||||
|
||||
switch (axis) {
|
||||
case DoorwayData.X_AXIS:
|
||||
if (pos.getZ() >= MIN_DOUBLE_DOOR_SPAN) {
|
||||
gap = (pos.getZ() - 2) / 3;
|
||||
carveDoorAlongX(world, pos.add(0, 1, gap));
|
||||
carveDoorAlongX(world, pos.add(0, 1, pos.getZ() - gap - 1));
|
||||
} else if (pos.getZ() > 3) {
|
||||
switch (random.nextInt(3)) {
|
||||
case 0:
|
||||
carveDoorAlongX(world, pos.add(0, 1, (pos.getZ() - 1) / 2));
|
||||
break;
|
||||
case 1:
|
||||
carveDoorAlongX(world, pos.add(0, 1, 2));
|
||||
break;
|
||||
case 2:
|
||||
carveDoorAlongX(world, pos.add(0,1,-3));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
carveDoorAlongX(world, pos.add(0,1,1));
|
||||
}
|
||||
break;
|
||||
case DoorwayData.Z_AXIS:
|
||||
if (pos.getX() >= MIN_DOUBLE_DOOR_SPAN) {
|
||||
gap = (pos.getX() - 2) / 3;
|
||||
carveDoorAlongZ(world, pos.add(gap, 1, 0));
|
||||
carveDoorAlongZ(world, pos.add(pos.getX() - gap - 1, 1, 0));
|
||||
} else if (pos.getZ() > 3) {
|
||||
switch (random.nextInt(3)) {
|
||||
case 0:
|
||||
carveDoorAlongZ(world, pos.add((volume.getX() - 1) / 2, 1, 0));
|
||||
break;
|
||||
case 1:
|
||||
carveDoorAlongZ(world, pos.add(2,1,0));
|
||||
break;
|
||||
case 2:
|
||||
carveDoorAlongZ(world, pos.add(volume.getX() - 3, 1, 0));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
carveDoorAlongZ(world, pos.add(1,1,0));
|
||||
}
|
||||
break;
|
||||
|
||||
case DoorwayData.Y_AXIS:
|
||||
gap = Math.min(volume.getX(), pos.getZ()) - 2;
|
||||
if (gap > 1) {
|
||||
if (gap > 6) {
|
||||
gap = 6;
|
||||
}
|
||||
decay.apply(world, new BlockPos(random.nextInt(volume.getX() - gap - 1) + 1, -1, random.nextInt(pos.getZ() - gap - 1) + 1), new BlockPos(gap, 4, gap));
|
||||
} else {
|
||||
carveHole(world, pos.add(1,0,1));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void carveDoorAlongX(World world, BlockPos pos) {
|
||||
world.setBlockState(pos, Blocks.air.getDefaultState());
|
||||
world.setBlockState(pos.add(0, 1, 0), Blocks.air.getDefaultState());
|
||||
world.setBlockState(pos.add(1, 0, 0), Blocks.air.getDefaultState());
|
||||
world.setBlockState(pos.add(1, 1, 0), Blocks.air.getDefaultState());
|
||||
}
|
||||
|
||||
private static void carveDoorAlongZ(World world, BlockPos pos) {
|
||||
world.setBlockState(pos, Blocks.air.getDefaultState());
|
||||
world.setBlockState(pos.add(0, 1, 0), Blocks.air.getDefaultState());
|
||||
world.setBlockState(pos.add(0, 0, 1), Blocks.air.getDefaultState());
|
||||
world.setBlockState(pos.add(0, 0, 0), Blocks.air.getDefaultState());
|
||||
}
|
||||
|
||||
private static void carveHole(World world, BlockPos pos) {
|
||||
world.setBlockState(pos, Blocks.air.getDefaultState());
|
||||
world.setBlockState(pos.up(), Blocks.air.getDefaultState());
|
||||
}
|
||||
|
||||
|
||||
private static void buildBox(World world, BlockPos offset, BlockPos minCorner, BlockPos maxCorner, IBlockState state) {
|
||||
int minX = minCorner.getX() + offset.getX();
|
||||
int minY = minCorner.getY() + offset.getY();
|
||||
int minZ = minCorner.getZ() + offset.getZ();
|
||||
|
||||
int maxX = maxCorner.getX() + offset.getX();
|
||||
int maxY = maxCorner.getY() + offset.getY();
|
||||
int maxZ = maxCorner.getZ() + offset.getZ();
|
||||
|
||||
int x, y, z;
|
||||
|
||||
for (x = minX; x <= maxX; x++) {
|
||||
for (z = minZ; z <= maxZ; z++) {
|
||||
world.setBlockState(new BlockPos(x, minY, z), state);
|
||||
world.setBlockState(new BlockPos(x, maxY, z), state);
|
||||
}
|
||||
}
|
||||
|
||||
for (x = minX; x <= maxX; x++) {
|
||||
for (y = minY; y <= maxY; y++) {
|
||||
world.setBlockState(new BlockPos(x, y, minZ), state);
|
||||
world.setBlockState(new BlockPos(x, y, maxZ), state);
|
||||
}
|
||||
}
|
||||
|
||||
for (z = minZ; z <= maxZ; z++) {
|
||||
for (y = minY; y <= maxY; y++) {
|
||||
world.setBlockState(new BlockPos(minX, y, z), state);
|
||||
world.setBlockState(new BlockPos(maxX, y, z), state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,53 +2,44 @@ package com.zixiken.dimdoors.experimental;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MazeDesign
|
||||
{
|
||||
public class MazeDesign {
|
||||
private PartitionNode root;
|
||||
private DirectedGraph<PartitionNode, DoorwayData> rooms;
|
||||
private ArrayList<IGraphNode<PartitionNode, DoorwayData>> cores;
|
||||
private ArrayList<BoundingBox> protectedAreas;
|
||||
|
||||
public MazeDesign(PartitionNode root, DirectedGraph<PartitionNode, DoorwayData> rooms,
|
||||
ArrayList<IGraphNode<PartitionNode, DoorwayData>> cores)
|
||||
{
|
||||
public MazeDesign(PartitionNode root, DirectedGraph<PartitionNode, DoorwayData> rooms, ArrayList<IGraphNode<PartitionNode, DoorwayData>> cores) {
|
||||
this.root = root;
|
||||
this.rooms = rooms;
|
||||
this.cores = cores;
|
||||
}
|
||||
|
||||
public PartitionNode getRootPartition()
|
||||
{
|
||||
public PartitionNode getRootPartition() {
|
||||
return root;
|
||||
}
|
||||
|
||||
public DirectedGraph<PartitionNode, DoorwayData> getRoomGraph()
|
||||
{
|
||||
public DirectedGraph<PartitionNode, DoorwayData> getRoomGraph() {
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public ArrayList<IGraphNode<PartitionNode, DoorwayData>> getCoreNodes()
|
||||
{
|
||||
public ArrayList<IGraphNode<PartitionNode, DoorwayData>> getCoreNodes() {
|
||||
return cores;
|
||||
}
|
||||
|
||||
public ArrayList<BoundingBox> getProtectedAreas()
|
||||
{
|
||||
public ArrayList<BoundingBox> getProtectedAreas() {
|
||||
return protectedAreas;
|
||||
}
|
||||
|
||||
public int width()
|
||||
{
|
||||
return root.width();
|
||||
public int width() {
|
||||
return root.volume().getX();
|
||||
}
|
||||
|
||||
public int height()
|
||||
{
|
||||
return root.height();
|
||||
return root.volume().getY();
|
||||
}
|
||||
|
||||
public int length()
|
||||
{
|
||||
return root.length();
|
||||
public int length() {
|
||||
return root.volume().getZ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,8 +90,7 @@ public class MazeDesigner
|
|||
}
|
||||
}
|
||||
|
||||
private static void splitByRandomZ(PartitionNode node, int levels, Random random)
|
||||
{
|
||||
private static void splitByRandomZ(PartitionNode node, int levels, Random random) {
|
||||
if (node.volume().getZ() >= 2 * MIN_SIDE) {
|
||||
node.splitByZ(MathHelper.getRandomIntegerInRange(random,
|
||||
node.minCorner().getZ() + MIN_SIDE, node.maxCorner().getZ() - MIN_SIDE + 1));
|
||||
|
@ -199,17 +198,14 @@ public class MazeDesigner
|
|||
}
|
||||
}
|
||||
// Check if we meet the minimum dimensions needed for a doorway
|
||||
if (diff.add(1,0,0).getX() + 1 >= MIN_SIDE && maxYI - minYI + 1 >= MIN_HEIGHT)
|
||||
{
|
||||
otherMin = new BlockPos(minXI, minYI, maxZ);
|
||||
otherMax = new BlockPos(maxXI, maxYI, maxZ + 1);
|
||||
if (diff.add(1,0,0).getX() + 1 >= MIN_SIDE && maxI.getY() - minI.getY() + 1 >= MIN_HEIGHT) {
|
||||
otherMin = new BlockPos(minI.getX(), minI.getY(), maxCorner.getZ());
|
||||
otherMax = new BlockPos(maxI.getX(), maxI.getY(), maxCorner.getZ() + 1);
|
||||
doorway = new DoorwayData(otherMin, otherMax, DoorwayData.Z_AXIS);
|
||||
adjacentNode = roomsToGraph.get(adjacent);
|
||||
roomGraph.addEdge(roomNode, adjacentNode, doorway);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
detected[a][b] = true;
|
||||
}
|
||||
}
|
||||
|
@ -218,46 +214,34 @@ public class MazeDesigner
|
|||
}
|
||||
|
||||
|
||||
if (maxX < root.maxCorner().getX())
|
||||
{
|
||||
if (maxCorner.getX() < root.maxCorner().getX()) {
|
||||
// Check for adjacent rooms along the YZ plane
|
||||
detected = new boolean[height][length];
|
||||
for (b = 0; b < height; b++)
|
||||
{
|
||||
for (c = 0; c < length; c++)
|
||||
{
|
||||
if (!detected[b][c])
|
||||
{
|
||||
adjacent = root.findPoint(maxX + 1, minY + b, minZ + c);
|
||||
if (adjacent != null)
|
||||
{
|
||||
detected = new boolean[volume.getY()][volume.getZ()];
|
||||
for (b = 0; b < volume.getY(); b++) {
|
||||
for (c = 0; c < volume.getZ(); c++) {
|
||||
if (!detected[b][c]) {
|
||||
adjacent = root.findPoint(new BlockPos(maxCorner.getX() + 1, minCorner.getY() + b, minCorner.getZ() + c));
|
||||
if (adjacent != null) {
|
||||
// Compute the dimensions available for a doorway
|
||||
otherMin = adjacent.minCorner();
|
||||
otherMax = adjacent.maxCorner();
|
||||
minYI = Math.max(minY, otherMin.getY());
|
||||
maxYI = Math.min(maxY, otherMax.getY());
|
||||
minZI = Math.max(minZ, otherMin.getZ());
|
||||
maxZI = Math.min(maxZ, otherMax.getZ());
|
||||
minI = BlockPosHelper.max(minCorner, otherMin);
|
||||
maxI = BlockPosHelper.min(maxCorner, otherMax);
|
||||
|
||||
for (q = 0; q <= maxYI - minYI; q++)
|
||||
{
|
||||
for (r = 0; r <= maxZI - minZI; r++)
|
||||
{
|
||||
for (q = 0; q <= maxI.getY() - minI.getY(); q++) {
|
||||
for (r = 0; r <= maxI.getZ() - minI.getZ(); r++) {
|
||||
detected[q + b][r + c] = true;
|
||||
}
|
||||
}
|
||||
// Check if we meet the minimum dimensions needed for a doorway
|
||||
if (maxYI - minYI + 1 >= MIN_HEIGHT && maxZI - minZI + 1 >= MIN_SIDE)
|
||||
{
|
||||
otherMin = new BlockPos(maxX, minYI, minZI);
|
||||
otherMax = new BlockPos(maxX + 1, maxYI, maxZI);
|
||||
if (maxI.getY() - minI.getY() + 1 >= MIN_HEIGHT && maxI.getZ() - minI.getZ() + 1 >= MIN_SIDE) {
|
||||
otherMin = new BlockPos(maxCorner.getX(), minI.getY(), minI.getZ());
|
||||
otherMax = new BlockPos(maxCorner.getX() + 1, maxI.getY(), maxI.getZ());
|
||||
doorway = new DoorwayData(otherMin, otherMax, DoorwayData.X_AXIS);
|
||||
adjacentNode = roomsToGraph.get(adjacent);
|
||||
roomGraph.addEdge(roomNode, adjacentNode, doorway);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
detected[b][c] = true;
|
||||
}
|
||||
}
|
||||
|
@ -266,46 +250,35 @@ public class MazeDesigner
|
|||
}
|
||||
|
||||
|
||||
if (maxY < root.maxCorner().getY())
|
||||
{
|
||||
if (maxCorner.getY() < root.maxCorner().getY()) {
|
||||
// Check for adjacent rooms along the XZ plane
|
||||
detected = new boolean[width][length];
|
||||
for (a = 0; a < width; a++)
|
||||
{
|
||||
for (c = 0; c < length; c++)
|
||||
{
|
||||
if (!detected[a][c])
|
||||
{
|
||||
adjacent = root.findPoint(minX + a, maxY + 1, minZ + c);
|
||||
if (adjacent != null)
|
||||
{
|
||||
detected = new boolean[volume.getX()][volume.getZ()];
|
||||
for (a = 0; a < volume.getX(); a++) {
|
||||
for (c = 0; c < volume.getZ(); c++) {
|
||||
if (!detected[a][c]) {
|
||||
adjacent = root.findPoint(new BlockPos(minCorner.getX() + a, maxCorner.getY() + 1, minCorner.getZ() + c));
|
||||
if (adjacent != null) {
|
||||
// Compute the dimensions available for a doorway
|
||||
otherMin = adjacent.minCorner();
|
||||
otherMax = adjacent.maxCorner();
|
||||
minXI = Math.max(minX, otherMin.getX());
|
||||
maxXI = Math.min(maxX, otherMax.getX());
|
||||
minZI = Math.max(minZ, otherMin.getZ());
|
||||
maxZI = Math.min(maxZ, otherMax.getZ());
|
||||
minI = BlockPosHelper.max(minCorner, otherMin);
|
||||
maxI = BlockPosHelper.min(maxCorner, otherMax);
|
||||
|
||||
for (p = 0; p <= maxXI - minXI; p++)
|
||||
{
|
||||
for (r = 0; r <= maxZI - minZI; r++)
|
||||
{
|
||||
for (p = 0; p <= maxI.getX() - minI.getX(); p++) {
|
||||
for (r = 0; r <= maxI.getZ() - minI.getZ(); r++) {
|
||||
detected[p + a][r + c] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we meet the minimum dimensions needed for a doorway
|
||||
if (maxXI - minXI + 1 >= MIN_SIDE && maxZI - minZI + 1 >= MIN_SIDE)
|
||||
{
|
||||
otherMin = new BlockPos(minXI, maxY, minZI);
|
||||
otherMax = new BlockPos(maxXI, maxY + 1, maxZI);
|
||||
if (maxI.getX() - minI.getX() + 1 >= MIN_SIDE && maxI.getZ() - minI.getZ() + 1 >= MIN_SIDE) {
|
||||
otherMin = new BlockPos(minI.getX(), maxCorner.getY(), minI.getZ());
|
||||
otherMax = new BlockPos(maxI.getX(), maxCorner.getY() + 1, maxI.getZ());
|
||||
doorway = new DoorwayData(otherMin, otherMax, DoorwayData.Y_AXIS);
|
||||
adjacentNode = roomsToGraph.get(adjacent);
|
||||
roomGraph.addEdge(roomNode, adjacentNode, doorway);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
detected[a][c] = true;
|
||||
}
|
||||
}
|
||||
|
@ -316,8 +289,7 @@ public class MazeDesigner
|
|||
//Done!
|
||||
}
|
||||
|
||||
private static ArrayList<IGraphNode<PartitionNode, DoorwayData>> createMazeSections(DirectedGraph<PartitionNode, DoorwayData> roomGraph, Random random)
|
||||
{
|
||||
private static ArrayList<IGraphNode<PartitionNode, DoorwayData>> createMazeSections(DirectedGraph<PartitionNode, DoorwayData> roomGraph, Random random) {
|
||||
// The randomness of the sections generated here hinges on
|
||||
// the nodes in the graph being in a random order. We assume
|
||||
// that was handled in a previous step!
|
||||
|
@ -337,49 +309,40 @@ public class MazeDesigner
|
|||
HashMap<IGraphNode<PartitionNode, DoorwayData>, Integer> distances = new HashMap<IGraphNode<PartitionNode, DoorwayData>, Integer>();
|
||||
|
||||
// Repeatedly generate sections until all nodes have been visited
|
||||
for (IGraphNode<PartitionNode, DoorwayData> node : roomGraph.nodes())
|
||||
{
|
||||
for (IGraphNode<PartitionNode, DoorwayData> node : roomGraph.nodes()) {
|
||||
// If this node hasn't been visited, then use it as the core of a new section
|
||||
// Otherwise, ignore it, since it was already processed
|
||||
if (!distances.containsKey(node))
|
||||
{
|
||||
if (!distances.containsKey(node)) {
|
||||
// Perform a breadth-first search to tag surrounding nodes with distances
|
||||
distances.put(node, 0);
|
||||
ordering.add(node);
|
||||
section.clear();
|
||||
|
||||
while (!ordering.isEmpty())
|
||||
{
|
||||
while (!ordering.isEmpty()) {
|
||||
current = ordering.remove();
|
||||
distance = distances.get(current) + 1;
|
||||
|
||||
if (distance <= MAX_DISTANCE + 1)
|
||||
{
|
||||
if (distance <= MAX_DISTANCE + 1) {
|
||||
section.add(current);
|
||||
|
||||
// Visit neighboring nodes and assign them distances, if they don't
|
||||
// have a distance assigned already
|
||||
for (IEdge<PartitionNode, DoorwayData> edge : current.inbound())
|
||||
{
|
||||
for (IEdge<PartitionNode, DoorwayData> edge : current.inbound()) {
|
||||
neighbor = edge.head();
|
||||
if (!distances.containsKey(neighbor))
|
||||
{
|
||||
if (!distances.containsKey(neighbor)) {
|
||||
distances.put(neighbor, distance);
|
||||
ordering.add(neighbor);
|
||||
}
|
||||
}
|
||||
for (IEdge<PartitionNode, DoorwayData> edge : current.outbound())
|
||||
{
|
||||
|
||||
for (IEdge<PartitionNode, DoorwayData> edge : current.outbound()) {
|
||||
neighbor = edge.tail();
|
||||
if (!distances.containsKey(neighbor))
|
||||
{
|
||||
if (!distances.containsKey(neighbor)) {
|
||||
distances.put(neighbor, distance);
|
||||
ordering.add(neighbor);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
removals.add(current);
|
||||
break;
|
||||
}
|
||||
|
@ -389,18 +352,14 @@ public class MazeDesigner
|
|||
// Those are precisely the nodes that remain in the queue
|
||||
// We can't remove them immediately because that could break
|
||||
// the iterator for the graph.
|
||||
while (!ordering.isEmpty())
|
||||
{
|
||||
while (!ordering.isEmpty()) {
|
||||
removals.add(ordering.remove());
|
||||
}
|
||||
|
||||
// Check if this section contains enough rooms
|
||||
if (section.size() >= MIN_SECTION_ROOMS)
|
||||
{
|
||||
if (section.size() >= MIN_SECTION_ROOMS) {
|
||||
cores.add(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
removals.addAll(section);
|
||||
}
|
||||
}
|
||||
|
@ -408,8 +367,7 @@ public class MazeDesigner
|
|||
|
||||
// Remove all the nodes that were listed for removal
|
||||
// Also remove unused partitions from the partition tree
|
||||
for (IGraphNode<PartitionNode, DoorwayData> node : removals)
|
||||
{
|
||||
for (IGraphNode<PartitionNode, DoorwayData> node : removals) {
|
||||
removeRoomPartitions(node.data());
|
||||
roomGraph.removeNode(node);
|
||||
}
|
||||
|
@ -444,24 +402,20 @@ public class MazeDesigner
|
|||
|
||||
ordering.add(core);
|
||||
components.makeSet(core);
|
||||
while (!ordering.isEmpty())
|
||||
{
|
||||
while (!ordering.isEmpty()) {
|
||||
current = ordering.pop();
|
||||
subgraph.add(current);
|
||||
|
||||
for (IEdge<PartitionNode, DoorwayData> edge : current.inbound())
|
||||
{
|
||||
for (IEdge<PartitionNode, DoorwayData> edge : current.inbound()) {
|
||||
neighbor = edge.head();
|
||||
if (components.makeSet(neighbor))
|
||||
{
|
||||
if (components.makeSet(neighbor)) {
|
||||
ordering.add(neighbor);
|
||||
}
|
||||
}
|
||||
for (IEdge<PartitionNode, DoorwayData> edge : current.outbound())
|
||||
{
|
||||
|
||||
for (IEdge<PartitionNode, DoorwayData> edge : current.outbound()) {
|
||||
neighbor = edge.tail();
|
||||
if (components.makeSet(neighbor))
|
||||
{
|
||||
if (components.makeSet(neighbor)) {
|
||||
ordering.add(neighbor);
|
||||
}
|
||||
}
|
||||
|
@ -470,19 +424,13 @@ public class MazeDesigner
|
|||
// Now iterate over the list of nodes and merge their sets
|
||||
// We only have to look at outbound edges since inbound edges mirror them
|
||||
// Also list any Y_AXIS doorways we come across
|
||||
ArrayList<IEdge<PartitionNode, DoorwayData>> targets =
|
||||
new ArrayList<IEdge<PartitionNode, DoorwayData>>();
|
||||
ArrayList<IEdge<PartitionNode, DoorwayData>> targets = new ArrayList<IEdge<PartitionNode, DoorwayData>>();
|
||||
|
||||
for (IGraphNode<PartitionNode, DoorwayData> room : subgraph)
|
||||
{
|
||||
for (IEdge<PartitionNode, DoorwayData> passage : room.outbound())
|
||||
{
|
||||
if (passage.data().axis() != DoorwayData.Y_AXIS)
|
||||
{
|
||||
for (IGraphNode<PartitionNode, DoorwayData> room : subgraph) {
|
||||
for (IEdge<PartitionNode, DoorwayData> passage : room.outbound()) {
|
||||
if (passage.data().axis() != DoorwayData.Y_AXIS) {
|
||||
components.mergeSets(passage.head(), passage.tail());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
targets.add(passage);
|
||||
}
|
||||
}
|
||||
|
@ -492,10 +440,8 @@ public class MazeDesigner
|
|||
Collections.shuffle(targets, random);
|
||||
|
||||
// Merge sets together and remove unnecessary doorways
|
||||
for (IEdge<PartitionNode, DoorwayData> passage : targets)
|
||||
{
|
||||
if (!components.mergeSets(passage.head(), passage.tail()))
|
||||
{
|
||||
for (IEdge<PartitionNode, DoorwayData> passage : targets) {
|
||||
if (!components.mergeSets(passage.head(), passage.tail())) {
|
||||
rooms.removeEdge(passage);
|
||||
}
|
||||
}
|
||||
|
@ -505,29 +451,23 @@ public class MazeDesigner
|
|||
components.clear();
|
||||
targets.clear();
|
||||
|
||||
for (IGraphNode<PartitionNode, DoorwayData> room : subgraph)
|
||||
{
|
||||
for (IGraphNode<PartitionNode, DoorwayData> room : subgraph) {
|
||||
components.makeSet(room);
|
||||
}
|
||||
for (IGraphNode<PartitionNode, DoorwayData> room : subgraph)
|
||||
{
|
||||
for (IEdge<PartitionNode, DoorwayData> passage : room.outbound())
|
||||
{
|
||||
if (passage.data().axis() == DoorwayData.Y_AXIS)
|
||||
{
|
||||
|
||||
for (IGraphNode<PartitionNode, DoorwayData> room : subgraph) {
|
||||
for (IEdge<PartitionNode, DoorwayData> passage : room.outbound()) {
|
||||
if (passage.data().axis() == DoorwayData.Y_AXIS) {
|
||||
components.mergeSets(passage.head(), passage.tail());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
targets.add(passage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.shuffle(targets, random);
|
||||
for (IEdge<PartitionNode, DoorwayData> passage : targets)
|
||||
{
|
||||
if (!components.mergeSets(passage.head(), passage.tail()) && random.nextBoolean())
|
||||
{
|
||||
for (IEdge<PartitionNode, DoorwayData> passage : targets) {
|
||||
if (!components.mergeSets(passage.head(), passage.tail()) && random.nextBoolean()) {
|
||||
rooms.removeEdge(passage);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,11 @@ package com.zixiken.dimdoors.experimental;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import com.zixiken.dimdoors.helpers.BlockPosHelper;
|
||||
import com.zixiken.dimdoors.schematic.WorldOperation;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
|
@ -16,57 +19,39 @@ public class SphereDecayOperation extends WorldOperation
|
|||
{
|
||||
private Random random;
|
||||
private double scaling;
|
||||
private double centerX;
|
||||
private double centerY;
|
||||
private double centerZ;
|
||||
private Block primaryBlock;
|
||||
private int primaryMetadata;
|
||||
private Block secondaryBlock;
|
||||
private int secondaryMetadata;
|
||||
|
||||
public SphereDecayOperation(Random random, Block primaryBlock, int primaryMetadata, Block secondaryBlock, int secondaryMetadata)
|
||||
{
|
||||
private BlockPos center;
|
||||
private IBlockState primaryBlock;
|
||||
private IBlockState secondaryBlock;
|
||||
|
||||
public SphereDecayOperation(Random random, IBlockState primaryBlock, IBlockState secondaryBlock) {
|
||||
super("SphereDecayOperation");
|
||||
this.random = random;
|
||||
this.primaryBlock = primaryBlock;
|
||||
this.primaryMetadata = primaryMetadata;
|
||||
this.secondaryBlock = secondaryBlock;
|
||||
this.secondaryMetadata = secondaryMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean initialize(World world, int x, int y, int z, int width, int height, int length)
|
||||
{
|
||||
protected boolean initialize(World world, BlockPos pos, BlockPos volume) {
|
||||
// Calculate a scaling factor so that the probability of decay
|
||||
// at the edge of the largest dimension of our bounds is 20%.
|
||||
scaling = Math.max(width - 1, Math.max(height - 1, length - 1)) / 2.0;
|
||||
scaling = Math.max(pos.getX() - 1, Math.max(pos.getY() - 1, pos.getZ() - 1)) / 2.0;
|
||||
scaling *= scaling * 0.20;
|
||||
|
||||
centerX = x + width / 2.0;
|
||||
centerY = y + height / 2.0;
|
||||
centerZ = z + length / 2.0;
|
||||
|
||||
center = pos.add(BlockPosHelper.divide(volume, 2.0));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean applyToBlock(World world, int x, int y, int z)
|
||||
{
|
||||
protected boolean applyToBlock(World world, BlockPos pos) {
|
||||
// Don't raise any notifications. This operation is only designed to run
|
||||
// when a dimension is being generated, which means there are no players around.
|
||||
if (!world.isAirBlock(x, y, z))
|
||||
{
|
||||
double dx = (centerX - x - 0.5);
|
||||
double dy = (centerY - y - 0.5);
|
||||
double dz = (centerZ - z - 0.5);
|
||||
double squareDistance = dx * dx + dy * dy + dz * dz;
|
||||
if (!world.isAirBlock(pos)) {
|
||||
double squareDistance = center.distanceSq(pos);
|
||||
|
||||
if (squareDistance < 0.5 || random.nextDouble() < scaling / squareDistance)
|
||||
{
|
||||
world.setBlock(x, y, z, primaryBlock, primaryMetadata, 1);
|
||||
}
|
||||
else if (random.nextDouble() < scaling / squareDistance)
|
||||
{
|
||||
world.setBlock(x, y, z, secondaryBlock, secondaryMetadata, 1);
|
||||
if (squareDistance < 0.5 || random.nextDouble() < scaling / squareDistance) {
|
||||
world.setBlockState(pos, primaryBlock);
|
||||
} else if (random.nextDouble() < scaling / squareDistance) {
|
||||
world.setBlockState(pos, secondaryBlock);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.zixiken.dimdoors.helpers;
|
||||
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.Vec3i;
|
||||
|
||||
public class BlockPosHelper {
|
||||
public static boolean between(BlockPos pos, BlockPos min, BlockPos max) {
|
||||
|
@ -29,7 +30,11 @@ public class BlockPosHelper {
|
|||
return (a.getX() <= b.getX() && a.getY() <= b.getY() && a.getZ() <= b.getZ());
|
||||
}
|
||||
|
||||
public static BlockPos posFromSingleValue(int value) {
|
||||
public static BlockPos posFromSingleValue(double value) {
|
||||
return new BlockPos(value, value, value);
|
||||
}
|
||||
|
||||
public static BlockPos divide(BlockPos volume, double factor) {
|
||||
return new BlockPos(volume.getX() / factor, volume.getY() / factor, volume.getZ() / factor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,33 +16,31 @@ public class yCoordHelper
|
|||
|
||||
private yCoordHelper() { }
|
||||
|
||||
public static int getFirstUncovered(World world, int x, int yStart, int z) {
|
||||
return getFirstUncovered(world, x, yStart, z, false);
|
||||
public static int getFirstUncovered(World world, BlockPos pos) {
|
||||
return getFirstUncovered(world, pos, false);
|
||||
}
|
||||
|
||||
public static int getFirstUncovered(World world, int x, int yStart, int z, boolean fromTop) {
|
||||
Chunk chunk = world.getChunkProvider().provideChunk(x >> 4, z >> 4);
|
||||
public static int getFirstUncovered(World world, BlockPos pos, boolean fromTop) {
|
||||
Chunk chunk = world.getChunkProvider().provideChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
|
||||
int localX = x < 0 ? (x % 16) + 16 : (x % 16);
|
||||
int localZ = z < 0 ? (z % 16) + 16 : (z % 16);
|
||||
int localX = pos.getX() < 0 ? (pos.getX() % 16) + 16 : (pos.getX() % 16);
|
||||
int localZ = pos.getZ() < 0 ? (pos.getZ() % 16) + 16 : (pos.getZ() % 16);
|
||||
int height = MAXIMUM_UNCOVERED_Y;
|
||||
|
||||
int y;
|
||||
|
||||
if (!fromTop)
|
||||
{
|
||||
if (!fromTop) {
|
||||
boolean covered = true;
|
||||
for (y = yStart; y < height && covered; y++)
|
||||
{
|
||||
for (y = pos.getY(); y < height && covered; y++) {
|
||||
covered = isCoveredBlock(chunk, localX, y - 1, localZ) || isCoveredBlock(chunk, localX, y, localZ);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
boolean covered = false;
|
||||
for (y = MAXIMUM_UNCOVERED_Y; y > 1 && !covered; y--)
|
||||
{
|
||||
for (y = MAXIMUM_UNCOVERED_Y; y > 1 && !covered; y--) {
|
||||
covered = isCoveredBlock(chunk, localX, y - 1, localZ);
|
||||
}
|
||||
|
||||
if (!covered) y = 63;
|
||||
y++;
|
||||
}
|
||||
|
@ -50,8 +48,7 @@ public class yCoordHelper
|
|||
return y;
|
||||
}
|
||||
|
||||
public static boolean isCoveredBlock(Chunk chunk, int localX, int y, int localZ)
|
||||
{
|
||||
public static boolean isCoveredBlock(Chunk chunk, int localX, int y, int localZ) {
|
||||
Block block;
|
||||
Material material;
|
||||
|
||||
|
|
|
@ -14,15 +14,14 @@ import com.zixiken.dimdoors.dungeon.DungeonData;
|
|||
import com.zixiken.dimdoors.helpers.DungeonHelper;
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.util.DDLogger;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import com.zixiken.dimdoors.util.FileFilters;
|
||||
import com.zixiken.dimdoors.util.Point4D;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
public class DDSaveHandler
|
||||
{
|
||||
public static boolean loadAll()
|
||||
{
|
||||
public class DDSaveHandler {
|
||||
public static boolean loadAll() {
|
||||
// SenseiKiwi: Loading up our save data is not as simple as just reading files.
|
||||
// To properly restore dimensions, we need to make sure we always load
|
||||
// a dimension's parent and root before trying to load it. We'll use
|
||||
|
@ -40,16 +39,14 @@ public class DDSaveHandler
|
|||
File dataDirectory = new File(basePath);
|
||||
|
||||
// Check if the folder exists. If it doesn't, just return.
|
||||
if (!dataDirectory.exists())
|
||||
{
|
||||
if (!dataDirectory.exists()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Load the dimension blacklist
|
||||
File blacklistFile = new File(basePath+"blacklist.txt");
|
||||
|
||||
if(blacklistFile.exists())
|
||||
{
|
||||
if(blacklistFile.exists()) {
|
||||
BlacklistProcessor blacklistReader = new BlacklistProcessor();
|
||||
List<Integer> blacklist = readBlacklist(blacklistFile,blacklistReader);
|
||||
PocketManager.createAndRegisterBlacklist(blacklist);
|
||||
|
@ -58,8 +55,7 @@ public class DDSaveHandler
|
|||
// Load the personal pockets mapping
|
||||
File personalPocketMap = new File(basePath+"personalPockets.txt");
|
||||
HashMap<String, Integer> ppMap = new HashMap<String, Integer>();
|
||||
if(personalPocketMap.exists())
|
||||
{
|
||||
if(personalPocketMap.exists()) {
|
||||
PersonalPocketMappingProcessor ppMappingProcessor = new PersonalPocketMappingProcessor();
|
||||
ppMap = readPersonalPocketsMapping(personalPocketMap,ppMappingProcessor);
|
||||
}
|
||||
|
@ -70,11 +66,9 @@ public class DDSaveHandler
|
|||
FileFilter dataFileFilter = new FileFilters.RegexFileFilter("dim_-?\\d+\\.txt");
|
||||
|
||||
File[] dataFiles = dataDirectory.listFiles(dataFileFilter);
|
||||
for (File dataFile : dataFiles)
|
||||
{
|
||||
for (File dataFile : dataFiles) {
|
||||
PackedDimData packedDim = readDimension(dataFile, reader);
|
||||
if(packedDim == null)
|
||||
{
|
||||
if(packedDim == null) {
|
||||
throw new IllegalStateException("The DD data for "+dataFile.getName().replace(".txt", "")+" at "+dataFile.getPath()+" is corrupted. Please report this on the MCF or on the DD github issues tracker.");
|
||||
}
|
||||
packedDims.put(packedDim.ID,packedDim);
|
||||
|
@ -83,16 +77,14 @@ public class DDSaveHandler
|
|||
|
||||
List<PackedLinkData> linksToUnpack = new ArrayList<PackedLinkData>();
|
||||
//get the grand list of all links to unpack
|
||||
for(PackedDimData packedDim : packedDims.values())
|
||||
{
|
||||
for(PackedDimData packedDim : packedDims.values()) {
|
||||
linksToUnpack.addAll(packedDim.Links);
|
||||
}
|
||||
unpackDimData(packedDims);
|
||||
unpackLinkData(linksToUnpack);
|
||||
|
||||
HashMap<String, DimData> personalPocketsMap = new HashMap<String, DimData>();
|
||||
for(Entry<String, Integer> pair : ppMap.entrySet())
|
||||
{
|
||||
for(Entry<String, Integer> pair : ppMap.entrySet()) {
|
||||
personalPocketsMap.put(pair.getKey(), PocketManager.getDimensionData(pair.getValue()));
|
||||
}
|
||||
PocketManager.setPersonalPocketsMapping(personalPocketsMap);
|
||||
|
@ -105,25 +97,21 @@ public class DDSaveHandler
|
|||
* @param packedDims
|
||||
* @return
|
||||
*/
|
||||
public static boolean unpackDimData(HashMap<Integer,PackedDimData> packedDims)
|
||||
{
|
||||
public static boolean unpackDimData(HashMap<Integer,PackedDimData> packedDims) {
|
||||
LinkedList<Integer> dimsToRegister = new LinkedList<Integer>();
|
||||
|
||||
for(PackedDimData packedDim : packedDims.values())
|
||||
{
|
||||
for(PackedDimData packedDim : packedDims.values()) {
|
||||
//fix pockets without parents
|
||||
verifyParents(packedDim, packedDims);
|
||||
|
||||
//Load roots first by inserting them in the LinkedList first.
|
||||
if(packedDim.RootID==packedDim.ID)
|
||||
{
|
||||
if(packedDim.RootID==packedDim.ID) {
|
||||
dimsToRegister.addFirst(packedDim.ID);
|
||||
}
|
||||
}
|
||||
|
||||
//load the children for each root
|
||||
while(!dimsToRegister.isEmpty())
|
||||
{
|
||||
while(!dimsToRegister.isEmpty()) {
|
||||
Integer childID = dimsToRegister.pop();
|
||||
PackedDimData data = packedDims.get(childID);
|
||||
dimsToRegister.addAll(verifyChildren(data, packedDims));
|
||||
|
@ -139,21 +127,17 @@ public class DDSaveHandler
|
|||
* @param packedDims
|
||||
* @return
|
||||
*/
|
||||
private static ArrayList<Integer> verifyChildren(PackedDimData packedDim,HashMap<Integer,PackedDimData> packedDims)
|
||||
{
|
||||
private static ArrayList<Integer> verifyChildren(PackedDimData packedDim,HashMap<Integer,PackedDimData> packedDims) {
|
||||
ArrayList<Integer> children = new ArrayList<Integer>();
|
||||
children.addAll(packedDim.ChildIDs);
|
||||
boolean isMissing = false;
|
||||
for(Integer childID : packedDim.ChildIDs)
|
||||
{
|
||||
if(!packedDims.containsKey(childID))
|
||||
{
|
||||
for(Integer childID : packedDim.ChildIDs) {
|
||||
if(!packedDims.containsKey(childID)) {
|
||||
children.remove(childID);
|
||||
isMissing=true;
|
||||
}
|
||||
}
|
||||
if(isMissing)
|
||||
{
|
||||
if(isMissing) {
|
||||
packedDim=(new PackedDimData(packedDim.ID, packedDim.Depth, packedDim.PackDepth, packedDim.ParentID, packedDim.RootID, packedDim.Orientation, DimensionType.getTypeFromIndex(packedDim.DimensionType), packedDim.IsFilled, packedDim.DungeonData, packedDim.Origin, children, packedDim.Links, packedDim.Tails));
|
||||
packedDims.put(packedDim.ID, packedDim);
|
||||
}
|
||||
|
@ -168,22 +152,19 @@ public class DDSaveHandler
|
|||
* @param packedDim
|
||||
* @param packedDims
|
||||
*/
|
||||
public static void verifyParents(PackedDimData packedDim,HashMap<Integer,PackedDimData> packedDims)
|
||||
{
|
||||
public static void verifyParents(PackedDimData packedDim,HashMap<Integer,PackedDimData> packedDims) {
|
||||
ArrayList<Integer> fosterChildren = new ArrayList<Integer>();
|
||||
fosterChildren.add(packedDim.ID);
|
||||
DimensionType type = DimensionType.getTypeFromIndex(packedDim.DimensionType);
|
||||
//fix pockets without parents
|
||||
if(!packedDims.containsKey(packedDim.ParentID))
|
||||
{
|
||||
if(!packedDims.containsKey(packedDim.ParentID)) {
|
||||
//Fix the orphan by changing its root to its parent, re-connecting it to the list
|
||||
packedDim=(new PackedDimData(packedDim.ID, 1, packedDim.PackDepth, packedDim.RootID, packedDim.RootID, packedDim.Orientation,type, packedDim.IsFilled, packedDim.DungeonData, packedDim.Origin, packedDim.ChildIDs, packedDim.Links, packedDim.Tails));
|
||||
packedDims.put(packedDim.ID, packedDim);
|
||||
}
|
||||
//fix pockets whose parents have forgotten about them
|
||||
PackedDimData fosterParent = packedDims.get(packedDim.ParentID);
|
||||
if(!fosterParent.ChildIDs.contains(packedDim.ID)&&packedDim.ID!=packedDim.RootID)
|
||||
{
|
||||
if(!fosterParent.ChildIDs.contains(packedDim.ID)&&packedDim.ID!=packedDim.RootID) {
|
||||
//find the root, and fix it by adding the orphan's ID to its children
|
||||
fosterChildren.addAll(fosterParent.ChildIDs);
|
||||
fosterParent=(new PackedDimData(fosterParent.ID, fosterParent.Depth, fosterParent.PackDepth, fosterParent.ParentID, fosterParent.RootID, fosterParent.Orientation, type, fosterParent.IsFilled, fosterParent.DungeonData, fosterParent.Origin, fosterChildren, fosterParent.Links, fosterParent.Tails));
|
||||
|
@ -192,16 +173,14 @@ public class DDSaveHandler
|
|||
|
||||
}
|
||||
|
||||
public static boolean unpackLinkData(List<PackedLinkData> linksToUnpack)
|
||||
{
|
||||
public static boolean unpackLinkData(List<PackedLinkData> linksToUnpack) {
|
||||
BlockPos fakePoint = new BlockPos(-1,-1,-1);
|
||||
List<PackedLinkData> unpackedLinks = new ArrayList<PackedLinkData>();
|
||||
/**
|
||||
* sort through the list, unpacking links that do not have parents.
|
||||
*/
|
||||
//TODO- what we have a loop of links?
|
||||
for(PackedLinkData packedLink : linksToUnpack)
|
||||
{
|
||||
for(PackedLinkData packedLink : linksToUnpack) {
|
||||
if(packedLink.parent.equals(fakePoint))
|
||||
{
|
||||
DimData data = PocketManager.getDimensionData(packedLink.source.getDimension());
|
||||
|
@ -212,7 +191,7 @@ public class DDSaveHandler
|
|||
Point4D destination = packedLink.tail.destination;
|
||||
if(destination!=null)
|
||||
{
|
||||
PocketManager.createDimensionDataDangerously(destination.getDimension()).setLinkDestination(link, destination.getX(),destination.getY(),destination.getZ());
|
||||
PocketManager.createDimensionDataDangerously(destination.getDimension()).setLinkDestination(link, destination.toBlockPos());
|
||||
}
|
||||
unpackedLinks.add(packedLink);
|
||||
}
|
||||
|
|
|
@ -2,35 +2,30 @@ package com.zixiken.dimdoors.schematic;
|
|||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
public class ReplacementFilter extends SchematicFilter {
|
||||
|
||||
private Block targetBlock;
|
||||
private byte targetMetadata;
|
||||
private boolean matchMetadata;
|
||||
private Block replacementBlock;
|
||||
private byte replacementMetadata;
|
||||
private boolean changeMetadata;
|
||||
private IBlockState targetState;
|
||||
private boolean matchState;
|
||||
private IBlockState replacementState;
|
||||
private boolean changeState;
|
||||
|
||||
public ReplacementFilter(Block targetBlock, byte targetMetadata, Block replacementBlock, byte replacementMetadata)
|
||||
{
|
||||
public ReplacementFilter(IBlockState targetState, byte targetMetadata, IBlockState replacementState) {
|
||||
super("ReplacementFilter");
|
||||
this.targetBlock = targetBlock;
|
||||
this.targetMetadata = targetMetadata;
|
||||
this.matchMetadata = true;
|
||||
this.replacementBlock = replacementBlock;
|
||||
this.replacementMetadata = replacementMetadata;
|
||||
this.changeMetadata = true;
|
||||
this.targetState = targetState;
|
||||
this.matchState = true;
|
||||
this.replacementState = replacementState;
|
||||
this.changeState = true;
|
||||
}
|
||||
|
||||
public ReplacementFilter(Block targetBlock, Block replacementBlock, byte replacementMetadata)
|
||||
/*public ReplacementFilter(IBlockState targetState, IBlockState replacementState)
|
||||
{
|
||||
super("ReplacementFilter");
|
||||
this.targetBlock = targetBlock;
|
||||
this.matchMetadata = false;
|
||||
this.replacementBlock = replacementBlock;
|
||||
this.replacementMetadata = replacementMetadata;
|
||||
this.changeMetadata = true;
|
||||
this.targetState = targetState;
|
||||
this.matchState = false;
|
||||
this.replacementState = replacementState;
|
||||
this.changeState = true;
|
||||
}
|
||||
|
||||
public ReplacementFilter(Block targetBlock, byte targetMetadata, Block replacementBlock)
|
||||
|
@ -38,31 +33,26 @@ public class ReplacementFilter extends SchematicFilter {
|
|||
super("ReplacementFilter");
|
||||
this.targetBlock = targetBlock;
|
||||
this.targetMetadata = targetMetadata;
|
||||
this.matchMetadata = true;
|
||||
this.matchState = true;
|
||||
this.replacementBlock = replacementBlock;
|
||||
this.changeMetadata = false;
|
||||
this.changeState = false;
|
||||
}
|
||||
|
||||
public ReplacementFilter(Block targetBlock, Block replacementBlock)
|
||||
{
|
||||
public ReplacementFilter(IBlockState targetState, IBlockState replacementState) {
|
||||
super("ReplacementFilter");
|
||||
this.targetBlock = targetBlock;
|
||||
this.matchMetadata = false;
|
||||
this.replacementBlock = replacementBlock;
|
||||
this.changeMetadata = false;
|
||||
}
|
||||
this.targetState = targetState;
|
||||
this.matchState = false;
|
||||
this.replacementState = replacementState;
|
||||
this.changeState = false;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
protected boolean applyToBlock(int index, Block[] blocks, byte[] metadata)
|
||||
{
|
||||
if (blocks[index] == targetBlock)
|
||||
{
|
||||
if ((matchMetadata && metadata[index] == targetMetadata) || !matchMetadata)
|
||||
{
|
||||
blocks[index] = replacementBlock;
|
||||
if (changeMetadata)
|
||||
{
|
||||
metadata[index] = replacementMetadata;
|
||||
protected boolean applyToBlock(int index, IBlockState[] states) {
|
||||
if (states[index] == targetState) {
|
||||
if ((matchState && states[index] == targetState) || !matchState) {
|
||||
states[index] = replacementState;
|
||||
if (changeState) {
|
||||
states[index] = replacementState;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,29 +1,20 @@
|
|||
package com.zixiken.dimdoors.schematic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class WorldBlockSetter implements IBlockSetter
|
||||
{
|
||||
public final int BLOCK_UPDATES_FLAG = 1;
|
||||
public final int NOTIFY_CLIENT_FLAG = 2;
|
||||
|
||||
private int flags;
|
||||
public class WorldBlockSetter implements IBlockSetter {
|
||||
private boolean ignoreAir;
|
||||
|
||||
public WorldBlockSetter(boolean doBlockUpdates, boolean notifyClients, boolean ignoreAir)
|
||||
{
|
||||
this.flags = 0;
|
||||
this.flags += doBlockUpdates ? BLOCK_UPDATES_FLAG : 0;
|
||||
this.flags += notifyClients ? NOTIFY_CLIENT_FLAG : 0;
|
||||
public WorldBlockSetter(boolean doBlockUpdates, boolean notifyClients, boolean ignoreAir) {
|
||||
this.ignoreAir = ignoreAir;
|
||||
}
|
||||
|
||||
public void setBlock(World world, int x, int y, int z, Block block, int metadata)
|
||||
{
|
||||
if (!ignoreAir || !block.isAir(world,x,y,z))
|
||||
{
|
||||
world.setBlock(x, y, z, block, metadata, flags);
|
||||
|
||||
public void setBlock(World world, BlockPos pos, IBlockState state) {
|
||||
if (!ignoreAir || !world.isAirBlock(pos)) {
|
||||
world.setBlockState(pos, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
@ -28,8 +29,7 @@ public class CustomLimboPopulator implements IRegularTickReceiver {
|
|||
private DDProperties properties;
|
||||
private ConcurrentLinkedQueue<ChunkLocation> locations;
|
||||
|
||||
public CustomLimboPopulator(IRegularTickSender sender, DDProperties properties)
|
||||
{
|
||||
public CustomLimboPopulator(IRegularTickSender sender, DDProperties properties) {
|
||||
this.properties = properties;
|
||||
this.locations = new ConcurrentLinkedQueue<ChunkLocation>();
|
||||
sender.registerReceiver(this, MONOLITH_SPAWNING_INTERVAL, false);
|
||||
|
@ -41,17 +41,13 @@ public class CustomLimboPopulator implements IRegularTickReceiver {
|
|||
World limboWorld = null;
|
||||
|
||||
// Check if any new spawning requests have come in
|
||||
if (!locations.isEmpty())
|
||||
{
|
||||
if (!locations.isEmpty()) {
|
||||
// Check if mob spawning is allowed
|
||||
if (isMobSpawningAllowed())
|
||||
{
|
||||
if (isMobSpawningAllowed()) {
|
||||
// Loop over the locations and call the appropriate function depending
|
||||
// on whether the request is for Limbo or for a pocket dimension.
|
||||
for (ChunkLocation location : locations)
|
||||
{
|
||||
if (location.DimensionID == properties.LimboDimensionID)
|
||||
{
|
||||
for (ChunkLocation location : locations) {
|
||||
if (location.DimensionID == properties.LimboDimensionID) {
|
||||
// Limbo chunk
|
||||
|
||||
// SenseiKiwi: Check if we haven't loaded Limbo for another request in this request
|
||||
|
@ -61,16 +57,14 @@ public class CustomLimboPopulator implements IRegularTickReceiver {
|
|||
// is that CC force-loads a chunk for some reason, but since there are no players around,
|
||||
// Limbo immediately unloads after standard world gen runs, and before this code can run.
|
||||
|
||||
if (limboWorld == null)
|
||||
{
|
||||
if (limboWorld == null) {
|
||||
limboWorld = PocketManager.loadDimension(properties.LimboDimensionID);
|
||||
}
|
||||
|
||||
placeMonolithsInLimbo(limboWorld, location.ChunkX, location.ChunkZ);
|
||||
DimDoors.gatewayGenerator.generate(limboWorld.rand, location.ChunkX, location.ChunkZ,
|
||||
limboWorld, limboWorld.getChunkProvider(), limboWorld.getChunkProvider());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//Pocket dimension chunk
|
||||
placeMonolithsInPocket(location.DimensionID, location.ChunkX, location.ChunkZ);
|
||||
}
|
||||
|
@ -81,22 +75,16 @@ public class CustomLimboPopulator implements IRegularTickReceiver {
|
|||
}
|
||||
}
|
||||
|
||||
public void registerChunkForPopulation(int dimensionID, int chunkX, int chunkZ)
|
||||
{
|
||||
public void registerChunkForPopulation(int dimensionID, int chunkX, int chunkZ) {
|
||||
ChunkLocation location = new ChunkLocation(dimensionID, chunkX, chunkZ);
|
||||
locations.add(location);
|
||||
}
|
||||
|
||||
private void placeMonolithsInPocket(int dimensionID, int chunkX, int chunkZ)
|
||||
{
|
||||
private void placeMonolithsInPocket(int dimensionID, int chunkX, int chunkZ) {
|
||||
DimData dimension = PocketManager.getDimensionData(dimensionID);
|
||||
World pocket = DimensionManager.getWorld(dimensionID);
|
||||
|
||||
if (pocket == null ||
|
||||
dimension == null ||
|
||||
dimension.dungeon() == null ||
|
||||
dimension.dungeon().isOpen())
|
||||
{
|
||||
if (pocket == null || dimension == null || dimension.dungeon() == null || dimension.dungeon().isOpen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -112,54 +100,51 @@ public class CustomLimboPopulator implements IRegularTickReceiver {
|
|||
random.setSeed(chunkX * factorA + chunkZ * factorB ^ pocket.getSeed());
|
||||
|
||||
//The following code really, really needs to be rewritten... "sanity" is not a proper variable name. ~SenseiKiwi
|
||||
int x, y, z;
|
||||
do
|
||||
{
|
||||
BlockPos pos;
|
||||
do {
|
||||
//Select a random column within the chunk
|
||||
x = chunkX * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
|
||||
z = chunkZ * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
|
||||
y = MAX_MONOLITH_SPAWN_Y;
|
||||
block = pocket.getBlock(x, y, z);
|
||||
pos = new BlockPos(chunkX * CHUNK_SIZE + random.nextInt(CHUNK_SIZE), chunkZ * CHUNK_SIZE + random.nextInt(CHUNK_SIZE), MAX_MONOLITH_SPAWN_Y);
|
||||
block = pocket.getBlockState(pos).getBlock();
|
||||
|
||||
while (block.isAir(pocket, x, y, z) &&y>0)
|
||||
{
|
||||
y--;
|
||||
block = pocket.getBlock(x, y, z);
|
||||
while (block.isAir(pocket, pos) && pos.getY() > 0) {
|
||||
pos = pos.down();
|
||||
block = pocket.getBlockState(pos).getBlock();
|
||||
}
|
||||
|
||||
while ((block == DimDoors.blockDimWall || block == DimDoors.blockDimWallPerm) && pos.getY() > 0) {
|
||||
pos = pos.down();
|
||||
block = pocket.getBlockState(pos).getBlock();
|
||||
}
|
||||
while ((block == DimDoors.blockDimWall || block == DimDoors.blockDimWallPerm) && y > 0)
|
||||
{
|
||||
y--;
|
||||
block = pocket.getBlock(x, y, z);
|
||||
|
||||
while (block.isAir(pocket, pos) && pos.getY() > 0) {
|
||||
pos = pos.down();
|
||||
block = pocket.getBlockState(pos).getBlock();
|
||||
}
|
||||
while (block.isAir(pocket, x, y, z) && y > 0)
|
||||
{
|
||||
y--;
|
||||
block = pocket.getBlock(x, y, z);
|
||||
}
|
||||
if(y > 0)
|
||||
{
|
||||
|
||||
if(pos.getY() > 0) {
|
||||
int jumpSanity = 0;
|
||||
int jumpHeight = 0;
|
||||
do
|
||||
{
|
||||
jumpHeight = y + random.nextInt(10);
|
||||
|
||||
do {
|
||||
jumpHeight = pos.getY() + random.nextInt(10);
|
||||
jumpSanity++;
|
||||
}
|
||||
while (!pocket.isAirBlock(x,jumpHeight+6 , z)&&jumpSanity<20);
|
||||
|
||||
while (!pocket.isAirBlock(new BlockPos(pos.getX(),jumpHeight+6 , pos.getZ()))&&jumpSanity<20);
|
||||
|
||||
MobMonolith monolith = new MobMonolith(pocket);
|
||||
monolith.setLocationAndAngles(x, jumpHeight-(5-monolith.getRenderSizeModifier()*5), z, 1, 1);
|
||||
monolith.setLocationAndAngles(pos.getX(), jumpHeight-(5-monolith.getRenderSizeModifier()*5), pos.getZ(), 1, 1);
|
||||
pocket.spawnEntityInWorld(monolith);
|
||||
didSpawn = true;
|
||||
}
|
||||
|
||||
sanity++;
|
||||
}
|
||||
|
||||
while (sanity < 5 && !didSpawn);
|
||||
}
|
||||
|
||||
private void placeMonolithsInLimbo(World limbo, int chunkX, int chunkZ)
|
||||
{
|
||||
private void placeMonolithsInLimbo(World limbo, int chunkX, int chunkZ) {
|
||||
//The following initialization code is based on code from ChunkProviderGenerate.
|
||||
//It makes our generation depend on the world seed.
|
||||
Random random = new Random(limbo.getSeed() ^ 0xB5130C4ACC71A822L);
|
||||
|
@ -168,23 +153,21 @@ public class CustomLimboPopulator implements IRegularTickReceiver {
|
|||
random.setSeed(chunkX * factorA + chunkZ * factorB ^ limbo.getSeed());
|
||||
|
||||
//Okay, the following code is full of magic constants and makes little sense. =/ ~SenseiKiwi
|
||||
if (random.nextInt(MAX_MONOLITH_SPAWNING_CHANCE) < properties.MonolithSpawningChance)
|
||||
{
|
||||
int y = 0;
|
||||
if (random.nextInt(MAX_MONOLITH_SPAWNING_CHANCE) < properties.MonolithSpawningChance) {
|
||||
BlockPos pos = BlockPos.ORIGIN;
|
||||
int yTest;
|
||||
do
|
||||
{
|
||||
int x = chunkX * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
|
||||
int z = chunkZ * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
|
||||
|
||||
while (limbo.getBlock(x, y, z).isAir(limbo, x, y, z) && y <255)
|
||||
{
|
||||
y++;
|
||||
do {
|
||||
pos = new BlockPos(chunkX * CHUNK_SIZE + random.nextInt(CHUNK_SIZE), 0, chunkZ * CHUNK_SIZE + random.nextInt(CHUNK_SIZE));
|
||||
|
||||
while (limbo.getBlockState(pos).getBlock().isAir(limbo, pos) && pos.getY() <255) {
|
||||
pos = pos.up();
|
||||
}
|
||||
y = yCoordHelper.getFirstUncovered(limbo, x, y + 2, z);
|
||||
yTest = yCoordHelper.getFirstUncovered(limbo, x, y + 5, z);
|
||||
if (yTest > 245)
|
||||
{
|
||||
|
||||
pos = new BlockPos(pos.getX(), yCoordHelper.getFirstUncovered(limbo, pos.up(2)), pos.getZ());
|
||||
yTest = yCoordHelper.getFirstUncovered(limbo, pos.up(5));
|
||||
|
||||
if (yTest > 245) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -192,26 +175,25 @@ public class CustomLimboPopulator implements IRegularTickReceiver {
|
|||
int jumpHeight = 0;
|
||||
do
|
||||
{
|
||||
jumpHeight = y + random.nextInt(25);
|
||||
jumpHeight = pos.getY() + random.nextInt(25);
|
||||
jumpSanity++;
|
||||
}
|
||||
while (!limbo.isAirBlock(x, jumpHeight + 6, z) && jumpSanity < 20);
|
||||
while (!limbo.isAirBlock(new BlockPos(pos.getX(), jumpHeight + 6, pos.getZ())) && jumpSanity < 20);
|
||||
|
||||
|
||||
Entity monolith = new MobMonolith(limbo);
|
||||
monolith.setLocationAndAngles(x, jumpHeight, z, 1, 1);
|
||||
monolith.setLocationAndAngles(pos.getX(), jumpHeight, pos.getZ(), 1, 1);
|
||||
limbo.spawnEntityInWorld(monolith);
|
||||
}
|
||||
while (yTest > y);
|
||||
while (yTest > pos.getX());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isMobSpawningAllowed()
|
||||
{
|
||||
public static boolean isMobSpawningAllowed() {
|
||||
//This function is used to retrieve the value of doMobSpawning. The code is the same
|
||||
//as the code used by Minecraft. Jaitsu requested this to make testing easier. ~SenseiKiwi
|
||||
|
||||
GameRules rules = MinecraftServer.getServer().worldServerForDimension(0).getGameRules();
|
||||
return rules.getGameRuleBooleanValue(MOB_SPAWNING_RULE);
|
||||
return rules.getBoolean(MOB_SPAWNING_RULE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,22 +31,19 @@ public class RiftRegenerator implements IRegularTickReceiver {
|
|||
private PriorityQueue<RiftTicket> ticketQueue;
|
||||
private BlockRift blockRift;
|
||||
|
||||
public RiftRegenerator(IRegularTickSender sender, BlockRift blockRift)
|
||||
{
|
||||
public RiftRegenerator(IRegularTickSender sender, BlockRift blockRift) {
|
||||
this.ticketQueue = new PriorityQueue<RiftTicket>();
|
||||
this.blockRift = blockRift;
|
||||
sender.registerReceiver(this, RIFT_REGENERATION_INTERVAL, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyTick()
|
||||
{
|
||||
public void notifyTick() {
|
||||
processTicketQueue();
|
||||
tickCount++;
|
||||
}
|
||||
|
||||
public void scheduleSlowRegeneration(DimLink link)
|
||||
{
|
||||
public void scheduleSlowRegeneration(DimLink link) {
|
||||
scheduleRegeneration(link, MIN_SLOW_DELAY, MAX_SLOW_DELAY);
|
||||
}
|
||||
|
||||
|
@ -58,31 +55,22 @@ public class RiftRegenerator implements IRegularTickReceiver {
|
|||
scheduleRegeneration(PocketManager.getLink(pos, world), MIN_FAST_DELAY, MAX_FAST_DELAY);
|
||||
}
|
||||
|
||||
private void scheduleRegeneration(DimLink link, int minDelay, int maxDelay)
|
||||
{
|
||||
if (link != null)
|
||||
{
|
||||
private void scheduleRegeneration(DimLink link, int minDelay, int maxDelay) {
|
||||
if (link != null) {
|
||||
int tickDelay = MathHelper.getRandomIntegerInRange(random, minDelay * TICKS_PER_SECOND, maxDelay * TICKS_PER_SECOND);
|
||||
ticketQueue.add(new RiftTicket(link.source(), tickCount + tickDelay));
|
||||
}
|
||||
}
|
||||
|
||||
private void processTicketQueue()
|
||||
{
|
||||
private void processTicketQueue() {
|
||||
RiftTicket ticket;
|
||||
while (!ticketQueue.isEmpty() && ticketQueue.peek().timestamp() <= tickCount)
|
||||
{
|
||||
while (!ticketQueue.isEmpty() && ticketQueue.peek().timestamp() <= tickCount) {
|
||||
ticket = ticketQueue.remove();
|
||||
regenerateRift(ticket.location());
|
||||
}
|
||||
}
|
||||
|
||||
private void regenerateRift(Point4D location)
|
||||
{
|
||||
int x = location.getX();
|
||||
int y = location.getY();
|
||||
int z = location.getZ();
|
||||
|
||||
private void regenerateRift(Point4D location) {
|
||||
// Try to regenerate a rift, or possibly reschedule its regeneration.
|
||||
// The world for the given location must be loaded.
|
||||
World world = DimensionManager.getWorld(location.getDimension());
|
||||
|
@ -97,24 +85,20 @@ public class RiftRegenerator implements IRegularTickReceiver {
|
|||
// The chunk at the given location must be loaded.
|
||||
// Note: ChunkProviderServer.chunkExists() returns whether a chunk is
|
||||
// loaded, not whether it has already been created.
|
||||
if (!world.getChunkProvider().chunkExists(x >> 4, z >> 4))
|
||||
if (!world.getChunkProvider().chunkExists(location.getX() >> 4, location.getZ() >> 4))
|
||||
return;
|
||||
|
||||
// If the location is occupied by an immune DD block, then don't regenerate.
|
||||
if (blockRift.isModBlockImmune(world, x, y, z))
|
||||
if (blockRift.isModBlockImmune(world, location.toBlockPos()))
|
||||
return;
|
||||
|
||||
// If the location is occupied by an immune block, then reschedule.
|
||||
if (blockRift.isBlockImmune(world, x, y, z))
|
||||
{
|
||||
if (blockRift.isBlockImmune(world, location.toBlockPos())) {
|
||||
scheduleRegeneration(link, MIN_RESCHEDULE_DELAY, MAX_RESCHEDULE_DELAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// All of the necessary conditions have been met. Restore the rift!
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (world.setBlock(x, y, z, blockRift))
|
||||
blockRift.dropWorldThread(block, world, x, y, z, random);
|
||||
if (world.setBlockState(location.toBlockPos(), blockRift.getDefaultState()))
|
||||
blockRift.dropWorldThread(world, location.toBlockPos(), random);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.zixiken.dimdoors.world;
|
||||
|
||||
public class BiomeGenLimbo extends DDBiomeGenBase
|
||||
{
|
||||
public BiomeGenLimbo(int biomeID)
|
||||
{
|
||||
public class BiomeGenLimbo extends DDBiomeGenBase {
|
||||
public BiomeGenLimbo(int biomeID) {
|
||||
super(biomeID, "Limbo");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.zixiken.dimdoors.world;
|
||||
|
||||
public class BiomeGenPocket extends DDBiomeGenBase
|
||||
{
|
||||
public BiomeGenPocket(int biomeID)
|
||||
{
|
||||
public class BiomeGenPocket extends DDBiomeGenBase {
|
||||
public BiomeGenPocket(int biomeID) {
|
||||
super(biomeID, "Pocket Dimension");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,17 +5,17 @@ import java.util.Random;
|
|||
import com.zixiken.dimdoors.DimDoors;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.ChunkPrimer;
|
||||
import net.minecraft.world.gen.MapGenBase;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
|
||||
public class CustomCaveGen extends MapGenBase
|
||||
{
|
||||
public class CustomCaveGen extends MapGenBase {
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public CustomCaveGen()
|
||||
{
|
||||
public CustomCaveGen() {
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
@ -23,40 +23,35 @@ public class CustomCaveGen extends MapGenBase
|
|||
/**
|
||||
* Generates a larger initial cave node than usual. Called 25% of the time.
|
||||
*/
|
||||
protected void generateLargeCaveNode(long par1, int par3, int par4, Block[] blocks, double par6, double par8, double par10)
|
||||
{
|
||||
this.generateCaveNode(par1, par3, par4, blocks, par6, par8, par10, 1.0F + this.rand.nextFloat() * 6.0F, 0.0F, 0.0F, -1, -1, 0.5D);
|
||||
protected void generateLargeCaveNode(long par1, int par3, int par4, ChunkPrimer primer, double par6, double par8, double par10) {
|
||||
this.generateCaveNode(par1, par3, par4, primer, par6, par8, par10, 1.0F + this.rand.nextFloat() * 6.0F, 0.0F, 0.0F, -1, -1, 0.5D);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a node in the current cave system recursion tree.
|
||||
*/
|
||||
protected void generateCaveNode(long par1, int par3, int par4, Block[] blocks, double par6, double par8, double par10, float par12, float par13, float par14, int par15, int par16, double par17)
|
||||
{
|
||||
protected void generateCaveNode(long par1, int par3, int par4, ChunkPrimer primer, double par6, double par8, double par10, float par12, float par13, float par14, int par15, int par16, double par17) {
|
||||
double var19 = par3 * 16 + 8;
|
||||
double var21 = par4 * 16 + 8;
|
||||
float var23 = 0.0F;
|
||||
float var24 = 0.0F;
|
||||
Random var25 = new Random(par1);
|
||||
|
||||
if (par16 <= 0)
|
||||
{
|
||||
if (par16 <= 0) {
|
||||
int var26 = this.range * 16 - 16;
|
||||
par16 = var26 - var25.nextInt(var26 / 4);
|
||||
}
|
||||
|
||||
boolean var54 = false;
|
||||
|
||||
if (par15 == -1)
|
||||
{
|
||||
if (par15 == -1) {
|
||||
par15 = par16 / 2;
|
||||
var54 = true;
|
||||
}
|
||||
|
||||
int var27 = var25.nextInt(par16 / 2) + par16 / 4;
|
||||
|
||||
for (boolean var28 = var25.nextInt(6) == 0; par15 < par16; ++par15)
|
||||
{
|
||||
for (boolean var28 = var25.nextInt(6) == 0; par15 < par16; ++par15) {
|
||||
double var29 = 1.5D + MathHelper.sin(par15 * (float)Math.PI / par16) * par12 * 1.0F;
|
||||
double var31 = var29 * par17;
|
||||
float var33 = MathHelper.cos(par14);
|
||||
|
@ -65,12 +60,9 @@ public class CustomCaveGen extends MapGenBase
|
|||
par8 += var34;
|
||||
par10 += MathHelper.sin(par13) * var33;
|
||||
|
||||
if (var28)
|
||||
{
|
||||
if (var28) {
|
||||
par14 *= 0.92F;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
par14 *= 0.7F;
|
||||
}
|
||||
|
||||
|
@ -81,27 +73,23 @@ public class CustomCaveGen extends MapGenBase
|
|||
var24 += (var25.nextFloat() - var25.nextFloat()) * var25.nextFloat() * 2.0F;
|
||||
var23 += (var25.nextFloat() - var25.nextFloat()) * var25.nextFloat() * 4.0F;
|
||||
|
||||
if (!var54 && par15 == var27 && par12 > 1.0F && par16 > 0)
|
||||
{
|
||||
this.generateCaveNode(var25.nextLong(), par3, par4, blocks, par6, par8, par10, var25.nextFloat() * 0.5F + 0.5F, par13 - ((float)Math.PI / 2F), par14 / 3.0F, par15, par16, 1.0D);
|
||||
this.generateCaveNode(var25.nextLong(), par3, par4, blocks, par6, par8, par10, var25.nextFloat() * 0.5F + 0.5F, par13 + ((float)Math.PI / 2F), par14 / 3.0F, par15, par16, 1.0D);
|
||||
if (!var54 && par15 == var27 && par12 > 1.0F && par16 > 0) {
|
||||
this.generateCaveNode(var25.nextLong(), par3, par4, primer, par6, par8, par10, var25.nextFloat() * 0.5F + 0.5F, par13 - ((float)Math.PI / 2F), par14 / 3.0F, par15, par16, 1.0D);
|
||||
this.generateCaveNode(var25.nextLong(), par3, par4, primer, par6, par8, par10, var25.nextFloat() * 0.5F + 0.5F, par13 + ((float)Math.PI / 2F), par14 / 3.0F, par15, par16, 1.0D);
|
||||
return;
|
||||
}
|
||||
|
||||
if (var54 || var25.nextInt(4) != 0)
|
||||
{
|
||||
if (var54 || var25.nextInt(4) != 0) {
|
||||
double var35 = par6 - var19;
|
||||
double var37 = par10 - var21;
|
||||
double var39 = par16 - par15;
|
||||
double var41 = par12 + 2.0F + 16.0F;
|
||||
|
||||
if (var35 * var35 + var37 * var37 - var39 * var39 > var41 * var41)
|
||||
{
|
||||
if (var35 * var35 + var37 * var37 - var39 * var39 > var41 * var41) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (par6 >= var19 - 16.0D - var29 * 2.0D && par10 >= var21 - 16.0D - var29 * 2.0D && par6 <= var19 + 16.0D + var29 * 2.0D && par10 <= var21 + 16.0D + var29 * 2.0D)
|
||||
{
|
||||
if (par6 >= var19 - 16.0D - var29 * 2.0D && par10 >= var21 - 16.0D - var29 * 2.0D && par6 <= var19 + 16.0D + var29 * 2.0D && par10 <= var21 + 16.0D + var29 * 2.0D) {
|
||||
int var55 = MathHelper.floor_double(par6 - var29) - par3 * 16 - 1;
|
||||
int var36 = MathHelper.floor_double(par6 + var29) - par3 * 16 + 1;
|
||||
int var57 = MathHelper.floor_double(par8 - var31) - 1;
|
||||
|
@ -109,33 +97,27 @@ public class CustomCaveGen extends MapGenBase
|
|||
int var56 = MathHelper.floor_double(par10 - var29) - par4 * 16 - 1;
|
||||
int var40 = MathHelper.floor_double(par10 + var29) - par4 * 16 + 1;
|
||||
|
||||
if (var55 < 0)
|
||||
{
|
||||
if (var55 < 0) {
|
||||
var55 = 0;
|
||||
}
|
||||
|
||||
if (var36 > 16)
|
||||
{
|
||||
if (var36 > 16) {
|
||||
var36 = 16;
|
||||
}
|
||||
|
||||
if (var57 < 1)
|
||||
{
|
||||
if (var57 < 1) {
|
||||
var57 = 1;
|
||||
}
|
||||
|
||||
if (var38 > 120)
|
||||
{
|
||||
if (var38 > 120) {
|
||||
var38 = 120;
|
||||
}
|
||||
|
||||
if (var56 < 0)
|
||||
{
|
||||
if (var56 < 0) {
|
||||
var56 = 0;
|
||||
}
|
||||
|
||||
if (var40 > 16)
|
||||
{
|
||||
if (var40 > 16) {
|
||||
var40 = 16;
|
||||
}
|
||||
|
||||
|
@ -143,23 +125,17 @@ public class CustomCaveGen extends MapGenBase
|
|||
int var42;
|
||||
int var45;
|
||||
|
||||
for (var42 = var55; !var58 && var42 < var36; ++var42)
|
||||
{
|
||||
for (int var43 = var56; !var58 && var43 < var40; ++var43)
|
||||
{
|
||||
for (int var44 = var38 + 1; !var58 && var44 >= var57 - 1; --var44)
|
||||
{
|
||||
for (var42 = var55; !var58 && var42 < var36; ++var42) {
|
||||
for (int var43 = var56; !var58 && var43 < var40; ++var43) {
|
||||
for (int var44 = var38 + 1; !var58 && var44 >= var57 - 1; --var44) {
|
||||
var45 = (var42 * 16 + var43) * 128 + var44;
|
||||
|
||||
if (var44 >= 0 && var44 < 128)
|
||||
{
|
||||
if (blocks[var45] == Blocks.flowing_water || blocks[var45] == Blocks.water)
|
||||
{
|
||||
if (var44 >= 0 && var44 < 128) {
|
||||
if (primer.getBlockState(var45) == Blocks.flowing_water || primer.getBlockState(var45) == Blocks.water) {
|
||||
var58 = true;
|
||||
}
|
||||
|
||||
if (var44 != var57 - 1 && var42 != var55 && var42 != var36 - 1 && var43 != var56 && var43 != var40 - 1)
|
||||
{
|
||||
if (var44 != var57 - 1 && var42 != var55 && var42 != var36 - 1 && var43 != var56 && var43 != var40 - 1) {
|
||||
var44 = var57;
|
||||
}
|
||||
}
|
||||
|
@ -167,46 +143,34 @@ public class CustomCaveGen extends MapGenBase
|
|||
}
|
||||
}
|
||||
|
||||
if (!var58)
|
||||
{
|
||||
for (var42 = var55; var42 < var36; ++var42)
|
||||
{
|
||||
if (!var58) {
|
||||
for (var42 = var55; var42 < var36; ++var42) {
|
||||
double var59 = (var42 + par3 * 16 + 0.5D - par6) / var29;
|
||||
|
||||
for (var45 = var56; var45 < var40; ++var45)
|
||||
{
|
||||
for (var45 = var56; var45 < var40; ++var45) {
|
||||
double var46 = (var45 + par4 * 16 + 0.5D - par10) / var29;
|
||||
int var48 = (var42 * 16 + var45) * 128 + var38;
|
||||
boolean var49 = false;
|
||||
|
||||
if (var59 * var59 + var46 * var46 < 1.0D)
|
||||
{
|
||||
for (int var50 = var38 - 1; var50 >= var57; --var50)
|
||||
{
|
||||
if (var59 * var59 + var46 * var46 < 1.0D) {
|
||||
for (int var50 = var38 - 1; var50 >= var57; --var50) {
|
||||
double var51 = (var50 + 0.5D - par8) / var31;
|
||||
|
||||
if (var51 > -0.7D && var59 * var59 + var51 * var51 + var46 * var46 < 1.0D)
|
||||
{
|
||||
Block var53 = blocks[var48];
|
||||
if (var51 > -0.7D && var59 * var59 + var51 * var51 + var46 * var46 < 1.0D) {
|
||||
Block var53 = primer.getBlockState(var48).getBlock();
|
||||
|
||||
if (var53 == Blocks.grass)
|
||||
{
|
||||
if (var53 == Blocks.grass) {
|
||||
var49 = true;
|
||||
}
|
||||
|
||||
if (var53 == DimDoors.blockLimbo || var53 == Blocks.dirt || var53 == Blocks.grass)
|
||||
{
|
||||
if (var50 < 10)
|
||||
{
|
||||
blocks[var48] = Blocks.flowing_lava;
|
||||
}
|
||||
else
|
||||
{
|
||||
blocks[var48] = Blocks.air;
|
||||
if (var53 == DimDoors.blockLimbo || var53 == Blocks.dirt || var53 == Blocks.grass) {
|
||||
if (var50 < 10) {
|
||||
primer.setBlockState(var48, Blocks.flowing_lava.getDefaultState());
|
||||
} else {
|
||||
primer.setBlockState(var48, Blocks.air.getDefaultState());
|
||||
|
||||
if (var49 && blocks[var48 - 1] == Blocks.dirt)
|
||||
{
|
||||
blocks[var48 - 1] = this.worldObj.getBiomeGenForCoords(var42 + par3 * 16, var45 + par4 * 16).topBlock;
|
||||
if (var49 && primer.getBlockState(var48 - 1) == Blocks.dirt) {
|
||||
primer.setBlockState(var48 - 1, this.worldObj.getBiomeGenForCoords(new BlockPos(var42 + par3 * 16, 0, var45 + par4 * 16)).topBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -218,8 +182,7 @@ public class CustomCaveGen extends MapGenBase
|
|||
}
|
||||
}
|
||||
|
||||
if (var54)
|
||||
{
|
||||
if (var54) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -232,40 +195,34 @@ public class CustomCaveGen extends MapGenBase
|
|||
* Recursively called by generate() (generate) and optionally by itself.
|
||||
*/
|
||||
@Override
|
||||
protected void func_151538_a(World par1World, int par2, int par3, int par4, int par5, Block[] blocks)
|
||||
{
|
||||
protected void recursiveGenerate(World par1World, int x, int z, int par4, int par5, ChunkPrimer primer) {
|
||||
int var7 = this.rand.nextInt(this.rand.nextInt(this.rand.nextInt(40) + 1) + 1);
|
||||
|
||||
if (this.rand.nextInt(15) != 0)
|
||||
{
|
||||
if (this.rand.nextInt(15) != 0) {
|
||||
var7 = 0;
|
||||
}
|
||||
|
||||
for (int var8 = 0; var8 < var7; ++var8)
|
||||
{
|
||||
double var9 = par2 * 16 + this.rand.nextInt(16);
|
||||
for (int var8 = 0; var8 < var7; ++var8) {
|
||||
double var9 = x * 16 + this.rand.nextInt(16);
|
||||
double var11 = this.rand.nextInt(this.rand.nextInt(120) + 8);
|
||||
double var13 = par3 * 16 + this.rand.nextInt(16);
|
||||
double var13 = z * 16 + this.rand.nextInt(16);
|
||||
int var15 = 1;
|
||||
|
||||
if (this.rand.nextInt(4) == 0)
|
||||
{
|
||||
this.generateLargeCaveNode(this.rand.nextLong(), par4, par5, blocks, var9, var11, var13);
|
||||
if (this.rand.nextInt(4) == 0) {
|
||||
this.generateLargeCaveNode(this.rand.nextLong(), par4, par5, primer, var9, var11, var13);
|
||||
var15 += this.rand.nextInt(4);
|
||||
}
|
||||
|
||||
for (int var16 = 0; var16 < var15; ++var16)
|
||||
{
|
||||
for (int var16 = 0; var16 < var15; ++var16) {
|
||||
float var17 = this.rand.nextFloat() * (float)Math.PI * 2.0F;
|
||||
float var18 = (this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F;
|
||||
float var19 = this.rand.nextFloat() * 2.0F + this.rand.nextFloat();
|
||||
|
||||
if (this.rand.nextInt(10) == 0)
|
||||
{
|
||||
if (this.rand.nextInt(10) == 0) {
|
||||
var19 *= this.rand.nextFloat() * this.rand.nextFloat() * 3.0F + 1.0F;
|
||||
}
|
||||
|
||||
this.generateCaveNode(this.rand.nextLong(), par4, par5, blocks, var9, var11, var13, var19, var17, var18, 0, 0, 1.0D);
|
||||
this.generateCaveNode(this.rand.nextLong(), par4, par5, primer, var9, var11, var13, var19, var17, var18, 0, 0, 1.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,9 +33,8 @@ public class CustomSkyProvider extends IRenderHandler
|
|||
|
||||
|
||||
@Override
|
||||
public void render(float par1, WorldClient world, Minecraft mc)
|
||||
{
|
||||
|
||||
public void render(float par1, WorldClient world, Minecraft mc) {
|
||||
/*
|
||||
starGLCallList = GLAllocation.generateDisplayLists(3);
|
||||
glSkyList = this.starGLCallList + 1;
|
||||
glSkyList2 = this.starGLCallList + 2;
|
||||
|
@ -225,9 +224,6 @@ public class CustomSkyProvider extends IRenderHandler
|
|||
GL11.glCallList(this.glSkyList2);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glDepthMask(true);*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import java.util.Random;
|
|||
import com.zixiken.dimdoors.DimDoors;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
|
@ -25,25 +26,24 @@ public class LimboDecay {
|
|||
private static final int SECTION_HEIGHT = 16;
|
||||
|
||||
//Provides a reversed list of the block IDs that blocks cycle through during decay.
|
||||
private Block[] decaySequence = null;
|
||||
private IBlockState[] decaySequence = null;
|
||||
|
||||
private final Random random;
|
||||
private final DDProperties properties;
|
||||
private Block[] blocksImmuneToDecay = null;
|
||||
|
||||
public LimboDecay(DDProperties properties)
|
||||
{
|
||||
public LimboDecay(DDProperties properties) {
|
||||
this.properties = properties;
|
||||
this.random = new Random();
|
||||
}
|
||||
|
||||
public Block[] getDecaySequence() {
|
||||
public IBlockState[] getDecaySequence() {
|
||||
if (decaySequence == null) {
|
||||
decaySequence = new Block[] {
|
||||
DimDoors.blockLimbo,
|
||||
Blocks.gravel,
|
||||
Blocks.cobblestone,
|
||||
Blocks.stone
|
||||
decaySequence = new IBlockState[] {
|
||||
DimDoors.blockLimbo.getDefaultState(),
|
||||
Blocks.gravel.getDefaultState(),
|
||||
Blocks.cobblestone.getDefaultState(),
|
||||
Blocks.stone.getDefaultState()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -76,8 +76,7 @@ public class LimboDecay {
|
|||
|
||||
//Check if we randomly apply decay spread or not. This can be used to moderate the frequency of
|
||||
//full spread decay checks, which can also shift its performance impact on the game.
|
||||
if (random.nextInt(MAX_DECAY_SPREAD_CHANCE) < DECAY_SPREAD_CHANCE)
|
||||
{
|
||||
if (random.nextInt(MAX_DECAY_SPREAD_CHANCE) < DECAY_SPREAD_CHANCE) {
|
||||
//Apply decay to the blocks above, below, and on all four sides.
|
||||
//World.getBlockId() implements bounds checking, so we don't have to worry about reaching out of the world
|
||||
decayBlock(world, pos.west());
|
||||
|
@ -93,31 +92,25 @@ public class LimboDecay {
|
|||
* Picks random blocks from each active chunk in Limbo and, if decay is applicable, converts them directly to Unraveled Fabric.
|
||||
* This decay method is designed to stop players from avoiding Limbo decay by building floating structures.
|
||||
*/
|
||||
public void applyRandomFastDecay()
|
||||
{
|
||||
int x, y, z;
|
||||
public void applyRandomFastDecay() {
|
||||
BlockPos pos;
|
||||
int sectionY;
|
||||
int limboHeight;
|
||||
World limbo = DimensionManager.getWorld(properties.LimboDimensionID);
|
||||
|
||||
if (limbo != null)
|
||||
{
|
||||
if (limbo != null) {
|
||||
limboHeight = limbo.getHeight();
|
||||
|
||||
//Obtain the coordinates of active chunks in Limbo. For each section of each chunk,
|
||||
//pick a random block and try to apply fast decay.
|
||||
for (Object coordObject : ForgeChunkManager.getPersistentChunksFor(limbo).keySet())
|
||||
{
|
||||
for (Object coordObject : ForgeChunkManager.getPersistentChunksFor(limbo).keySet()) {
|
||||
ChunkCoordIntPair chunkCoord = (ChunkCoordIntPair) coordObject;
|
||||
|
||||
//Loop through each chunk section and fast-decay a random block
|
||||
//Apply the changes using the world object instead of directly to the chunk so that clients are always notified.
|
||||
for (sectionY = 0; sectionY < limboHeight; sectionY += SECTION_HEIGHT)
|
||||
{
|
||||
x = chunkCoord.chunkXPos * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
|
||||
z = chunkCoord.chunkZPos * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
|
||||
y = sectionY + random.nextInt(SECTION_HEIGHT);
|
||||
decayBlockFast(limbo, x, y, z);
|
||||
for (sectionY = 0; sectionY < limboHeight; sectionY += SECTION_HEIGHT) {
|
||||
pos = new BlockPos(chunkCoord.chunkXPos * CHUNK_SIZE + random.nextInt(CHUNK_SIZE), chunkCoord.chunkZPos * CHUNK_SIZE + random.nextInt(CHUNK_SIZE), sectionY + random.nextInt(SECTION_HEIGHT));
|
||||
decayBlockFast(limbo, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,12 +119,12 @@ public class LimboDecay {
|
|||
/**
|
||||
* Checks if a block can be decayed and, if so, changes it directly into Unraveled Fabric.
|
||||
*/
|
||||
private boolean decayBlockFast(World world, int x, int y, int z)
|
||||
private boolean decayBlockFast(World world, BlockPos pos)
|
||||
{
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (canDecayBlock(block, world, x, y, z))
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (canDecayBlock(state, world, pos))
|
||||
{
|
||||
world.setBlock(x, y, z, DimDoors.blockLimbo);
|
||||
world.setBlockState(pos, DimDoors.blockLimbo.getDefaultState());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -142,8 +135,8 @@ public class LimboDecay {
|
|||
*/
|
||||
private boolean decayBlock(World world, BlockPos pos) {
|
||||
int index;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (canDecayBlock(block, world, x, y, z))
|
||||
IBlockState block = world.getBlockState(pos);
|
||||
if (canDecayBlock(block, world, pos))
|
||||
{
|
||||
//Loop over the block IDs that decay can go through.
|
||||
//Find an index matching the current blockID, if any.
|
||||
|
@ -161,7 +154,7 @@ public class LimboDecay {
|
|||
//last ID in the array, which is the first one that all blocks decay into.
|
||||
//We assume that Unraveled Fabric is NOT decayable. Otherwise, this will go out of bounds!
|
||||
|
||||
world.setBlock(x, y, z, getDecaySequence()[index - 1]);
|
||||
world.setBlockState(pos, getDecaySequence()[index - 1]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -170,21 +163,17 @@ public class LimboDecay {
|
|||
/**
|
||||
* Checks if a block can decay. We will not decay air, certain DD blocks, or containers.
|
||||
*/
|
||||
private boolean canDecayBlock(Block block, World world, int x, int y, int z)
|
||||
{
|
||||
if (block.isAir(world, x, y, z))
|
||||
{
|
||||
private boolean canDecayBlock(IBlockState state, World world, BlockPos pos) {
|
||||
if (state.getBlock().isAir(world, pos)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int k = 0; k < getBlocksImmuneToDecay().length; k++)
|
||||
{
|
||||
if (block == getBlocksImmuneToDecay()[k])
|
||||
{
|
||||
for (int k = 0; k < getBlocksImmuneToDecay().length; k++) {
|
||||
if (state.getBlock() == getBlocksImmuneToDecay()[k]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return (block == null || !(block instanceof BlockContainer));
|
||||
return (state == null || !(state instanceof BlockContainer));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,16 +4,16 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.IProgressUpdate;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkPrimer;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderGenerate;
|
||||
import net.minecraft.world.gen.NoiseGeneratorOctaves;
|
||||
|
@ -22,9 +22,9 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
import net.minecraftforge.event.terraingen.ChunkProviderEvent;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.ticking.CustomLimboPopulator;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class LimboGenerator extends ChunkProviderGenerate
|
||||
{
|
||||
public class LimboGenerator extends ChunkProviderGenerate {
|
||||
private static Random rand;
|
||||
|
||||
/** A NoiseGeneratorOctaves used in generating terrain */
|
||||
|
@ -79,6 +79,7 @@ public class LimboGenerator extends ChunkProviderGenerate
|
|||
*/
|
||||
float[] parabolicField;
|
||||
int[][] field_73219_j = new int[32][32];
|
||||
|
||||
{
|
||||
// caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE);
|
||||
}
|
||||
|
@ -86,9 +87,8 @@ public class LimboGenerator extends ChunkProviderGenerate
|
|||
private DDProperties properties;
|
||||
private CustomLimboPopulator spawner;
|
||||
|
||||
public LimboGenerator(World world, long seed, CustomLimboPopulator spawner, DDProperties properties)
|
||||
{
|
||||
super(world, seed, false);
|
||||
public LimboGenerator(World world, long seed, CustomLimboPopulator spawner, DDProperties properties) {
|
||||
super(world, seed, false, "limbo");
|
||||
|
||||
LimboGenerator.rand = new Random(seed);
|
||||
this.noiseGen1 = new NoiseGeneratorOctaves(LimboGenerator.rand, 16); //base terrain
|
||||
|
@ -108,79 +108,67 @@ public class LimboGenerator extends ChunkProviderGenerate
|
|||
this.noiseGen5 = noiseGens[4];
|
||||
this.noiseGen6 = noiseGens[5];
|
||||
this.mobSpawnerNoise = noiseGens[6];
|
||||
|
||||
this.worldObj = world;
|
||||
|
||||
this.worldObj = world;
|
||||
|
||||
this.spawner = spawner;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chunkExists(int var1, int var2)
|
||||
{
|
||||
return super.chunkExists(var1, var2);
|
||||
public boolean chunkExists(int x, int z) {
|
||||
return super.chunkExists(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceBlocksForBiome(int par1, int par2, Block[] blocks, byte[] par3ArrayOfByte, BiomeGenBase[] par4ArrayOfBiomeGenBase)
|
||||
{
|
||||
|
||||
public void replaceBlocksForBiome(int x, int z, ChunkPrimer blocks, BiomeGenBase[] par4ArrayOfBiomeGenBase) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk provideChunk(int chunkX, int chunkZ)
|
||||
{
|
||||
public Chunk provideChunk(int chunkX, int chunkZ) {
|
||||
//TODO: Wtf? Why do you reinitialize the seed when we already initialized it in the constructor?! ~SenseiKiwi
|
||||
LimboGenerator.rand.setSeed(chunkX * 341873128712L + chunkZ * 132897987541L);
|
||||
Block[] var3 = new Block[32768];
|
||||
this.func_147424_a(chunkX, chunkZ, var3);
|
||||
Chunk var4 = new Chunk(this.worldObj, var3, chunkX, chunkZ);
|
||||
var4.generateSkylightMap();
|
||||
ChunkPrimer primer = new ChunkPrimer();
|
||||
this.setBlocksInChunk(chunkX, chunkZ, primer);
|
||||
Chunk chunk = new Chunk(this.worldObj, primer, chunkX, chunkZ);
|
||||
chunk.generateSkylightMap();
|
||||
|
||||
if (!var4.isTerrainPopulated)
|
||||
{
|
||||
var4.isTerrainPopulated=true;
|
||||
if (!chunk.isTerrainPopulated()) {
|
||||
chunk.setTerrainPopulated(true);
|
||||
spawner.registerChunkForPopulation(properties.LimboDimensionID, chunkX, chunkZ);
|
||||
}
|
||||
return var4;
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk loadChunk(int var1, int var2) {
|
||||
public Chunk provideChunk(BlockPos pos) {
|
||||
// TODO Auto-generated method stub
|
||||
return super.provideChunk(var1, var2);
|
||||
return super.provideChunk(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(IChunkProvider var1, int var2, int var3)
|
||||
{
|
||||
public void populate(IChunkProvider var1, int var2, int var3) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveChunks(boolean var1, IProgressUpdate var2) {
|
||||
// TODO Auto-generated method stub
|
||||
return super.saveChunks(var1, var2);
|
||||
}
|
||||
private double[] initializeNoiseField(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, int par6, int par7)
|
||||
{
|
||||
private double[] initializeNoiseField(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, int par6, int par7) {
|
||||
ChunkProviderEvent.InitNoiseField event = new ChunkProviderEvent.InitNoiseField(this, par1ArrayOfDouble, par2, par3, par4, par5, par6, par7);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
if (event.getResult() == Event.Result.DENY) return event.noisefield;
|
||||
|
||||
if (par1ArrayOfDouble == null)
|
||||
{
|
||||
if (par1ArrayOfDouble == null) {
|
||||
par1ArrayOfDouble = new double[par5 * par6 * par7];
|
||||
}
|
||||
|
||||
if (this.parabolicField == null)
|
||||
{
|
||||
if (this.parabolicField == null) {
|
||||
this.parabolicField = new float[25];
|
||||
|
||||
for (int var8 = -2; var8 <= 2; ++var8)
|
||||
{
|
||||
for (int var9 = -2; var9 <= 2; ++var9)
|
||||
{
|
||||
for (int var8 = -2; var8 <= 2; ++var8) {
|
||||
for (int var9 = -2; var9 <= 2; ++var9) {
|
||||
float var10 = 10.0F / MathHelper.sqrt_float(var8 * var8 + var9 * var9 + 0.2F);
|
||||
this.parabolicField[var8 + 2 + (var9 + 2) * 5] = var10;
|
||||
}
|
||||
|
@ -198,26 +186,22 @@ public class LimboGenerator extends ChunkProviderGenerate
|
|||
int var12 = 0;
|
||||
int var13 = 0;
|
||||
|
||||
for (int var14 = 0; var14 < par5; ++var14)
|
||||
{
|
||||
for (int var15 = 0; var15 < par7; ++var15)
|
||||
{
|
||||
for (int var14 = 0; var14 < par5; ++var14) {
|
||||
for (int var15 = 0; var15 < par7; ++var15) {
|
||||
float var16 = 0.0F;
|
||||
float var17 = 0.0F;
|
||||
float var18 = 0.0F;
|
||||
byte var19 = 2;
|
||||
|
||||
for (int var21 = -var19; var21 <= var19; ++var21)
|
||||
{
|
||||
for (int var22 = -var19; var22 <= var19; ++var22)
|
||||
{
|
||||
float var24 = this.parabolicField[var21 + 2 + (var22 + 2) * 5] / (BiomeGenBase.plains.rootHeight + 9.0F);
|
||||
for (int var21 = -var19; var21 <= var19; ++var21) {
|
||||
for (int var22 = -var19; var22 <= var19; ++var22) {
|
||||
float var24 = this.parabolicField[var21 + 2 + (var22 + 2) * 5] / (BiomeGenBase.plains.minHeight + 9.0F);
|
||||
|
||||
|
||||
//this adjusts the height of the terrain
|
||||
|
||||
var16 += BiomeGenBase.plains.heightVariation * var24+4;
|
||||
var17 += BiomeGenBase.plains.rootHeight * var24-1;
|
||||
var16 += BiomeGenBase.plains.maxHeight * var24+4;
|
||||
var17 += BiomeGenBase.plains.minHeight * var24-1;
|
||||
var18 += var24;
|
||||
}
|
||||
}
|
||||
|
@ -228,29 +212,23 @@ public class LimboGenerator extends ChunkProviderGenerate
|
|||
var17 = (var17 * 4.0F - 1.0F) / 8.0F;
|
||||
double var47 = this.noise6[var13] / 8000.0D;
|
||||
|
||||
if (var47 < 0.0D)
|
||||
{
|
||||
if (var47 < 0.0D) {
|
||||
var47 = -var47 * 0.3D;
|
||||
}
|
||||
|
||||
var47 = var47 * 3.0D - 2.0D;
|
||||
|
||||
if (var47 < 0.0D)
|
||||
{
|
||||
if (var47 < 0.0D) {
|
||||
var47 /= 2.0D;
|
||||
|
||||
if (var47 < -1.0D)
|
||||
{
|
||||
if (var47 < -1.0D) {
|
||||
var47 = -1.0D;
|
||||
}
|
||||
|
||||
var47 /= 1.4D;
|
||||
var47 /= 2.0D;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (var47 > 1.0D)
|
||||
{
|
||||
} else {
|
||||
if (var47 > 1.0D) {
|
||||
var47 = 1.0D;
|
||||
}
|
||||
|
||||
|
@ -259,8 +237,7 @@ public class LimboGenerator extends ChunkProviderGenerate
|
|||
|
||||
++var13;
|
||||
|
||||
for (int var46 = 0; var46 < par6; ++var46)
|
||||
{
|
||||
for (int var46 = 0; var46 < par6; ++var46) {
|
||||
double var48 = var17;
|
||||
double var26 = var16;
|
||||
var48 += var47 * 0.2D;
|
||||
|
@ -269,8 +246,7 @@ public class LimboGenerator extends ChunkProviderGenerate
|
|||
double var30 = 0.0D;
|
||||
double var32 = (var46 - var28) * 12.0D * 128.0D / 128.0D / var26;
|
||||
|
||||
if (var32 < 0.0D)
|
||||
{
|
||||
if (var32 < 0.0D) {
|
||||
var32 *= 4.0D;
|
||||
}
|
||||
|
||||
|
@ -278,23 +254,17 @@ public class LimboGenerator extends ChunkProviderGenerate
|
|||
double var36 = this.noise2[var12] / 512.0D;
|
||||
double var38 = (this.noise3[var12] / 10.0D + 1.0D) / 2.0D;
|
||||
|
||||
if (var38 < 0.0D)
|
||||
{
|
||||
if (var38 < 0.0D) {
|
||||
var30 = var34;
|
||||
}
|
||||
else if (var38 > 1.0D)
|
||||
{
|
||||
} else if (var38 > 1.0D) {
|
||||
var30 = var36;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
var30 = var34 + (var36 - var34) * var38;
|
||||
}
|
||||
|
||||
var30 -= var32;
|
||||
|
||||
if (var46 > par6 - 4)
|
||||
{
|
||||
if (var46 > par6 - 4) {
|
||||
double var40 = (var46 - (par6 - 4)) / 3.0F;
|
||||
var30 = var30 * (1.0D - var40) + -10.0D * var40;
|
||||
}
|
||||
|
@ -308,23 +278,19 @@ public class LimboGenerator extends ChunkProviderGenerate
|
|||
return par1ArrayOfDouble;
|
||||
}
|
||||
@Override
|
||||
public void func_147424_a(int par1, int par2, Block[] blocks)
|
||||
{
|
||||
public void setBlocksInChunk(int x, int z, ChunkPrimer primer) {
|
||||
byte var4 = 4;
|
||||
byte var5 = 16;
|
||||
byte var6 = 19;
|
||||
int var7 = var4 + 1;
|
||||
byte var8 = 17;
|
||||
int var9 = var4 + 1;
|
||||
this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, par1 * 4 - 2, par2 * 4 - 2, var7 + 5, var9 + 5);
|
||||
this.noiseArray = this.initializeNoiseField(this.noiseArray, par1 * var4, 0, par2 * var4, var7, var8, var9);
|
||||
this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, var7 + 5, var9 + 5);
|
||||
this.noiseArray = this.initializeNoiseField(this.noiseArray, x * var4, 0, z * var4, var7, var8, var9);
|
||||
|
||||
for (int var10 = 0; var10 < var4; ++var10)
|
||||
{
|
||||
for (int var11 = 0; var11 < var4; ++var11)
|
||||
{
|
||||
for (int var12 = 0; var12 < var5; ++var12)
|
||||
{
|
||||
for (int var10 = 0; var10 < var4; ++var10) {
|
||||
for (int var11 = 0; var11 < var4; ++var11) {
|
||||
for (int var12 = 0; var12 < var5; ++var12) {
|
||||
double var13 = 0.125D;
|
||||
double var15 = this.noiseArray[((var10 + 0) * var9 + var11 + 0) * var8 + var12 + 0];
|
||||
double var17 = this.noiseArray[((var10 + 0) * var9 + var11 + 1) * var8 + var12 + 0];
|
||||
|
@ -335,16 +301,14 @@ public class LimboGenerator extends ChunkProviderGenerate
|
|||
double var27 = (this.noiseArray[((var10 + 1) * var9 + var11 + 0) * var8 + var12 + 1] - var19) * var13;
|
||||
double var29 = (this.noiseArray[((var10 + 1) * var9 + var11 + 1) * var8 + var12 + 1] - var21) * var13;
|
||||
|
||||
for (int var31 = 0; var31 < 8; ++var31)
|
||||
{
|
||||
for (int var31 = 0; var31 < 8; ++var31) {
|
||||
double var32 = 0.25D;
|
||||
double var34 = var15;
|
||||
double var36 = var17;
|
||||
double var38 = (var19 - var15) * var32;
|
||||
double var40 = (var21 - var17) * var32;
|
||||
|
||||
for (int var42 = 0; var42 < 4; ++var42)
|
||||
{
|
||||
for (int var42 = 0; var42 < 4; ++var42) {
|
||||
int var43 = var42 + var10 * 4 << 11 | 0 + var11 * 4 << 7 | var12 * 8 + var31;
|
||||
short var44 = 128;
|
||||
var43 -= var44;
|
||||
|
@ -352,20 +316,13 @@ public class LimboGenerator extends ChunkProviderGenerate
|
|||
double var49 = (var36 - var34) * var45;
|
||||
double var47 = var34 - var49;
|
||||
|
||||
for (int var51 = 0; var51 < 4; ++var51)
|
||||
{
|
||||
if ((var47 += var49) > 0.0D)
|
||||
{
|
||||
blocks[var43 += var44] = DimDoors.blockLimbo;
|
||||
}
|
||||
else if (var12 * 8 + var31 < var6)
|
||||
{
|
||||
blocks[var43 += var44] = DimDoors.blockDimWallPerm;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
blocks[var43 += var44] = Blocks.air;
|
||||
for (int var51 = 0; var51 < 4; ++var51) {
|
||||
if ((var47 += var49) > 0.0D) {
|
||||
primer.setBlockState(var43 += var44, DimDoors.blockLimbo.getDefaultState());
|
||||
} else if (var12 * 8 + var31 < var6) {
|
||||
primer.setBlockState(var43 += var44, DimDoors.blockDimWallPerm.getDefaultState());
|
||||
} else {
|
||||
primer.setBlockState(var43 += var44, Blocks.air.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,28 +343,22 @@ public class LimboGenerator extends ChunkProviderGenerate
|
|||
|
||||
@Override
|
||||
public boolean canSave() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.canSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String makeString() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.makeString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4)
|
||||
{
|
||||
|
||||
BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(par2, par4);
|
||||
return biomegenbase == null ? null : (biomegenbase == BiomeGenBase.swampland && par1EnumCreatureType == EnumCreatureType.monster && this.scatteredFeatureGenerator.hasStructureAt(par2, par3, par4) ? this.scatteredFeatureGenerator.getScatteredFeatureSpawnList() : biomegenbase.getSpawnableList(par1EnumCreatureType));
|
||||
public List getPossibleCreatures(EnumCreatureType enumCreatureType, BlockPos pos) {
|
||||
BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(pos);
|
||||
return biomegenbase == null ? null : (biomegenbase == BiomeGenBase.swampland && enumCreatureType == EnumCreatureType.MONSTER && this.scatteredFeatureGenerator.func_175796_a(world, pos) ? this.scatteredFeatureGenerator.getScatteredFeatureSpawnList() : biomegenbase.getSpawnableList(enumCreatureType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkPosition func_147416_a(World var1, String var2,
|
||||
int var3, int var4, int var5) {
|
||||
// TODO Auto-generated method stub
|
||||
public BlockPos getStrongholdGen(World world, String name, BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -418,9 +369,7 @@ public class LimboGenerator extends ChunkProviderGenerate
|
|||
}
|
||||
|
||||
@Override
|
||||
public void recreateStructures(int var1, int var2) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public void recreateStructures(Chunk chunk, int x, int z) {
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
|
@ -17,8 +17,8 @@ import com.zixiken.dimdoors.CloudRenderBlank;
|
|||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.ticking.CustomLimboPopulator;
|
||||
import com.zixiken.dimdoors.util.Point4D;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class LimboProvider extends WorldProvider
|
||||
{
|
||||
|
@ -31,8 +31,7 @@ public class LimboProvider extends WorldProvider
|
|||
private DDProperties properties;
|
||||
private CustomLimboPopulator spawner;
|
||||
|
||||
public LimboProvider()
|
||||
{
|
||||
public LimboProvider() {
|
||||
this.hasNoSky = false;
|
||||
this.skyRenderer = new LimboSkyProvider();
|
||||
this.spawner = DimDoors.spawner;
|
||||
|
@ -41,49 +40,42 @@ public class LimboProvider extends WorldProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IRenderHandler getSkyRenderer()
|
||||
{
|
||||
public IRenderHandler getSkyRenderer() {
|
||||
return this.skyRenderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerWorldChunkManager()
|
||||
{
|
||||
protected void registerWorldChunkManager() {
|
||||
super.worldChunkMgr = new WorldChunkManagerHell(DimDoors.limboBiome,1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiomeGenForCoords(int x, int z)
|
||||
{
|
||||
public BiomeGenBase getBiomeGenForCoords(BlockPos pos) {
|
||||
return DimDoors.limboBiome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRespawnHere()
|
||||
{
|
||||
public boolean canRespawnHere() {
|
||||
return properties.HardcoreLimboEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockHighHumidity(int x, int y, int z)
|
||||
{
|
||||
public boolean isBlockHighHumidity(BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canSnowAt(int x, int y, int z, boolean checkLight)
|
||||
public boolean canSnowAt(BlockPos pos, boolean checkLight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generateLightBrightnessTable()
|
||||
{
|
||||
protected void generateLightBrightnessTable() {
|
||||
float modifier = 0.0F;
|
||||
|
||||
for (int steps = 0; steps <= 15; ++steps)
|
||||
{
|
||||
for (int steps = 0; steps <= 15; ++steps) {
|
||||
float var3 = 1.0F - steps / 15.0F;
|
||||
this.lightBrightnessTable[steps] = ((0.0F + var3) / (var3 * 3.0F + 1.0F) * (1.0F - modifier) + modifier)*3;
|
||||
// System.out.println( this.lightBrightnessTable[steps]+"light");
|
||||
|
@ -91,25 +83,20 @@ public class LimboProvider extends WorldProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public ChunkCoordinates getSpawnPoint()
|
||||
{
|
||||
|
||||
public BlockPos getSpawnPoint() {
|
||||
return this.getRandomizedSpawnPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float calculateCelestialAngle(long par1, float par3)
|
||||
{
|
||||
public float calculateCelestialAngle(long par1, float par3) {
|
||||
int var4 = (int)(par1 % 24000L);
|
||||
float var5 = (var4 + par3) / 24000.0F - 0.25F;
|
||||
|
||||
if (var5 < 0.0F)
|
||||
{
|
||||
if (var5 < 0.0F) {
|
||||
++var5;
|
||||
}
|
||||
|
||||
if (var5 > 1.0F)
|
||||
{
|
||||
if (var5 > 1.0F) {
|
||||
--var5;
|
||||
}
|
||||
|
||||
|
@ -120,74 +107,70 @@ public class LimboProvider extends WorldProvider
|
|||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getMoonPhase(long par1, float par3)
|
||||
{
|
||||
public int getMoonPhase(long par1) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public String getSaveFolder()
|
||||
{
|
||||
public String getSaveFolder() {
|
||||
return (dimensionId == 0 ? null : "DimensionalDoors/Limbo" + dimensionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCoordinateBeSpawn(int par1, int par2)
|
||||
{
|
||||
Block block = this.worldObj.getTopBlock(par1, par2);
|
||||
public boolean canCoordinateBeSpawn(int par1, int par2) {
|
||||
Block block = this.worldObj.getBlockState(this.worldObj.getTopSolidOrLiquidBlock(new BlockPos(par1, 0, par2))).getBlock();
|
||||
return block == DimDoors.blockLimbo;
|
||||
}
|
||||
@Override
|
||||
public double getHorizon()
|
||||
{
|
||||
public double getHorizon() {
|
||||
return worldObj.getHeight()/4-800;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getSkyColor(Entity cameraEntity, float partialTicks)
|
||||
{
|
||||
public Vec3 getSkyColor(Entity cameraEntity, float partialTicks) {
|
||||
setCloudRenderer( new CloudRenderBlank());
|
||||
return Vec3.createVectorHelper(0, 0, 0);
|
||||
return new Vec3(0, 0, 0);
|
||||
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Vec3 getFogColor(float par1, float par2)
|
||||
{
|
||||
return Vec3.createVectorHelper(.2, .2, .2);
|
||||
public Vec3 getFogColor(float par1, float par2) {
|
||||
return new Vec3(.2, .2, .2);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRespawnDimension(EntityPlayerMP player)
|
||||
{
|
||||
public int getRespawnDimension(EntityPlayerMP player) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkProvider createChunkGenerator()
|
||||
{
|
||||
//TODO: ...We're passing the LimboGenerator a fixed seed. We should be passing the world seed! @_@ ~SenseiKiwi
|
||||
public IChunkProvider createChunkGenerator() {
|
||||
return new LimboGenerator(worldObj, 45, spawner, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBlockFreeze(int x, int y, int z, boolean byWater)
|
||||
{
|
||||
public boolean canBlockFreeze(BlockPos pos, boolean byWater) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Point4D getLimboSkySpawn(EntityPlayer player, DDProperties properties)
|
||||
{
|
||||
public static Point4D getLimboSkySpawn(EntityPlayer player, DDProperties properties) {
|
||||
int x = (int) (player.posX) + MathHelper.getRandomIntegerInRange(player.worldObj.rand, -properties.LimboEntryRange, properties.LimboEntryRange);
|
||||
int z = (int) (player.posZ) + MathHelper.getRandomIntegerInRange(player.worldObj.rand, -properties.LimboEntryRange, properties.LimboEntryRange);
|
||||
return new Point4D(x, 700, z, properties.LimboDimensionID);
|
||||
return new Point4D(new BlockPos(x, 700, z), properties.LimboDimensionID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkCoordinates getRandomizedSpawnPoint()
|
||||
{
|
||||
public BlockPos getRandomizedSpawnPoint() {
|
||||
int x = MathHelper.getRandomIntegerInRange(this.worldObj.rand, -500, 500);
|
||||
int z = MathHelper.getRandomIntegerInRange(this.worldObj.rand, -500, 500);
|
||||
return new ChunkCoordinates(x, 700, z);
|
||||
return new BlockPos(x, 700, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInternalNameSuffix() {
|
||||
return "_limbo";
|
||||
}
|
||||
|
||||
}
|
|
@ -6,60 +6,51 @@ import net.minecraftforge.client.IRenderHandler;
|
|||
import com.zixiken.dimdoors.CloudRenderBlank;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.ticking.CustomLimboPopulator;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PersonalPocketProvider extends PocketProvider
|
||||
{
|
||||
public class PersonalPocketProvider extends PocketProvider {
|
||||
private DDProperties properties;
|
||||
private CustomLimboPopulator spawner;
|
||||
private IRenderHandler skyRenderer;
|
||||
|
||||
public PersonalPocketProvider()
|
||||
{
|
||||
public PersonalPocketProvider() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getSkyColor(Entity cameraEntity, float partialTicks)
|
||||
{
|
||||
public Vec3 getSkyColor(Entity cameraEntity, float partialTicks) {
|
||||
setCloudRenderer( new CloudRenderBlank());
|
||||
return Vec3.createVectorHelper(1,1,1);
|
||||
return new Vec3(1,1,1);
|
||||
}
|
||||
|
||||
public boolean isSurfaceWorld()
|
||||
{
|
||||
public boolean isSurfaceWorld() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generateLightBrightnessTable()
|
||||
{
|
||||
protected void generateLightBrightnessTable() {
|
||||
float f = 0.0F;
|
||||
|
||||
for (int i = 0; i <= 15; ++i)
|
||||
{
|
||||
for (int i = 0; i <= 15; ++i) {
|
||||
float f1 = 1.0F - (float)i / 15.0F;
|
||||
this.lightBrightnessTable[i] = (15);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHorizon()
|
||||
{
|
||||
public double getHorizon() {
|
||||
return worldObj.getHeight()-256;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Vec3 getFogColor(float par1, float par2)
|
||||
{
|
||||
return Vec3.createVectorHelper(1,1,1);
|
||||
public Vec3 getFogColor(float par1, float par2) {
|
||||
return new Vec3(1,1,1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActualHeight()
|
||||
{
|
||||
public int getActualHeight() {
|
||||
return -256;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,14 @@ package com.zixiken.dimdoors.world;
|
|||
import java.util.Random;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.blocks.BlockDimWall;
|
||||
import com.zixiken.dimdoors.core.*;
|
||||
import com.zixiken.dimdoors.helpers.BlockPosHelper;
|
||||
import com.zixiken.dimdoors.helpers.EnumFacingHelper;
|
||||
import com.zixiken.dimdoors.items.ItemBlockDimWall;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockTNT;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
@ -55,7 +60,7 @@ public class PocketBuilder
|
|||
destination = new BlockPos(source.getX(), source.getY(), source.getZ());
|
||||
}
|
||||
|
||||
destination.setY( yCoordHelper.adjustDestinationY(destination.getY(), world.getHeight(), schematic.getEntranceDoorLocation().getY(), schematic.getHeight()) );
|
||||
destination = new BlockPos(destination.getZ(), yCoordHelper.adjustDestinationY(destination.getY(), world.getHeight(), schematic.getEntranceDoorLocation().getY(), schematic.getVolume().getY()), destination.getZ());
|
||||
|
||||
//Generate the dungeon
|
||||
schematic.copyToWorld(world, destination, orientation, link, random, properties, false);
|
||||
|
@ -217,59 +222,49 @@ public class PocketBuilder
|
|||
return generateNewPocket(link, DEFAULT_POCKET_SIZE, DEFAULT_POCKET_WALL_THICKNESS, properties, door, type);
|
||||
}
|
||||
|
||||
private static int getDoorOrientation(Point4D source, DDProperties properties) {
|
||||
private static EnumFacing getDoorOrientation(Point4D source, DDProperties properties) {
|
||||
World world = DimensionManager.getWorld(source.getDimension());
|
||||
|
||||
if (world == null) throw new IllegalStateException("The link's source world should be loaded!");
|
||||
|
||||
|
||||
//Check if the block below that point is actually a door
|
||||
Block block = world.getBlock(source.getX().getX(), source.getY() - 1, source.getZ());
|
||||
if (block==null || !(block instanceof IDimDoor))
|
||||
{
|
||||
Block block = world.getBlockState(source.toBlockPos().down()).getBlock();
|
||||
if (block==null || !(block instanceof IDimDoor)) {
|
||||
throw new IllegalStateException("The link's source is not a door block. It should be impossible to traverse a rift without a door!");
|
||||
}
|
||||
|
||||
//Return the orientation portion of its metadata
|
||||
int orientation = world.getBlockMetadata(source.getX(), source.getY() - 1, source.getZ()) & 3;
|
||||
EnumFacing orientation = EnumFacingHelper.getFacingFromBlockState(world.getBlockState(source.toBlockPos().down()));
|
||||
|
||||
return orientation;
|
||||
}
|
||||
|
||||
public static void validatePocketSetup(DimLink link, int size, int wallThickness, DDProperties properties, Block door)
|
||||
{
|
||||
if (link == null)
|
||||
{
|
||||
public static void validatePocketSetup(DimLink link, int size, int wallThickness, DDProperties properties, Block door) {
|
||||
if (link == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (properties == null)
|
||||
{
|
||||
if (properties == null) {
|
||||
throw new IllegalArgumentException("properties cannot be null.");
|
||||
}
|
||||
if (link.linkType() != LinkType.PERSONAL && link.hasDestination())
|
||||
{
|
||||
if (link.linkType() != LinkType.PERSONAL && link.hasDestination()) {
|
||||
throw new IllegalArgumentException("link cannot have a destination assigned already.");
|
||||
}
|
||||
|
||||
if(door==null)
|
||||
{
|
||||
if(door==null) {
|
||||
throw new IllegalArgumentException("Must have a doorItem to gen one!!");
|
||||
|
||||
}
|
||||
|
||||
if (size < MIN_POCKET_SIZE || size > MAX_POCKET_SIZE)
|
||||
{
|
||||
if (size < MIN_POCKET_SIZE || size > MAX_POCKET_SIZE) {
|
||||
throw new IllegalArgumentException("size must be between " + MIN_POCKET_SIZE + " and " + MAX_POCKET_SIZE + ", inclusive.");
|
||||
}
|
||||
if (wallThickness < MIN_POCKET_WALL_THICKNESS || wallThickness > MAX_POCKET_WALL_THICKNESS)
|
||||
{
|
||||
if (wallThickness < MIN_POCKET_WALL_THICKNESS || wallThickness > MAX_POCKET_WALL_THICKNESS) {
|
||||
throw new IllegalArgumentException("wallThickness must be between " + MIN_POCKET_WALL_THICKNESS + " and " + MAX_POCKET_WALL_THICKNESS + ", inclusive.");
|
||||
}
|
||||
if (size % 2 == 0)
|
||||
{
|
||||
if (size % 2 == 0) {
|
||||
throw new IllegalArgumentException("size must be an odd number.");
|
||||
}
|
||||
if (size < 2 * wallThickness + 3)
|
||||
{
|
||||
if (size < 2 * wallThickness + 3) {
|
||||
throw new IllegalArgumentException("size must be large enough to fit the specified wall thickness and some air space.");
|
||||
}
|
||||
}
|
||||
|
@ -282,11 +277,9 @@ public class PocketBuilder
|
|||
* @param door
|
||||
* @return
|
||||
*/
|
||||
public static boolean generateNewPersonalPocket(DimLink link, DDProperties properties,EntityPlayer player, Block door)
|
||||
{
|
||||
public static boolean generateNewPersonalPocket(DimLink link, DDProperties properties,EntityPlayer player, Block door) {
|
||||
//incase a chicken walks in or something
|
||||
if(!(player instanceof EntityPlayer))
|
||||
{
|
||||
if(!(player instanceof EntityPlayer)) {
|
||||
return false;
|
||||
}
|
||||
int wallThickness = DEFAULT_POCKET_WALL_THICKNESS;
|
||||
|
@ -294,8 +287,7 @@ public class PocketBuilder
|
|||
|
||||
validatePocketSetup(link, size, wallThickness, properties, door);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
//Register a new dimension
|
||||
DimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
DimData dimension = PocketManager.registerPocket(parent, DimensionType.PERSONAL, player.getGameProfile().getId().toString());
|
||||
|
@ -304,8 +296,7 @@ public class PocketBuilder
|
|||
//Load a world
|
||||
World world = PocketManager.loadDimension(dimension.id());
|
||||
|
||||
if (world == null || world.provider == null)
|
||||
{
|
||||
if (world == null || world.provider == null) {
|
||||
System.err.println("Could not initialize dimension for a pocket!");
|
||||
return false;
|
||||
}
|
||||
|
@ -313,34 +304,30 @@ public class PocketBuilder
|
|||
//Calculate the destination point
|
||||
Point4D source = link.source();
|
||||
int destinationY = yCoordHelper.adjustDestinationY(link.source().getY(), world.getHeight(), wallThickness + 1, size);
|
||||
int orientation = getDoorOrientation(source, properties);
|
||||
EnumFacing orientation = getDoorOrientation(source, properties);
|
||||
|
||||
//Place a link leading back out of the pocket
|
||||
DimLink reverseLink = dimension.createLink(source.getX(), destinationY, source.getZ(), LinkType.REVERSE,(link.orientation()+2)%4);
|
||||
parent.setLinkDestination(reverseLink, source.getX(), source.getY(), source.getZ());
|
||||
DimLink reverseLink = dimension.createLink(new BlockPos(source.getX(), destinationY, source.getZ()), LinkType.REVERSE,(link.orientation().getOpposite()));
|
||||
parent.setLinkDestination(reverseLink, source.toBlockPos());
|
||||
|
||||
//Build the actual pocket area
|
||||
buildPocket(world, source.getX(), destinationY, source.getZ(), orientation, size, wallThickness, properties, door);
|
||||
buildPocket(world, source.toBlockPos(), orientation, size, wallThickness, properties, door.getDefaultState());
|
||||
|
||||
//Finish up destination initialization
|
||||
dimension.initializePocket(source.getX(), destinationY, source.getZ(), orientation, link);
|
||||
dimension.initializePocket(new BlockPos(source.getX(), destinationY, source.getZ()), orientation, link);
|
||||
dimension.setFilled(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean generateNewPocket(DimLink link, int size, int wallThickness, DDProperties properties, Block door, DimensionType type)
|
||||
{
|
||||
public static boolean generateNewPocket(DimLink link, int size, int wallThickness, DDProperties properties, Block door, DimensionType type) {
|
||||
validatePocketSetup(link, size, wallThickness, properties, door);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
//Register a new dimension
|
||||
DimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
DimData dimension = PocketManager.registerPocket(parent, type);
|
||||
|
@ -349,8 +336,7 @@ public class PocketBuilder
|
|||
//Load a world
|
||||
World world = PocketManager.loadDimension(dimension.id());
|
||||
|
||||
if (world == null || world.provider == null)
|
||||
{
|
||||
if (world == null || world.provider == null) {
|
||||
System.err.println("Could not initialize dimension for a pocket!");
|
||||
return false;
|
||||
}
|
||||
|
@ -358,157 +344,114 @@ public class PocketBuilder
|
|||
//Calculate the destination point
|
||||
Point4D source = link.source();
|
||||
int destinationY = yCoordHelper.adjustDestinationY(source.getY(), world.getHeight(), wallThickness + 1, size);
|
||||
int orientation = getDoorOrientation(source, properties);
|
||||
EnumFacing orientation = getDoorOrientation(source, properties);
|
||||
|
||||
//Place a link leading back out of the pocket
|
||||
|
||||
DimLink reverseLink = dimension.createLink(source.getX(), destinationY, source.getZ(), LinkType.REVERSE,(link.orientation()+2)%4);
|
||||
parent.setLinkDestination(reverseLink, source.getX(), source.getY(), source.getZ());
|
||||
DimLink reverseLink = dimension.createLink(new BlockPos(source.getX(), destinationY, source.getZ()), LinkType.REVERSE,(link.orientation().getOpposite()));
|
||||
parent.setLinkDestination(reverseLink, source.toBlockPos());
|
||||
|
||||
//Build the actual pocket area
|
||||
buildPocket(world, source.getX(), destinationY, source.getZ(), orientation, size, wallThickness, properties, door);
|
||||
buildPocket(world, source.toBlockPos(), orientation, size, wallThickness, properties, door.getDefaultState());
|
||||
|
||||
//Finish up destination initialization
|
||||
dimension.initializePocket(source.getX(), destinationY, source.getZ(), orientation, link);
|
||||
dimension.initializePocket(new BlockPos(source.getX(), destinationY, source.getZ()), orientation, link);
|
||||
dimension.setFilled(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildPocket(World world, int x, int y, int z, int orientation, int size, int wallThickness, DDProperties properties, Block doorBlock)
|
||||
{
|
||||
if (properties == null)
|
||||
{
|
||||
private static void buildPocket(World world, BlockPos pos, EnumFacing orientation, int size, int wallThickness, DDProperties properties, IBlockState doorBlock) {
|
||||
if (properties == null) {
|
||||
throw new IllegalArgumentException("properties cannot be null.");
|
||||
}
|
||||
if (size < MIN_POCKET_SIZE || size > MAX_POCKET_SIZE)
|
||||
{
|
||||
if (size < MIN_POCKET_SIZE || size > MAX_POCKET_SIZE) {
|
||||
throw new IllegalArgumentException("size must be between " + MIN_POCKET_SIZE + " and " + MAX_POCKET_SIZE + ", inclusive.");
|
||||
}
|
||||
if (wallThickness < MIN_POCKET_WALL_THICKNESS || wallThickness > MAX_POCKET_WALL_THICKNESS)
|
||||
{
|
||||
if (wallThickness < MIN_POCKET_WALL_THICKNESS || wallThickness > MAX_POCKET_WALL_THICKNESS) {
|
||||
throw new IllegalArgumentException("wallThickness must be between " + MIN_POCKET_WALL_THICKNESS + " and " + MAX_POCKET_WALL_THICKNESS + ", inclusive.");
|
||||
}
|
||||
if (size % 2 == 0)
|
||||
{
|
||||
if (size % 2 == 0) {
|
||||
throw new IllegalArgumentException("size must be an odd number.");
|
||||
}
|
||||
if (size < 2 * wallThickness + 3)
|
||||
{
|
||||
if (size < 2 * wallThickness + 3) {
|
||||
throw new IllegalArgumentException("size must be large enough to fit the specified wall thickness and some air space.");
|
||||
}
|
||||
if (!(doorBlock instanceof IDimDoor))
|
||||
{
|
||||
if (!(doorBlock instanceof IDimDoor)) {
|
||||
throw new IllegalArgumentException("Door must implement IDimDoor");
|
||||
}
|
||||
|
||||
|
||||
BlockPos center = new BlockPos(x - wallThickness + 1 + (size / 2), y - wallThickness - 1 + (size / 2), z);
|
||||
BlockPos door = new BlockPos(x, y, z);
|
||||
BlockRotator.transformPoint(center, door, orientation - BlockRotator.EAST_DOOR_METADATA, door);
|
||||
BlockPos center = pos.add(-wallThickness + 1 + (size / 2), -wallThickness - 1 + (size / 2), 0);
|
||||
BlockPos door = pos;
|
||||
BlockRotator.transformPoint(center, door, orientation, door);
|
||||
|
||||
//Build the outer layer of Eternal Fabric
|
||||
buildBox(world, center.getX(), center.getY(), center.getZ(), (size / 2), DimDoors.blockDimWallPerm, 0, false, 0);
|
||||
buildBox(world, center, (size / 2), DimDoors.blockDimWallPerm.getDefaultState(), false, 0);
|
||||
|
||||
//check if we are building a personal pocket
|
||||
int metadata = 0;
|
||||
if(world.provider instanceof PersonalPocketProvider)
|
||||
{
|
||||
if(world.provider instanceof PersonalPocketProvider) {
|
||||
metadata = 2;
|
||||
}
|
||||
|
||||
//Build the (wallThickness - 1) layers of Fabric of Reality
|
||||
for (int layer = 1; layer < wallThickness; layer++)
|
||||
{
|
||||
buildBox(world, center.getX(), center.getY(), center.getZ(), (size / 2) - layer, DimDoors.blockDimWall, metadata,
|
||||
layer < (wallThickness - 1) && properties.TNFREAKINGT_Enabled, properties.NonTntWeight);
|
||||
buildBox(world, center, (size / 2) - layer, DimDoors.blockDimWall.getDefaultState().withProperty(BlockDimWall.TYPE, 2),
|
||||
layer < (wallThickness - 1) && properties.TNFREAKINGT_Enabled, properties.NonTntWeight);
|
||||
}
|
||||
|
||||
//MazeBuilder.generate(world, x, y, z, random);
|
||||
|
||||
//Build the door
|
||||
int doorOrientation = BlockRotator.transformMetadata(BlockRotator.EAST_DOOR_METADATA, orientation - BlockRotator.EAST_DOOR_METADATA + 2, doorBlock);
|
||||
ItemDimensionalDoor.placeDoorBlock(world, x, y - 1, z, doorOrientation, doorBlock);
|
||||
EnumFacing doorOrientation = EnumFacingHelper.getFacingFromBlockState(BlockRotator.transform(doorBlock,2));
|
||||
ItemDimensionalDoor.placeDoor(world, pos.down(), doorOrientation, doorBlock.getBlock());
|
||||
|
||||
}
|
||||
|
||||
private static void buildBox(World world, int centerX, int centerY, int centerZ, int radius, Block block, int metadata, boolean placeTnt, int nonTntWeight)
|
||||
{
|
||||
private static void buildBox(World world, BlockPos center, int radius, IBlockState state, boolean placeTnt, int nonTntWeight) {
|
||||
int x, y, z;
|
||||
|
||||
final int startX = centerX - radius;
|
||||
final int startY = centerY - radius;
|
||||
final int startZ = centerZ - radius;
|
||||
final int startX = center.getX() - radius;
|
||||
final int startY = center.getY() - radius;
|
||||
final int startZ = center.getZ() - radius;
|
||||
|
||||
final int endX = centerX + radius;
|
||||
final int endY = centerY + radius;
|
||||
final int endZ = centerZ + radius;
|
||||
final int endX = center.getX() + radius;
|
||||
final int endY = center.getY() + radius;
|
||||
final int endZ = center.getZ() + radius;
|
||||
|
||||
//Build faces of the box
|
||||
for (x = startX; x <= endX; x++)
|
||||
{
|
||||
for (z = startZ; z <= endZ; z++)
|
||||
{
|
||||
setBlockDirectlySpecial(world, x, startY, z, block, metadata, placeTnt, nonTntWeight);
|
||||
setBlockDirectlySpecial(world, x, endY, z, block, metadata, placeTnt, nonTntWeight);
|
||||
for (x = startX; x <= endX; x++) {
|
||||
for (z = startZ; z <= endZ; z++) {
|
||||
setBlockDirectlySpecial(world, new BlockPos(x, startY, z), state, placeTnt, nonTntWeight);
|
||||
setBlockDirectlySpecial(world, new BlockPos(x, endY, z), state, placeTnt, nonTntWeight);
|
||||
}
|
||||
|
||||
for (y = startY; y <= endY; y++)
|
||||
{
|
||||
setBlockDirectlySpecial(world, x, y, startZ, block, metadata, placeTnt, nonTntWeight);
|
||||
setBlockDirectlySpecial(world, x, y, endZ, block, metadata, placeTnt, nonTntWeight);
|
||||
for (y = startY; y <= endY; y++) {
|
||||
setBlockDirectlySpecial(world, new BlockPos(x, y, startZ), state, placeTnt, nonTntWeight);
|
||||
setBlockDirectlySpecial(world, new BlockPos(x, y, endZ), state, placeTnt, nonTntWeight);
|
||||
}
|
||||
}
|
||||
|
||||
for (y = startY; y <= endY; y++)
|
||||
{
|
||||
for (z = startZ; z <= endZ; z++)
|
||||
{
|
||||
setBlockDirectlySpecial(world, startX, y, z, block, metadata, placeTnt, nonTntWeight);
|
||||
setBlockDirectlySpecial(world, endX, y, z, block, metadata, placeTnt, nonTntWeight);
|
||||
for (y = startY; y <= endY; y++) {
|
||||
for (z = startZ; z <= endZ; z++) {
|
||||
setBlockDirectlySpecial(world, new BlockPos(startX, y, z), state, placeTnt, nonTntWeight);
|
||||
setBlockDirectlySpecial(world, new BlockPos(endX, y, z), state, placeTnt, nonTntWeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setBlockDirectlySpecial(World world, int x, int y, int z, Block block, int metadata, boolean placeTnt, int nonTntWeight)
|
||||
{
|
||||
if (placeTnt && random.nextInt(nonTntWeight + 1) == 0)
|
||||
{
|
||||
setBlockDirectly(world, x, y, z, Blocks.tnt, 1);
|
||||
private static void setBlockDirectlySpecial(World world, BlockPos pos, IBlockState state, boolean placeTnt, int nonTntWeight) {
|
||||
if (placeTnt && random.nextInt(nonTntWeight + 1) == 0) {
|
||||
world.setBlockState(pos, Blocks.tnt.getDefaultState().withProperty(BlockTNT.EXPLODE, true), 1);
|
||||
} else {
|
||||
world.setBlockState(pos, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
setBlockDirectly(world, x, y, z, block, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setBlockDirectly(World world, int x, int y, int z, Block block, int metadata)
|
||||
{
|
||||
int cX = x >> 4;
|
||||
int cZ = z >> 4;
|
||||
int cY = y >> 4;
|
||||
Chunk chunk;
|
||||
|
||||
int localX = (x % 16) < 0 ? (x % 16) + 16 : (x % 16);
|
||||
int localZ = (z % 16) < 0 ? (z % 16) + 16 : (z % 16);
|
||||
ExtendedBlockStorage extBlockStorage;
|
||||
|
||||
chunk = world.getChunkFromChunkCoords(cX, cZ);
|
||||
extBlockStorage = chunk.getBlockStorageArray()[cY];
|
||||
if (extBlockStorage == null)
|
||||
{
|
||||
extBlockStorage = new ExtendedBlockStorage(cY << 4, !world.provider.hasNoSky);
|
||||
chunk.getBlockStorageArray()[cY] = extBlockStorage;
|
||||
}
|
||||
extBlockStorage.func_150818_a(localX, y & 15, localZ, block);
|
||||
extBlockStorage.setExtBlockMetadata(localX, y & 15, localZ, metadata);
|
||||
chunk.setChunkModified();
|
||||
}
|
||||
|
||||
public static BoundingBox calculateDefaultBounds(DimData pocket)
|
||||
|
@ -519,29 +462,28 @@ public class PocketBuilder
|
|||
int minX = 0;
|
||||
int minZ = 0;
|
||||
Point4D origin = pocket.origin();
|
||||
int orientation = pocket.orientation();
|
||||
if (orientation < 0 || orientation > 3)
|
||||
{
|
||||
EnumFacing orientation = pocket.orientation();
|
||||
if (orientation.equals(EnumFacing.UP) || orientation.equals(EnumFacing.DOWN)) {
|
||||
throw new IllegalArgumentException("pocket has an invalid orientation value.");
|
||||
}
|
||||
switch (orientation)
|
||||
{
|
||||
case 0:
|
||||
minX = origin.getX() - DEFAULT_POCKET_WALL_THICKNESS + 1;
|
||||
minZ = origin.getZ() - DEFAULT_POCKET_SIZE / 2;
|
||||
break;
|
||||
case 1:
|
||||
minX = origin.getX() - DEFAULT_POCKET_SIZE / 2;
|
||||
minZ = origin.getZ() - DEFAULT_POCKET_WALL_THICKNESS + 1;
|
||||
break;
|
||||
case 2:
|
||||
minX = origin.getX() + DEFAULT_POCKET_WALL_THICKNESS - DEFAULT_POCKET_SIZE;
|
||||
minZ = origin.getZ() - DEFAULT_POCKET_SIZE / 2;
|
||||
break;
|
||||
case 3:
|
||||
minX = origin.getX() - DEFAULT_POCKET_SIZE / 2;
|
||||
minZ = origin.getZ() + DEFAULT_POCKET_WALL_THICKNESS - DEFAULT_POCKET_SIZE;
|
||||
break;
|
||||
|
||||
switch (orientation) {
|
||||
case SOUTH:
|
||||
minX = origin.getX() - DEFAULT_POCKET_WALL_THICKNESS + 1;
|
||||
minZ = origin.getZ() - DEFAULT_POCKET_SIZE / 2;
|
||||
break;
|
||||
case WEST:
|
||||
minX = origin.getX() - DEFAULT_POCKET_SIZE / 2;
|
||||
minZ = origin.getZ() - DEFAULT_POCKET_WALL_THICKNESS + 1;
|
||||
break;
|
||||
case NORTH:
|
||||
minX = origin.getX() + DEFAULT_POCKET_WALL_THICKNESS - DEFAULT_POCKET_SIZE;
|
||||
minZ = origin.getZ() - DEFAULT_POCKET_SIZE / 2;
|
||||
break;
|
||||
case EAST:
|
||||
minX = origin.getX() - DEFAULT_POCKET_SIZE / 2;
|
||||
minZ = origin.getZ() + DEFAULT_POCKET_WALL_THICKNESS - DEFAULT_POCKET_SIZE;
|
||||
break;
|
||||
}
|
||||
return new BoundingBox(minX, 0, minZ, DEFAULT_POCKET_SIZE, 255, DEFAULT_POCKET_SIZE);
|
||||
}
|
||||
|
|
|
@ -7,25 +7,29 @@ import com.zixiken.dimdoors.core.DimLink;
|
|||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.BlockStoneSlab;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
import net.minecraft.world.gen.structure.StructureComponent;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
|
||||
public class ComponentNetherGateway extends StructureComponent
|
||||
{
|
||||
// Note: In this case, it doesn't really matter which class we extend, since this class will
|
||||
// never be passed to Minecraft. We just need an instance to have access to structure-building methods.
|
||||
// If Forge supports adding custom fortress structures in the future, then we might have to change
|
||||
// our class to extend ComponentNetherBridgeCrossing or something along those lines. ~SenseiKiwi
|
||||
|
||||
public ComponentNetherGateway(int componentType, Random random, StructureBoundingBox bounds, int coordBaseMode)
|
||||
{
|
||||
public class ComponentNetherGateway extends StructureComponent {
|
||||
// Note: In this case, it doesn't really matter which class we extend, since this class will
|
||||
// never be passed to Minecraft. We just need an instance to have access to structure-building methods.
|
||||
// If Forge supports adding custom fortress structures in the future, then we might have to change
|
||||
// our class to extend ComponentNetherBridgeCrossing or something along those lines. ~SenseiKiwi
|
||||
|
||||
public ComponentNetherGateway(int componentType, Random random, StructureBoundingBox bounds, EnumFacing coordBaseMode) {
|
||||
super(componentType);
|
||||
|
||||
|
||||
this.boundingBox = bounds;
|
||||
this.coordBaseMode = coordBaseMode;
|
||||
}
|
||||
|
@ -33,32 +37,27 @@ public class ComponentNetherGateway extends StructureComponent
|
|||
/**
|
||||
* Creates and returns a new component piece. Or null if it could not find enough room to place it.
|
||||
*/
|
||||
public static ComponentNetherGateway createValidComponent(List components, Random random, int minX, int minY, int minZ, int coordBaseMode, int componentType)
|
||||
{
|
||||
public static ComponentNetherGateway createValidComponent(List components, Random random, int minX, int minY, int minZ, EnumFacing coordBaseMode, int componentType) {
|
||||
StructureBoundingBox bounds = StructureBoundingBox.getComponentToAddBoundingBox(minX, minY, minZ, -2, 0, 0, 7, 9, 7, coordBaseMode);
|
||||
return isAboveGround(bounds) && StructureComponent.findIntersecting(components, bounds) == null ? new ComponentNetherGateway(componentType, random, bounds, coordBaseMode) : null;
|
||||
}
|
||||
|
||||
public static ComponentNetherGateway createFromComponent(StructureComponent component, Random random)
|
||||
{
|
||||
// Create an instance of our gateway component using the same data as another component,
|
||||
// likely a component that we intend to replace during generation
|
||||
return new ComponentNetherGateway( component.getComponentType(), random,
|
||||
component.getBoundingBox(), getCoordBaseMode(component));
|
||||
|
||||
public static ComponentNetherGateway createFromComponent(StructureComponent component, Random random) {
|
||||
// Create an instance of our gateway component using the same data as another component,
|
||||
// likely a component that we intend to replace during generation
|
||||
return new ComponentNetherGateway( component.getComponentType(), random, component.getBoundingBox(), getCoordBaseMode(component));
|
||||
}
|
||||
|
||||
private static int getCoordBaseMode(StructureComponent component)
|
||||
{
|
||||
// This is a hack to get the value of a component's coordBaseMode field.
|
||||
// It's essentially the orientation of the component... with a weird name.
|
||||
return component.func_143010_b().getInteger("O");
|
||||
|
||||
private static EnumFacing getCoordBaseMode(StructureComponent component) {
|
||||
// This is a hack to get the value of a component's coordBaseMode field.
|
||||
// It's essentially the orientation of the component... with a weird name.
|
||||
return EnumFacing.getHorizontal(component.createStructureBaseNBT().getInteger("O"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the bounding box's minY is > 10
|
||||
*/
|
||||
protected static boolean isAboveGround(StructureBoundingBox par0StructureBoundingBox)
|
||||
{
|
||||
protected static boolean isAboveGround(StructureBoundingBox par0StructureBoundingBox) {
|
||||
return par0StructureBoundingBox != null && par0StructureBoundingBox.minY > 10;
|
||||
}
|
||||
|
||||
|
@ -67,116 +66,113 @@ public class ComponentNetherGateway extends StructureComponent
|
|||
* the end, it adds Fences...
|
||||
*/
|
||||
@Override
|
||||
public boolean addComponentParts(World world, Random random, StructureBoundingBox bounds)
|
||||
{
|
||||
int NETHER_SLAB_METADATA = 6;
|
||||
|
||||
public boolean addComponentParts(World world, Random random, StructureBoundingBox bounds) {
|
||||
// Set all the blocks in the area of the room to air
|
||||
this.fillWithBlocks(world, bounds, 0, 2, 0, 6, 6, 6, Blocks.air, Blocks.air, false);
|
||||
this.fillWithBlocks(world, bounds, 0, 2, 0, 6, 6, 6, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
|
||||
// Set up the platform under the gateway
|
||||
this.fillWithBlocks(world, bounds, 0, 0, 0, 6, 1, 6, Blocks.nether_brick, Blocks.nether_brick, false);
|
||||
|
||||
this.fillWithBlocks(world, bounds, 0, 0, 0, 6, 1, 6, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
|
||||
|
||||
// Build the fence at the back of the room
|
||||
this.fillWithBlocks(world, bounds, 1, 2, 6, 5, 2, 6, Blocks.nether_brick, Blocks.nether_brick, false);
|
||||
this.fillWithBlocks(world, bounds, 1, 3, 6, 5, 3, 6, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false);
|
||||
this.fillWithBlocks(world, bounds, 1, 2, 6, 5, 2, 6, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
|
||||
this.fillWithBlocks(world, bounds, 1, 3, 6, 5, 3, 6, Blocks.nether_brick_fence.getDefaultState(), Blocks.nether_brick_fence.getDefaultState(), false);
|
||||
|
||||
// Build the fences at the sides of the room
|
||||
this.fillWithBlocks(world, bounds, 0, 2, 0, 0, 2, 6, Blocks.nether_brick, Blocks.nether_brick, false);
|
||||
this.fillWithBlocks(world, bounds, 0, 3, 0, 0, 3, 6, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false);
|
||||
|
||||
this.fillWithBlocks(world, bounds, 6, 2, 0, 6, 2, 6, Blocks.nether_brick, Blocks.nether_brick, false);
|
||||
this.fillWithBlocks(world, bounds, 6, 3, 0, 6, 3, 6, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false);
|
||||
|
||||
this.fillWithBlocks(world, bounds, 0, 2, 0, 0, 2, 6, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
|
||||
this.fillWithBlocks(world, bounds, 0, 3, 0, 0, 3, 6, Blocks.nether_brick_fence.getDefaultState(), Blocks.nether_brick_fence.getDefaultState(), false);
|
||||
|
||||
this.fillWithBlocks(world, bounds, 6, 2, 0, 6, 2, 6, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
|
||||
this.fillWithBlocks(world, bounds, 6, 3, 0, 6, 3, 6, Blocks.nether_brick_fence.getDefaultState(), Blocks.nether_brick_fence.getDefaultState(), false);
|
||||
|
||||
// Build the fence portions closest to the entrance
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick, 0, 1, 2, 0, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_fence, 0, 1, 3, 0, bounds);
|
||||
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick, 0, 5, 2, 0, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_fence, 0, 5, 3, 0, bounds);
|
||||
|
||||
this.setBlockState(world, Blocks.nether_brick.getDefaultState(), 1, 2, 0, bounds);
|
||||
this.setBlockState(world, Blocks.nether_brick_fence.getDefaultState(), 1, 3, 0, bounds);
|
||||
|
||||
this.setBlockState(world, Blocks.nether_brick.getDefaultState(), 5, 2, 0, bounds);
|
||||
this.setBlockState(world, Blocks.nether_brick_fence.getDefaultState(), 5, 3, 0, bounds);
|
||||
|
||||
// Build the first layer of the gateway
|
||||
this.fillWithBlocks(world, bounds, 1, 2, 2, 5, 2, 5, Blocks.nether_brick, Blocks.nether_brick, false);
|
||||
this.fillWithMetadataBlocks(world, bounds, 1, 2, 1, 5, 2, 1, Blocks.stone_slab, NETHER_SLAB_METADATA, Blocks.stone_slab, NETHER_SLAB_METADATA, false);
|
||||
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.stone_slab, NETHER_SLAB_METADATA, 1, 2, 2, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.stone_slab, NETHER_SLAB_METADATA, 5, 2, 2, bounds);
|
||||
|
||||
this.fillWithBlocks(world, bounds, 1, 2, 2, 5, 2, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
|
||||
this.fillWithBlocks(world, bounds, 1, 2, 1, 5, 2, 1, Blocks.stone_slab.getDefaultState().withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.NETHERBRICK), Blocks.stone_slab.getDefaultState().withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.NETHERBRICK), false);
|
||||
|
||||
this.setBlockState(world, Blocks.stone_slab.getDefaultState().withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.NETHERBRICK), 1, 2, 2, bounds);
|
||||
this.setBlockState(world, Blocks.stone_slab.getDefaultState().withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.NETHERBRICK), 5, 2, 2, bounds);
|
||||
|
||||
// Build the second layer of the gateway
|
||||
int orientation = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 2);
|
||||
this.fillWithBlocks(world, bounds, 2, 3, 3, 2, 3, 4, Blocks.nether_brick, Blocks.nether_brick, false);
|
||||
this.fillWithBlocks(world, bounds, 4, 3, 3, 4, 3, 4, Blocks.nether_brick, Blocks.nether_brick, false);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick, 0, 3, 3, 4, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_stairs, orientation, 3, 3, 5, bounds);
|
||||
|
||||
EnumFacing orientation = EnumFacing.WEST;
|
||||
this.fillWithBlocks(world, bounds, 2, 3, 3, 2, 3, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
|
||||
this.fillWithBlocks(world, bounds, 4, 3, 3, 4, 3, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
|
||||
this.setBlockState(world, Blocks.nether_brick.getDefaultState(), 3, 3, 4, bounds);
|
||||
this.setBlockState(world, Blocks.nether_brick_stairs.getDefaultState().withProperty(BlockStairs.FACING, orientation), 3, 3, 5, bounds);
|
||||
|
||||
// Build the third layer of the gateway
|
||||
// We add 4 to get the rotated metadata for upside-down stairs
|
||||
// because Minecraft only supports metadata rotations for normal stairs -_-
|
||||
this.fillWithMetadataBlocks(world, bounds, 2, 4, 4, 4, 4, 4, Blocks.nether_brick_stairs, orientation, Blocks.nether_brick_stairs, orientation, false);
|
||||
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_stairs, this.getMetadataWithOffset(Blocks.nether_brick_stairs, 0) + 4, 2, 4, 3, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_stairs, this.getMetadataWithOffset(Blocks.nether_brick_stairs, 1) + 4, 4, 4, 3, bounds);
|
||||
|
||||
this.fillWithBlocks(world, bounds, 2, 4, 4, 4, 4, 4, Blocks.nether_brick_stairs.getDefaultState().withProperty(BlockStairs.FACING, orientation), Blocks.nether_brick_stairs.getDefaultState().withProperty(BlockStairs.FACING, orientation), false);
|
||||
|
||||
IBlockState state = Blocks.nether_brick_stairs.getDefaultState().withProperty(BlockStairs.HALF, BlockStairs.EnumHalf.TOP);
|
||||
|
||||
this.setBlockState(world, state, 2, 4, 3, bounds);
|
||||
this.setBlockState(world, state.withProperty(BlockStairs.FACING, EnumFacing.EAST), 4, 4, 3, bounds);
|
||||
|
||||
// Build the fourth layer of the gateway
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick, 0, 3, 5, 3, bounds);
|
||||
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.netherrack, 0, 2, 5, 3, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_stairs, this.getMetadataWithOffset(Blocks.nether_brick_stairs, 0) + 4, 1, 5, 3, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_stairs, this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3) + 4, 2, 5, 2, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_stairs, this.getMetadataWithOffset(Blocks.nether_brick_stairs, 2) + 4, 2, 5, 4, bounds);
|
||||
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.netherrack, 0, 4, 5, 3, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_stairs, this.getMetadataWithOffset(Blocks.nether_brick_stairs, 1) + 4, 5, 5, 3, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_stairs, this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3) + 4, 4, 5, 2, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_stairs, this.getMetadataWithOffset(Blocks.nether_brick_stairs, 2) + 4, 4, 5, 4, bounds);
|
||||
|
||||
this.setBlockState(world, Blocks.nether_brick.getDefaultState(), 3, 5, 3, bounds);
|
||||
|
||||
this.setBlockState(world, Blocks.netherrack.getDefaultState(), 2, 5, 3, bounds);
|
||||
this.setBlockState(world, state, 1, 5, 3, bounds);
|
||||
this.setBlockState(world, state.withProperty(BlockStairs.FACING, EnumFacing.EAST), 2, 5, 2, bounds);
|
||||
this.setBlockState(world, state.withProperty(BlockStairs.FACING, EnumFacing.NORTH), 2, 5, 4, bounds);
|
||||
|
||||
this.setBlockState(world, Blocks.netherrack.getDefaultState(), 4, 5, 3, bounds);
|
||||
this.setBlockState(world, state.withProperty(BlockStairs.FACING, EnumFacing.WEST), 5, 5, 3, bounds);
|
||||
this.setBlockState(world, state.withProperty(BlockStairs.FACING, EnumFacing.EAST), 4, 5, 2, bounds);
|
||||
this.setBlockState(world, state.withProperty(BlockStairs.FACING, EnumFacing.NORTH), 4, 5, 4, bounds);
|
||||
|
||||
// Build the top layer of the gateway
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_fence, 0, 3, 6, 3, bounds);
|
||||
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.fire, 0, 2, 6, 3, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_fence, 0, 1, 6, 3, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_fence, 0, 2, 6, 2, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_fence, 0, 2, 6, 4, bounds);
|
||||
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.fire, 0, 4, 6, 3, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_fence, 0, 5, 6, 3, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_fence, 0, 4, 6, 2, bounds);
|
||||
this.placeBlockAtCurrentPosition(world, Blocks.nether_brick_fence, 0, 4, 6, 4, bounds);
|
||||
|
||||
this.setBlockState(world, Blocks.nether_brick_fence.getDefaultState(), 3, 6, 3, bounds);
|
||||
|
||||
this.setBlockState(world, Blocks.fire.getDefaultState(), 2, 6, 3, bounds);
|
||||
this.setBlockState(world, Blocks.nether_brick_fence.getDefaultState(), 1, 6, 3, bounds);
|
||||
this.setBlockState(world, Blocks.nether_brick_fence.getDefaultState(), 2, 6, 2, bounds);
|
||||
this.setBlockState(world, Blocks.nether_brick_fence.getDefaultState(), 2, 6, 4, bounds);
|
||||
|
||||
this.setBlockState(world, Blocks.fire.getDefaultState(), 4, 6, 3, bounds);
|
||||
this.setBlockState(world, Blocks.nether_brick_fence.getDefaultState(), 5, 6, 3, bounds);
|
||||
this.setBlockState(world, Blocks.nether_brick_fence.getDefaultState(), 4, 6, 2, bounds);
|
||||
this.setBlockState(world, Blocks.nether_brick_fence.getDefaultState(), 4, 6, 4, bounds);
|
||||
|
||||
// Place the transient door
|
||||
int y = this.getYWithOffset(3);
|
||||
int x = this.getXWithOffset(3, 3);
|
||||
int z = this.getZWithOffset(3, 3);
|
||||
BlockPos pos = new BlockPos(this.getYWithOffset(3), this.getXWithOffset(3, 3), this.getZWithOffset(3, 3));
|
||||
|
||||
DimLink link;
|
||||
DimData dimension;
|
||||
|
||||
// This function might run multiple times for a single component
|
||||
// due to the way Minecraft handles structure generation!
|
||||
if (bounds.isVecInside(x, y, z) && bounds.isVecInside(x, y + 1, z))
|
||||
{
|
||||
orientation = this.getMetadataWithOffset(Blocks.wooden_door, 1);
|
||||
dimension = PocketManager.createDimensionData(world);
|
||||
link = dimension.getLink(x, y + 1, z);
|
||||
if (link == null)
|
||||
{
|
||||
link = dimension.createLink(x, y + 1, z, LinkType.DUNGEON, orientation);
|
||||
}
|
||||
ItemDoor.placeDoorBlock(world, x, y, z, orientation, DimDoors.transientDoor);
|
||||
if (bounds.isVecInside(pos) && bounds.isVecInside(pos.up())) {
|
||||
orientation = Blocks.oak_door.getDefaultState().getValue(BlockDoor.FACING);
|
||||
|
||||
dimension = PocketManager.createDimensionData(world);
|
||||
|
||||
link = dimension.getLink(pos.up());
|
||||
if (link == null) {
|
||||
link = dimension.createLink(pos.up(), LinkType.DUNGEON, orientation);
|
||||
}
|
||||
|
||||
ItemDoor.placeDoor(world, pos, orientation, DimDoors.transientDoor);
|
||||
}
|
||||
|
||||
for (x = 0; x <= 6; ++x)
|
||||
{
|
||||
for (z = 0; z <= 6; ++z)
|
||||
{
|
||||
this.func_151554_b(world, Blocks.nether_brick, 0, x, -1, z, bounds);
|
||||
for (int i = 0; i <= 6; ++ i) {
|
||||
for (int k = 0; k <= 6; ++k) {
|
||||
this.setBlockState(world, Blocks.nether_brick.getDefaultState(), i, -1, k, bounds);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void func_143012_a(NBTTagCompound tag) { }
|
||||
@Override
|
||||
protected void writeStructureToNBT(NBTTagCompound tagCompound) {}
|
||||
|
||||
@Override
|
||||
protected void func_143011_b(NBTTagCompound tag) { }
|
||||
}
|
||||
@Override
|
||||
protected void readStructureFromNBT(NBTTagCompound tagCompound) {}
|
||||
}
|
|
@ -5,17 +5,15 @@ import net.minecraft.world.gen.structure.MapGenNetherBridge;
|
|||
import net.minecraft.world.gen.structure.MapGenStructureIO;
|
||||
import net.minecraft.world.gen.structure.StructureStart;
|
||||
|
||||
public class DDNetherFortressGenerator extends MapGenNetherBridge
|
||||
{
|
||||
public class DDNetherFortressGenerator extends MapGenNetherBridge {
|
||||
public DDNetherFortressGenerator()
|
||||
{
|
||||
super();
|
||||
{super();
|
||||
|
||||
// Register our custom StructureStart class with MapGenStructureIO
|
||||
// If we don't do this, Minecraft will crash when a fortress tries to generate.
|
||||
// Moreover, use Fortress as our structure identifier so that if DD is removed,
|
||||
// fortresses will generate properly using Vanilla code.
|
||||
MapGenStructureIO.func_143031_a(DDStructureNetherBridgeStart.class, "Fortress");
|
||||
MapGenStructureIO.registerStructure(DDStructureNetherBridgeStart.class, "Fortress");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,8 +23,7 @@ public class DDStructureNetherBridgeStart extends StructureStart
|
|||
|
||||
public DDStructureNetherBridgeStart() { }
|
||||
|
||||
public DDStructureNetherBridgeStart(World world, Random random, int chunkX, int chunkZ, DDProperties properties)
|
||||
{
|
||||
public DDStructureNetherBridgeStart(World world, Random random, int chunkX, int chunkZ, DDProperties properties) {
|
||||
// StructureNetherBridgeStart handles designing the fortress for us
|
||||
super(chunkX, chunkZ);
|
||||
|
||||
|
@ -35,23 +34,19 @@ public class DDStructureNetherBridgeStart extends StructureStart
|
|||
hasGateway = false;
|
||||
|
||||
// Randomly decide whether to build a gateway in this fortress
|
||||
if (random.nextInt(MAX_GATEWAY_GENERATION_CHANCE) < properties.FortressGatewayGenerationChance)
|
||||
{
|
||||
if (random.nextInt(MAX_GATEWAY_GENERATION_CHANCE) < properties.FortressGatewayGenerationChance) {
|
||||
// Search for all the blaze spawners in a fortress
|
||||
spawnerRooms = new ArrayList<StructureNetherBridgePieces.Throne>();
|
||||
componentIterator = this.components.iterator();
|
||||
while (componentIterator.hasNext())
|
||||
{
|
||||
while (componentIterator.hasNext()) {
|
||||
component = (StructureComponent) componentIterator.next();
|
||||
if (component instanceof StructureNetherBridgePieces.Throne)
|
||||
{
|
||||
if (component instanceof StructureNetherBridgePieces.Throne) {
|
||||
spawnerRooms.add((StructureNetherBridgePieces.Throne) component);
|
||||
}
|
||||
}
|
||||
|
||||
// If any spawner rooms were found, choose one to randomly replace
|
||||
if (!spawnerRooms.isEmpty())
|
||||
{
|
||||
if (!spawnerRooms.isEmpty()) {
|
||||
hasGateway = true;
|
||||
component = spawnerRooms.get(random.nextInt(spawnerRooms.size()));
|
||||
// Store enough data to identify the room when it's going to be built later
|
||||
|
@ -64,37 +59,33 @@ public class DDStructureNetherBridgeStart extends StructureStart
|
|||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound func_143021_a(int chunkX, int chunkZ)
|
||||
{
|
||||
public NBTTagCompound writeStructureComponentsToNBT(int chunkX, int chunkZ) {
|
||||
// We override the function for writing NBT data to add our own gateway data
|
||||
NBTTagCompound fortressTag = super.func_143021_a(chunkX, chunkZ);
|
||||
NBTTagCompound fortressTag = super.writeStructureComponentsToNBT(chunkX, chunkZ);
|
||||
|
||||
// Add a compound tag with our data
|
||||
NBTTagCompound dimensionalTag = new NBTTagCompound();
|
||||
dimensionalTag.setBoolean("HasGateway", this.hasGateway);
|
||||
if (hasGateway)
|
||||
{
|
||||
if (hasGateway) {
|
||||
dimensionalTag.setInteger("GatewayMinX", this.minX);
|
||||
dimensionalTag.setInteger("GatewayMinY", this.minY);
|
||||
dimensionalTag.setInteger("GatewayMinZ", this.minZ);
|
||||
}
|
||||
|
||||
fortressTag.setTag("DimensionalDoors", dimensionalTag);
|
||||
|
||||
return fortressTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_143020_a(World world, NBTTagCompound fortressTag)
|
||||
{
|
||||
public void readStructureComponentsFromNBT(World world, NBTTagCompound fortressTag) {
|
||||
// We override the function for reading NBT data to load gateway data
|
||||
super.func_143020_a(world, fortressTag);
|
||||
super.readStructureComponentsFromNBT(world, fortressTag);
|
||||
|
||||
NBTTagCompound dimensionalTag = fortressTag.getCompoundTag("DimensionalDoors");
|
||||
if (dimensionalTag != null)
|
||||
{
|
||||
if (dimensionalTag != null) {
|
||||
this.hasGateway = dimensionalTag.getBoolean("HasGateway");
|
||||
if (hasGateway)
|
||||
{
|
||||
if (hasGateway) {
|
||||
minX = dimensionalTag.getInteger("GatewayMinX");
|
||||
minY = dimensionalTag.getInteger("GatewayMinY");
|
||||
minZ = dimensionalTag.getInteger("GatewayMinZ");
|
||||
|
@ -106,38 +97,31 @@ public class DDStructureNetherBridgeStart extends StructureStart
|
|||
* Keeps iterating Structure Pieces and spawning them until the checks tell it to stop
|
||||
*/
|
||||
@Override
|
||||
public void generateStructure(World world, Random random, StructureBoundingBox generationBounds)
|
||||
{
|
||||
if (hasGateway)
|
||||
{
|
||||
public void generateStructure(World world, Random random, StructureBoundingBox generationBounds) {
|
||||
if (hasGateway) {
|
||||
// Use a modified version of Vanilla's fortress generation code
|
||||
// Try to detect the room that we intend to replace with our gateway
|
||||
Iterator iterator = this.components.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
while (iterator.hasNext()) {
|
||||
StructureComponent component = (StructureComponent)iterator.next();
|
||||
StructureBoundingBox bounds = component.getBoundingBox();
|
||||
|
||||
if (bounds.intersectsWith(generationBounds))
|
||||
{
|
||||
if (bounds.intersectsWith(generationBounds)) {
|
||||
// Check if this is our replacement target
|
||||
// Checking the location is enough because structures aren't allowed to have
|
||||
// intersecting bounding boxes - nothing else can have these min coordinates.
|
||||
if (bounds.minX == this.minX && bounds.minY == this.minY && bounds.minZ == this.minZ)
|
||||
{
|
||||
if (bounds.minX == this.minX && bounds.minY == this.minY && bounds.minZ == this.minZ) {
|
||||
component = ComponentNetherGateway.createFromComponent(component, random);
|
||||
}
|
||||
|
||||
// Now for the last bit of Vanilla's generation code
|
||||
if (!component.addComponentParts(world, random, generationBounds))
|
||||
{
|
||||
if (!component.addComponentParts(world, random, generationBounds)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Just run the usual structure generation
|
||||
super.generateStructure(world, random, generationBounds);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.zixiken.dimdoors.world.PocketProvider;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
@ -76,7 +77,7 @@ public class GatewayGenerator implements IWorldGenerator
|
|||
return;
|
||||
}
|
||||
|
||||
int x, y, z;
|
||||
BlockPos pos = BlockPos.ORIGIN;
|
||||
int attempts;
|
||||
boolean valid;
|
||||
DimLink link;
|
||||
|
@ -84,34 +85,27 @@ public class GatewayGenerator implements IWorldGenerator
|
|||
|
||||
// Check if we're allowed to generate rift clusters in this dimension.
|
||||
// If so, randomly decide whether to one.
|
||||
if (DimDoors.worldProperties.RiftClusterDimensions.isAccepted(dimensionID)
|
||||
&& random.nextInt(MAX_CLUSTER_GENERATION_CHANCE) < properties.ClusterGenerationChance)
|
||||
{
|
||||
if (DimDoors.worldProperties.RiftClusterDimensions.isAccepted(dimensionID) && random.nextInt(MAX_CLUSTER_GENERATION_CHANCE) < properties.ClusterGenerationChance) {
|
||||
link = null;
|
||||
dimension = null;
|
||||
do
|
||||
{
|
||||
do {
|
||||
//Pick a random point on the surface of the chunk
|
||||
x = chunkX * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH);
|
||||
z = chunkZ * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH);
|
||||
y = world.getHeight(new BlockPos(x, 0, z)).getY();
|
||||
pos = new BlockPos(chunkX * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH), 0, chunkZ * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH));
|
||||
pos = world.getHeight(pos);
|
||||
|
||||
//If the point is within the acceptable altitude range, the block above is empty, and we're
|
||||
//not building on bedrock, then generate a rift there
|
||||
if (y >= MIN_RIFT_Y && y <= MAX_RIFT_Y && world.isAirBlock(x, y + 1, z) &&
|
||||
world.getBlock(x, y, z) != Blocks.bedrock && //<-- Stops Nether roof spawning. DO NOT REMOVE!
|
||||
world.getBlock(x, y - 1, z) != Blocks.bedrock &&
|
||||
world.getBlock(x, y - 2, z) != Blocks.bedrock)
|
||||
{
|
||||
if (pos.getY() >= MIN_RIFT_Y && pos.getY() <= MAX_RIFT_Y && world.isAirBlock(pos.up()) &&
|
||||
world.getBlockState(pos).getBlock() != Blocks.bedrock && //<-- Stops Nether roof spawning. DO NOT REMOVE!
|
||||
world.getBlockState(pos.down()).getBlock() != Blocks.bedrock &&
|
||||
world.getBlockState(pos.down(2)).getBlock() != Blocks.bedrock) {
|
||||
|
||||
//Create a link. If this is not the first time, create a child link and connect it to the first link.
|
||||
if (link == null)
|
||||
{
|
||||
if (link == null) {
|
||||
dimension = PocketManager.getDimensionData(world);
|
||||
link = dimension.createLink(x, y + 1, z, LinkType.DUNGEON,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
dimension.createChildLink(x, y + 1, z, link);
|
||||
link = dimension.createLink(pos.up(), LinkType.DUNGEON, EnumFacing.SOUTH);
|
||||
} else {
|
||||
dimension.createChildLink(pos.up(), link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,64 +115,51 @@ public class GatewayGenerator implements IWorldGenerator
|
|||
|
||||
// Check if we can place a Rift Gateway in this dimension, then randomly decide whether to place one.
|
||||
// This only happens if a rift cluster was NOT generated.
|
||||
else if (DimDoors.worldProperties.RiftGatewayDimensions.isAccepted(dimensionID) &&
|
||||
random.nextInt(MAX_GATEWAY_GENERATION_CHANCE) < properties.GatewayGenerationChance)
|
||||
{
|
||||
else if (DimDoors.worldProperties.RiftGatewayDimensions.isAccepted(dimensionID) && random.nextInt(MAX_GATEWAY_GENERATION_CHANCE) < properties.GatewayGenerationChance) {
|
||||
valid = false;
|
||||
x = y = z = 0; //Stop the compiler from freaking out
|
||||
|
||||
//Check locations for the gateway until we are satisfied or run out of attempts.
|
||||
for (attempts = 0; attempts < MAX_GATEWAY_GENERATION_ATTEMPTS && !valid; attempts++)
|
||||
{
|
||||
for (attempts = 0; attempts < MAX_GATEWAY_GENERATION_ATTEMPTS && !valid; attempts++) {
|
||||
//Pick a random point on the surface of the chunk and check its materials
|
||||
x = chunkX * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH);
|
||||
z = chunkZ * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH);
|
||||
y = world.getHeightValue(x, z);
|
||||
valid = checkGatewayLocation(world, x, y, z);
|
||||
pos = new BlockPos(chunkX * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH), 0, chunkZ * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH));
|
||||
pos = world.getHeight(pos);
|
||||
valid = checkGatewayLocation(world, pos);
|
||||
}
|
||||
|
||||
// Build the gateway if we found a valid location
|
||||
if (valid)
|
||||
{
|
||||
if (valid) {
|
||||
ArrayList<BaseGateway> validGateways = new ArrayList<BaseGateway>();
|
||||
for (BaseGateway gateway : gateways)
|
||||
{
|
||||
if (gateway.isLocationValid(world, x, y, z))
|
||||
{
|
||||
for (BaseGateway gateway : gateways) {
|
||||
if (gateway.isLocationValid(world, pos)) {
|
||||
validGateways.add(gateway);
|
||||
}
|
||||
}
|
||||
// Add the default gateway if the rest were rejected
|
||||
if (validGateways.isEmpty())
|
||||
{
|
||||
if (validGateways.isEmpty()) {
|
||||
validGateways.add(defaultGateway);
|
||||
}
|
||||
// Randomly select a gateway from the pool of viable gateways
|
||||
validGateways.get(random.nextInt(validGateways.size())).generate(world, x, y - 1, z);
|
||||
validGateways.get(random.nextInt(validGateways.size())).generate(world, pos.down());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean checkGatewayLocation(World world, int x, int y, int z)
|
||||
{
|
||||
private static boolean checkGatewayLocation(World world, BlockPos pos) {
|
||||
//Check if the point is within the acceptable altitude range, the block above that point is empty,
|
||||
//and the block two levels down is opaque and has a reasonable material. Plus that we're not building
|
||||
//on top of bedrock.
|
||||
return (y >= MIN_RIFT_Y &&
|
||||
y <= MAX_RIFT_Y &&
|
||||
world.isAirBlock(x, y + 1, z) &&
|
||||
world.getBlock(x, y, z) != Blocks.bedrock && //<-- Stops Nether roof spawning. DO NOT REMOVE!
|
||||
world.getBlock(x, y - 1, z) != Blocks.bedrock &&
|
||||
checkFoundationMaterial(world, x, y - 2, z));
|
||||
return (pos.getY() >= MIN_RIFT_Y && pos.getY() <= MAX_RIFT_Y && world.isAirBlock(pos.up()) &&
|
||||
world.getBlockState(pos).getBlock() != Blocks.bedrock && //<-- Stops Nether roof spawning. DO NOT REMOVE!
|
||||
world.getBlockState(pos.down()).getBlock() != Blocks.bedrock &&
|
||||
checkFoundationMaterial(world, pos.down(2)));
|
||||
}
|
||||
|
||||
private static boolean checkFoundationMaterial(World world, int x, int y, int z)
|
||||
{
|
||||
private static boolean checkFoundationMaterial(World world, BlockPos pos) {
|
||||
//We check the material and opacity to prevent generating gateways on top of trees or houses,
|
||||
//or on top of strange things like tall grass, water, slabs, or torches.
|
||||
//We also want to avoid generating things on top of the Nether's bedrock!
|
||||
Material material = world.getBlock(x, y, z).getMaterial();
|
||||
Material material = world.getBlockState(pos).getBlock().getMaterial();
|
||||
return (material != Material.leaves && material != Material.wood && material != Material.gourd
|
||||
&& world.isBlockNormalCubeDefault(x, y, z, false) && world.getBlock(x, y, z) != Blocks.bedrock);
|
||||
&& world.isBlockNormalCube(pos, false) && world.getBlockState(pos).getBlock() != Blocks.bedrock);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,43 +2,43 @@ package com.zixiken.dimdoors.world.gateways;
|
|||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.world.LimboProvider;
|
||||
|
||||
public class GatewayLimbo extends BaseGateway
|
||||
{
|
||||
public GatewayLimbo(DDProperties properties)
|
||||
{
|
||||
public class GatewayLimbo extends BaseGateway {
|
||||
public GatewayLimbo(DDProperties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(World world, int x, int y, int z)
|
||||
{
|
||||
Block block = DimDoors.blockLimbo;
|
||||
public boolean generate(World world, BlockPos pos) {
|
||||
IBlockState state = DimDoors.blockLimbo.getDefaultState();
|
||||
// Build the gateway out of Unraveled Fabric. Since nearly all the blocks in Limbo are of
|
||||
// that type, there is no point replacing the ground.
|
||||
world.setBlock(x, y + 3, z + 1, block, 0, 3);
|
||||
world.setBlock(x, y + 3, z - 1, block, 0, 3);
|
||||
world.setBlockState(pos.add(0,3,1), state);
|
||||
world.setBlockState(pos.add(0,3,-1), state);
|
||||
|
||||
// Build the columns around the door
|
||||
world.setBlock(x, y + 2, z - 1, block, 0, 3);
|
||||
world.setBlock(x, y + 2, z + 1, block, 0, 3);
|
||||
world.setBlock(x, y + 1, z - 1, block, 0, 3);
|
||||
world.setBlock(x, y + 1, z + 1, block, 0, 3);
|
||||
world.setBlockState(pos.add(0,2,-1), state);
|
||||
world.setBlockState(pos.add(0,2,1), state);
|
||||
world.setBlockState(pos.add(0,1,-1), state);
|
||||
world.setBlockState(pos.add(0,1,1), state);
|
||||
|
||||
PocketManager.getDimensionData(world).createLink(x, y + 2, z, LinkType.DUNGEON, 0);
|
||||
PocketManager.getDimensionData(world).createLink(pos.up(2), LinkType.DUNGEON, EnumFacing.SOUTH);
|
||||
|
||||
ItemDoor.placeDoorBlock(world, x, y + 1, z, 0, DimDoors.transientDoor);
|
||||
ItemDoor.placeDoor(world, pos.up(), EnumFacing.SOUTH, DimDoors.transientDoor);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocationValid(World world, int x, int y, int z) {
|
||||
public boolean isLocationValid(World world, BlockPos pos) {
|
||||
return (world.provider instanceof LimboProvider);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,10 @@ package com.zixiken.dimdoors.world.gateways;
|
|||
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStoneBrick;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GatewayTwoPillars extends BaseSchematicGateway
|
||||
|
@ -15,31 +18,24 @@ public class GatewayTwoPillars extends BaseSchematicGateway
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void generateRandomBits(World world, int x, int y, int z)
|
||||
{
|
||||
final Block block = Blocks.stonebrick;
|
||||
protected void generateRandomBits(World world, BlockPos pos) {
|
||||
final IBlockState state = Blocks.stonebrick.getDefaultState();
|
||||
|
||||
//Replace some of the ground around the gateway with bricks
|
||||
for (int xc = -GATEWAY_RADIUS; xc <= GATEWAY_RADIUS; xc++)
|
||||
{
|
||||
for (int zc= -GATEWAY_RADIUS; zc <= GATEWAY_RADIUS; zc++)
|
||||
{
|
||||
for (int xc = -GATEWAY_RADIUS; xc <= GATEWAY_RADIUS; xc++) {
|
||||
for (int zc= -GATEWAY_RADIUS; zc <= GATEWAY_RADIUS; zc++) {
|
||||
//Check that the block is supported by an opaque block.
|
||||
//This prevents us from building over a cliff, on the peak of a mountain,
|
||||
//or the surface of the ocean or a frozen lake.
|
||||
if (world.isBlockNormalCubeDefault(x + xc, y - 1, z + zc, false))
|
||||
{
|
||||
if (world.isBlockNormalCube(pos.add(xc, 0, zc).down(), false)) {
|
||||
//Randomly choose whether to place bricks or not. The math is designed so that the
|
||||
//chances of placing a block decrease as we get farther from the gateway's center.
|
||||
if (Math.abs(xc) + Math.abs(zc) < world.rand.nextInt(2) + 3)
|
||||
{
|
||||
if (Math.abs(xc) + Math.abs(zc) < world.rand.nextInt(2) + 3) {
|
||||
//Place Stone Bricks
|
||||
world.setBlock(x + xc, y, z + zc, block, 0, 3);
|
||||
}
|
||||
else if (Math.abs(xc) + Math.abs(zc) < world.rand.nextInt(3) + 3)
|
||||
{
|
||||
world.setBlockState(pos.add(xc, 0, zc), state);
|
||||
} else if (Math.abs(xc) + Math.abs(zc) < world.rand.nextInt(3) + 3) {
|
||||
//Place Cracked Stone Bricks
|
||||
world.setBlock(x + xc, y, z + zc, block, 2, 3);
|
||||
world.setBlockState(pos.add(xc, 0, zc), state.withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.CRACKED));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +43,6 @@ public class GatewayTwoPillars extends BaseSchematicGateway
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getSchematicPath() {
|
||||
return "/schematics/gateways/twoPillars.schematic";
|
||||
public String getSchematicPath() {return "/schematics/gateways/twoPillars.schematic";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue