Bug fixes
- Fix dimensional trapdoor - Fix world unload bug - Fix gradle bug
This commit is contained in:
parent
94cadce276
commit
9e7646d047
20 changed files with 86 additions and 111 deletions
|
@ -6,8 +6,11 @@ import net.minecraft.client.particle.ParticleSimpleAnimated;
|
|||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
// This has exactly the same appearence as the 1.6.4 mod.
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ParticleRiftEffect extends ParticleSimpleAnimated { // TODO: colors, density
|
||||
|
||||
private float colorMultiplier;
|
||||
|
|
|
@ -11,6 +11,8 @@ import ddutils.render.RGBA;
|
|||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.vertex.*;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -19,6 +21,7 @@ import net.minecraft.util.ResourceLocation;
|
|||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TileEntityEntranceRiftRenderer extends TileEntitySpecialRenderer<TileEntityEntranceRift> { // TODO: see TileEntityEndGatewayRenderer
|
||||
|
||||
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
|
||||
|
@ -96,7 +99,7 @@ public class TileEntityEntranceRiftRenderer extends TileEntitySpecialRenderer<Ti
|
|||
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_EYE_PLANE, getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
|
||||
break;
|
||||
case DOWN:
|
||||
// TODO: logic for UP
|
||||
// TODO: logic for DOWN
|
||||
}
|
||||
|
||||
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
|
||||
|
@ -128,7 +131,7 @@ public class TileEntityEntranceRiftRenderer extends TileEntitySpecialRenderer<Ti
|
|||
double ovs = 0.5 - extendDown;
|
||||
double ove = 0.5 + extendUp;
|
||||
// Render the rectangle based on the orientation
|
||||
double od = orientation == EnumFacing.NORTH || orientation == EnumFacing.WEST || orientation == EnumFacing.DOWN ? pushIn : 1 - pushIn;
|
||||
double od = orientation == EnumFacing.NORTH || orientation == EnumFacing.WEST || orientation == EnumFacing.UP ? pushIn : 1 - pushIn;
|
||||
switch (orientation) {
|
||||
case NORTH:
|
||||
worldRenderer.pos(x + ohs, y + ovs, z + od).endVertex();
|
||||
|
|
|
@ -11,9 +11,11 @@ import net.minecraft.client.renderer.Tessellator;
|
|||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TileEntityFloatingRiftRenderer extends TileEntitySpecialRenderer<TileEntityFloatingRift> {
|
||||
private static ResourceLocation tesseract_path = new ResourceLocation(DimDoors.MODID + ":textures/other/tesseract.png");
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ public class DDProxyServer extends DDProxyCommon {
|
|||
}
|
||||
|
||||
@Override
|
||||
public WorldServer getWorldServer(int dimId) {
|
||||
return DimensionManager.getWorld(dimId);
|
||||
public WorldServer getWorldServer(int dim) {
|
||||
return DimensionManager.getWorld(0).getMinecraftServer().getWorld(dim);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,10 +42,10 @@ public class EventHandler {
|
|||
EntityPlayerMP player = (EntityPlayerMP) entity;
|
||||
World world = entity.world;
|
||||
int dimID = world.provider.getDimension();
|
||||
if (!world.isRemote && !player.isDead && DimDoorDimensions.isPocketDimension(dimID) && !PocketRegistry.getForDim(dimID).isPlayerAllowedToBeHere(player, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ())) {
|
||||
if (!world.isRemote && !player.isDead && DimDoorDimensions.isPocketDimension(dimID) && !PocketRegistry.getForDim(dimID).isPlayerAllowedToBeHere(player, player.getPosition())) {
|
||||
// TODO: Avoid players even getting here by making a maximum build distance that's smaller than the pocket size
|
||||
// TODO: This doesn't really work yet.
|
||||
// DimDoors.chat(player, "You travelled too far into the void and have been sent to Limbo.");
|
||||
DimDoors.chat(player, "You travelled too far into the void and have been sent to Limbo.");
|
||||
// PocketRegistry.sendToLimbo(player); // TODO
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,15 +56,15 @@ public class VirtualLocation { // TODO: use BlockPos/Location
|
|||
public static VirtualLocation fromLocation(Location location) { // TODO: reverse function too
|
||||
VirtualLocation virtualLocation = null;
|
||||
if (DimDoorDimensions.isPocketDimension(location.getDim())) {
|
||||
Pocket pocket = PocketRegistry.getForDim(location.getDim()).getPocketFromLocation(location.getPos().getY(), location.getPos().getY(), location.getPos().getZ());
|
||||
Pocket pocket = PocketRegistry.getForDim(location.getDim()).getPocketAt(location.getPos());
|
||||
if (pocket != null) {
|
||||
virtualLocation = pocket.getVirtualLocation();
|
||||
virtualLocation = pocket.getVirtualLocation(); // TODO: pocket-relative coordinates
|
||||
} else {
|
||||
virtualLocation = new VirtualLocation(0, 0, 0, 0, 0); // TODO: door was placed in a pocket dim but outside of a pocket...
|
||||
}
|
||||
}
|
||||
if (virtualLocation == null) {
|
||||
virtualLocation = new VirtualLocation(WorldUtils.getDim(location.getWorld()), location.getPos().getX(), location.getPos().getY(), location.getPos().getZ(), 0);
|
||||
virtualLocation = new VirtualLocation(location, 0);
|
||||
}
|
||||
return virtualLocation;
|
||||
}
|
||||
|
|
|
@ -22,8 +22,9 @@ public abstract class ItemDimensionalDoor extends ItemDoor {
|
|||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
EnumActionResult result = super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||
if (result == EnumActionResult.SUCCESS) {
|
||||
IBlockState state = world.getBlockState(pos.offset(facing));
|
||||
((IRiftProvider<?>) state.getBlock()).handleRiftSetup(world, pos.offset(facing), state);
|
||||
if (!world.getBlockState(pos).getBlock().isReplaceable(world, pos)) pos = pos.offset(facing);
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
((IRiftProvider<?>) state.getBlock()).handleRiftSetup(world, pos, state);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.zixiken.dimdoors.shared.blocks.IRiftProvider;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -24,8 +23,9 @@ public abstract class ItemDimensionalTrapdoor extends ItemBlock {
|
|||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
EnumActionResult result = super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||
if (result == EnumActionResult.SUCCESS) {
|
||||
IBlockState state = world.getBlockState(pos.offset(facing));
|
||||
((IRiftProvider<?>) state.getBlock()).handleRiftSetup(world, pos.offset(facing), state);
|
||||
if (!world.getBlockState(pos).getBlock().isReplaceable(world, pos)) pos = pos.offset(facing);
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
((IRiftProvider<?>) state.getBlock()).handleRiftSetup(world, pos, state);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.zixiken.dimdoors.shared.items;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.shared.blocks.BlockDimensionalDoorIron;
|
||||
import com.zixiken.dimdoors.shared.blocks.BlockDimensionalTrapdoorWood;
|
||||
import com.zixiken.dimdoors.shared.blocks.ModBlocks;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
|
|
|
@ -14,16 +14,12 @@ import lombok.Setter;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Robijnvogel
|
||||
*/
|
||||
public class Pocket { // TODO: better visibilities
|
||||
|
||||
@Getter int id; // Not saved
|
||||
@Getter /*private*/ int dimID; // Not saved
|
||||
|
||||
@Getter private int id;
|
||||
@Getter private int x; // Grid x TODO: rename to gridX and gridY
|
||||
@Getter private int z; // Grid y
|
||||
@Getter @Setter private int size; // In chunks TODO: non chunk-based size, better bounds such as minX, minZ, maxX, maxZ, etc.
|
||||
|
@ -32,6 +28,8 @@ public class Pocket { // TODO: better visibilities
|
|||
@Getter Location entrance;
|
||||
@Getter List<Location> riftLocations;
|
||||
|
||||
@Getter int dimID; // Not saved
|
||||
|
||||
private Pocket() {}
|
||||
|
||||
Pocket(int id, int dimID, int x, int z) {
|
||||
|
@ -91,13 +89,14 @@ public class Pocket { // TODO: better visibilities
|
|||
return nbt;
|
||||
}
|
||||
|
||||
boolean isLocationWithinPocketBounds(int locX, int locY, int locZ, int gridSize) {
|
||||
boolean isInBounds(BlockPos pos) {
|
||||
// pocket bounds
|
||||
int gridSize = PocketRegistry.getForDim(dimID).getGridSize();
|
||||
int pocMinX = x * gridSize;
|
||||
int pocMinZ = z * gridSize;
|
||||
int pocMaxX = pocMinX + (size + 1) * 16;
|
||||
int pocMaxZ = pocMinX + (size + 1) * 16;
|
||||
return pocMinX <= locX && pocMinZ <= locZ && locX < pocMaxX && locZ < pocMaxZ;
|
||||
return pocMinX <= pos.getX() && pocMinZ <= pos.getZ() && pos.getX() < pocMaxX && pos.getZ() < pocMaxZ;
|
||||
}
|
||||
|
||||
// TODO better allow/deny player system. Just because a player is allowed in two adjacent pockets doesn't mean he should be able to cross through the void to the other pocket
|
||||
|
@ -108,11 +107,6 @@ public class Pocket { // TODO: better visibilities
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isPlayerAllowedInPocket(EntityPlayer player) { // TODO
|
||||
String playerUUID = player.getCachedUniqueIdString();
|
||||
return playerUUIDs.contains(playerUUID);
|
||||
}
|
||||
|
||||
public List<TileEntityRift> getRifts() {
|
||||
List<TileEntityRift> rifts = new ArrayList<>(riftLocations.size()); // TODO: make immutable
|
||||
for (Location riftLocation : riftLocations) {
|
||||
|
@ -175,8 +169,8 @@ public class Pocket { // TODO: better visibilities
|
|||
|
||||
// set virtual locations and register rifts
|
||||
for (TileEntityRift rift : rifts) {
|
||||
// TODO: put a rift on door break?
|
||||
rift.setVirtualLocation(virtualLocation);
|
||||
rift.markStateChanged();
|
||||
rift.register();
|
||||
}
|
||||
}
|
||||
|
@ -204,5 +198,10 @@ public class Pocket { // TODO: better visibilities
|
|||
// TODO
|
||||
}
|
||||
|
||||
public BlockPos getOrigin() {
|
||||
int gridSize = PocketRegistry.getForDim(dimID).getGridSize();
|
||||
return new BlockPos(x * gridSize, 0, z * gridSize); // TODO: configurable yBase?
|
||||
}
|
||||
|
||||
// TODO: method to erase a pocket
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.zixiken.dimdoors.shared.pockets;
|
|||
|
||||
import com.zixiken.dimdoors.shared.DDConfig;
|
||||
import ddutils.math.GridUtils;
|
||||
import ddutils.Location;
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import ddutils.nbt.NBTUtils;
|
||||
import ddutils.WorldUtils;
|
||||
|
@ -12,11 +11,11 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.storage.MapStorage;
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
||||
|
||||
|
@ -101,6 +100,7 @@ public class PocketRegistry extends WorldSavedData {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static boolean upgradeRegistry(NBTTagCompound nbt, int oldVersion) {
|
||||
if (oldVersion > DATA_VERSION) throw new RuntimeException("Upgrade the mod!"); // TODO: better exceptions
|
||||
switch (oldVersion) {
|
||||
|
@ -143,7 +143,7 @@ public class PocketRegistry extends WorldSavedData {
|
|||
/**
|
||||
* Create a new blank pocket.
|
||||
*
|
||||
* @return The newly created Pocket
|
||||
* @return The newly created pocket
|
||||
*/
|
||||
public Pocket newPocket() {
|
||||
Pocket pocket = null;
|
||||
|
@ -152,14 +152,13 @@ public class PocketRegistry extends WorldSavedData {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new pocket with a specific ID. IMPORTANT: This generates data for all pockets with an ID below, so don't set
|
||||
* too high!
|
||||
* Create a new pocket with a specific ID.
|
||||
*
|
||||
* @return The newly created Pocket, or null if that ID is taken already.
|
||||
* @return The newly created Pocket, or null if that ID is already taken.
|
||||
*/
|
||||
public Pocket newPocket(int id) {
|
||||
if (pockets.get(id) != null) return null;
|
||||
GridUtils.GridPos pos = getGridPosFromID(id);
|
||||
GridUtils.GridPos pos = idToGridPos(id);
|
||||
Pocket pocket = new Pocket(id, dimID, pos.getX(), pos.getZ());
|
||||
pockets.put(id, pocket);
|
||||
if (id >= nextID) nextID = id + 1;
|
||||
|
@ -183,6 +182,7 @@ public class PocketRegistry extends WorldSavedData {
|
|||
return pockets.get(id);
|
||||
}
|
||||
|
||||
// TODO: these should be per-map rather than per-world
|
||||
public int getPrivatePocketID(String playerUUID) {
|
||||
Integer id = privatePocketMap.get(playerUUID);
|
||||
if (id == null) return -1;
|
||||
|
@ -194,58 +194,42 @@ public class PocketRegistry extends WorldSavedData {
|
|||
markDirty();
|
||||
}
|
||||
|
||||
public GridUtils.GridPos getGridPosFromID(int id) {
|
||||
public GridUtils.GridPos idToGridPos(int id) {
|
||||
return GridUtils.numToPos(id);
|
||||
}
|
||||
|
||||
public int getIDFromGridPos(GridUtils.GridPos pos) {
|
||||
public int gridPosToID(GridUtils.GridPos pos) {
|
||||
return GridUtils.posToNum(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the default Location where a pocket should be based on the ID. Use this only for placing
|
||||
* Calculates the default BlockPos where a pocket should be based on the ID. Use this only for placing
|
||||
* pockets, and use Pocket.getGridPos() for getting the position
|
||||
*
|
||||
* @param id The ID of the pocket
|
||||
* @return The Location of the pocket
|
||||
* @return The BlockPos of the pocket
|
||||
*/
|
||||
public Location getLocationFromID(int id) {
|
||||
GridUtils.GridPos pos = getGridPosFromID(id);
|
||||
return new Location(dimID, pos.getX() * gridSize * 16, 0, pos.getZ() * gridSize * 16);
|
||||
public BlockPos idToPos(int id) {
|
||||
GridUtils.GridPos pos = idToGridPos(id);
|
||||
return new BlockPos(pos.getX() * gridSize * 16, 0, pos.getZ() * gridSize * 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the ID of a pocket based on the Location.
|
||||
* Calculates the ID of a pocket at a certain BlockPos.
|
||||
*
|
||||
* @param x The x coordinate of the player.
|
||||
* @param y The y coordinate of the player.
|
||||
* @param z The z coordinate of the player.
|
||||
* @param pos The position
|
||||
* @return The ID of the pocket, or -1 if there is no pocket at that location
|
||||
*/
|
||||
public int getIDFromLocation(int x, int y, int z) {
|
||||
int id = getIDFromGridPos(new GridUtils.GridPos(x / (gridSize * 16), z / (gridSize * 16)));
|
||||
return pockets.containsKey(id) ? id : -1;
|
||||
public int posToID(BlockPos pos) {
|
||||
return gridPosToID(new GridUtils.GridPos(pos.getX() / (gridSize * 16), pos.getZ() / (gridSize * 16)));
|
||||
}
|
||||
|
||||
public Pocket getPocketFromLocation(int x, int y, int z) { // TODO: use BlockPos
|
||||
return getPocket(getIDFromLocation(x, y, z));
|
||||
public Pocket getPocketAt(BlockPos pos) { // TODO: use BlockPos
|
||||
return getPocket(posToID(pos));
|
||||
}
|
||||
|
||||
public void allowPlayerAtLocation(EntityPlayer player, int x, int y, int z) {
|
||||
Pocket pocket = getPocketFromLocation(x, y, z);
|
||||
if (pocket != null) {
|
||||
pocket.allowPlayer(player);
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPlayerAllowedToBeHere(EntityPlayerMP player, int x, int y, int z) { // TODO see getLocationFromID
|
||||
int pocketID = getIDFromLocation(x, y, z);
|
||||
if (pocketID == -1) { // outside of a pocket
|
||||
return false;
|
||||
} else {
|
||||
Pocket pocket = pockets.get(pocketID);
|
||||
return pocket.isPlayerAllowedInPocket(player) && pocket.isLocationWithinPocketBounds(x, y, z, gridSize);
|
||||
}
|
||||
public boolean isPlayerAllowedToBeHere(EntityPlayerMP player, BlockPos pos) {
|
||||
Pocket pocket = getPocketAt(pos);
|
||||
return pocket != null && pocket.isInBounds(pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@ package com.zixiken.dimdoors.shared.rifts;
|
|||
import ddutils.nbt.INBTStorable;
|
||||
import ddutils.Location;
|
||||
import ddutils.nbt.NBTUtils;
|
||||
import lombok.*;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import lombok.*; // Don't change import order! (Gradle bug): https://stackoverflow.com/questions/26557133/
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -145,7 +145,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
}
|
||||
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
@Getter @AllArgsConstructor @Builder(toBuilder = true)
|
||||
public static class RelativeDestination extends RiftDestination { // TODO: use Vec3i
|
||||
private Vec3i offset;
|
||||
|
||||
|
@ -165,7 +165,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
@Getter @AllArgsConstructor @Builder(toBuilder = true)
|
||||
public static class LocalDestination extends RiftDestination { // TODO: use BlockPos
|
||||
private BlockPos pos;
|
||||
|
||||
|
@ -185,7 +185,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
@Getter @AllArgsConstructor @Builder(toBuilder = true)
|
||||
public static class GlobalDestination extends RiftDestination { // TODO: location directly in nbt like minecraft?
|
||||
private Location loc;
|
||||
|
||||
|
@ -205,7 +205,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
@Getter @AllArgsConstructor @Builder(toBuilder = true)
|
||||
public static class NewPublicDestination extends RiftDestination { // TODO: more config options such as non-default size, etc.
|
||||
//private NewPublicDestination() {}
|
||||
|
||||
|
@ -221,7 +221,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
@Getter @AllArgsConstructor @Builder(toBuilder = true)
|
||||
public static class PrivateDestination extends RiftDestination {
|
||||
|
||||
//private PrivateDestination() {}
|
||||
|
@ -238,7 +238,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
@Getter @AllArgsConstructor @Builder(toBuilder = true)
|
||||
public static class LimboDestination extends RiftDestination {
|
||||
|
||||
//private LimboDestination() {}
|
||||
|
@ -255,7 +255,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
@Getter @AllArgsConstructor @Builder(toBuilder = true)
|
||||
public static class AvailableLinkDestination extends RiftDestination { // TODO
|
||||
private float newDungeonRiftProbability;
|
||||
private float depthPenalization; // TODO: these make the equation assymetric
|
||||
|
@ -308,7 +308,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
@Getter @AllArgsConstructor @Builder(toBuilder = true)
|
||||
public static class PocketEntranceDestination extends RiftDestination {
|
||||
private float weight;
|
||||
@Builder.Default private List<WeightedRiftDestination> ifDestinations = new LinkedList<>(); // TODO addIfDestination method in builder
|
||||
|
@ -359,7 +359,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
@Getter @AllArgsConstructor @Builder(toBuilder = true)
|
||||
public static class PocketExitDestination extends RiftDestination {
|
||||
|
||||
//private PocketExitDestination() {}
|
||||
|
@ -376,7 +376,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
@Getter @AllArgsConstructor @Builder(toBuilder = true)
|
||||
public static class PrivatePocketExitDestination extends RiftDestination { // TODO: merge into PocketExit or Escape?
|
||||
|
||||
//private PrivatePocketExitDestination() {}
|
||||
|
@ -393,7 +393,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
@Getter @AllArgsConstructor @Builder(toBuilder = true)
|
||||
public static class EscapeDestination extends RiftDestination {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package com.zixiken.dimdoors.shared.rifts;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.shared.VirtualLocation;
|
||||
import com.zixiken.dimdoors.shared.rifts.RiftRegistry.RiftInfo.AvailableLinkInfo;
|
||||
import ddutils.nbt.INBTStorable;
|
||||
import ddutils.nbt.INBTStorable; // Don't change imports order! (Gradle bug): https://stackoverflow.com/questions/26557133/
|
||||
import ddutils.Location;
|
||||
import ddutils.WorldUtils;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Wither;
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.shared.VirtualLocation;
|
||||
import com.zixiken.dimdoors.shared.rifts.RiftRegistry.RiftInfo.AvailableLinkInfo;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
@ -30,8 +30,8 @@ public class RiftRegistry extends WorldSavedData {
|
|||
@Getter private int dim;
|
||||
private World world;
|
||||
|
||||
@lombok.AllArgsConstructor @lombok.EqualsAndHashCode @lombok.Builder(toBuilder = true)
|
||||
public static class RiftInfo implements ddutils.nbt.INBTStorable {
|
||||
@AllArgsConstructor @EqualsAndHashCode @Builder(toBuilder = true)
|
||||
public static class RiftInfo implements INBTStorable {
|
||||
@Builder.Default @Getter private Set<AvailableLinkInfo> availableLinks = new HashSet<>(); // ignore intellij warnings, builder needs these
|
||||
@Builder.Default @Getter private Set<Location> sources = new HashSet<>();
|
||||
@Builder.Default @Getter private Set<Location> destinations = new HashSet<>();
|
||||
|
@ -174,6 +174,7 @@ public class RiftRegistry extends WorldSavedData {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static boolean upgradeRegistry(NBTTagCompound nbt, int oldVersion) {
|
||||
if (oldVersion > DATA_VERSION) throw new RuntimeException("Upgrade the mod!"); // TODO: better exceptions
|
||||
switch (oldVersion) {
|
||||
|
|
|
@ -38,7 +38,7 @@ import java.util.*;
|
|||
public abstract class TileEntityRift extends TileEntity implements ITickable { // TODO: implement ITeleportSource and ITeleportDestination
|
||||
|
||||
@Getter protected VirtualLocation virtualLocation;
|
||||
@Nonnull @Getter protected List<WeightedRiftDestination> destinations;
|
||||
@Nonnull @Getter protected List<WeightedRiftDestination> destinations; // Not using a set because we can have duplicate destinations. Maybe use Multiset from Guava?
|
||||
@Getter protected boolean makeDestinationPermanent;
|
||||
@Getter protected boolean preserveRotation;
|
||||
@Getter protected float yaw;
|
||||
|
@ -244,11 +244,6 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
newPitch = pitch;
|
||||
}
|
||||
TeleportUtils.teleport(entity, new Location(world, pos), newPitch, newYaw);
|
||||
|
||||
int dim = WorldUtils.getDim(world);
|
||||
if (entity instanceof EntityPlayer && DimDoorDimensions.isPocketDimension(dim)) { // TODO
|
||||
PocketRegistry.getForDim(dim).allowPlayerAtLocation((EntityPlayer) entity, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean teleport(Entity entity) { try { // TODO: return failiure message string rather than boolean
|
||||
|
|
|
@ -97,11 +97,6 @@ public class TileEntityEntranceRift extends TileEntityRift {
|
|||
@Override
|
||||
public void teleportTo(Entity entity) {
|
||||
TeleportUtils.teleport(entity, new Location(world, pos.offset(orientation, tpOffset)), orientation.getHorizontalAngle(), 0);
|
||||
|
||||
int dim = WorldUtils.getDim(world);
|
||||
if (entity instanceof EntityPlayer && DimDoorDimensions.isPocketDimension(dim)) { // TODO
|
||||
PocketRegistry.getForDim(dim).allowPlayerAtLocation((EntityPlayer) entity, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
public RGBA getEntranceRenderColor(Random rand) { // TODO: custom color
|
||||
|
|
|
@ -154,7 +154,7 @@ public class PocketSchematicGenerator {
|
|||
schematic.tileEntities = new ArrayList<>();
|
||||
TileEntityRift rift = (TileEntityRift) doorBlock.createTileEntity(null, doorBlock.getDefaultState());
|
||||
rift.setSingleDestination(RiftDestination.PocketEntranceDestination.builder()
|
||||
.ifDestinations(MathUtils.listFrom(new WeightedRiftDestination(exitDest, 1, 0)))
|
||||
.ifDestinations(Collections.singletonList(new WeightedRiftDestination(exitDest, 1, 0)))
|
||||
.build());
|
||||
NBTTagCompound tileNBT = rift.serializeNBT();
|
||||
tileNBT.setInteger("x", (size - 1) / 2);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package ddutils;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
public class WorldUtils {
|
||||
public static World getWorld(int dim) {
|
||||
return DimensionManager.getWorld(dim);
|
||||
public static WorldServer getWorld(int dim) {
|
||||
return DimensionManager.getWorld(0).getMinecraftServer().getWorld(dim);
|
||||
}
|
||||
|
||||
public static int getDim(World world) {
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Random;
|
|||
* Allows the creation of indestructible air blocks that can have a TileEntity. Right clicks
|
||||
* on this block call the onBlockActivated method, and if it returns false, call the onBlockActivated
|
||||
* method of the block that would have been hit if the block wasn't there. Left clicks pass through the
|
||||
* block.
|
||||
* block (or maybe add an onLeftClick method).
|
||||
*/ // TODO
|
||||
public abstract class BlockSpecialAir extends Block { // TODO: make water and pistons pass through but not destroy
|
||||
|
||||
|
|
|
@ -42,5 +42,5 @@ public class GridUtils {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: add more modes, such as spiral, triangle, etc.?
|
||||
// TODO: add more modes: hexagonal sphere packing and maybe spiral, triangle
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ddutils.math;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -21,10 +19,4 @@ public class MathUtils {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> List<T> listFrom(T element) {
|
||||
List<T> list = new ArrayList<>();
|
||||
list.add(element);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue