Fix a few bugs

This commit is contained in:
Runemoro 2018-04-20 02:13:15 -04:00
parent 32f77b8b9d
commit 54d53a4568
9 changed files with 43 additions and 14 deletions

View file

@ -395,7 +395,7 @@ public class Schematic {
// CubicChunks makes cubic worlds implement ICubicWorld // CubicChunks makes cubic worlds implement ICubicWorld
// Just "world instanceof ICubicWorld" would throw a class not found error // Just "world instanceof ICubicWorld" would throw a class not found error
//noinspection InstanceofIncompatibleInterface //noinspection InstanceofIncompatibleInterface
if (cubicChunks && world instanceof ICubicWorld) { if (cubicChunks && ((ICubicWorld) world).isCubicWorld()) {
DimDoors.log.info("Setting cube blockstates"); DimDoors.log.info("Setting cube blockstates");
ICubicWorld cubicWorld = (ICubicWorld) world; ICubicWorld cubicWorld = (ICubicWorld) world;
for (int cubeX = 0; cubeX <= (width >> 4) + 1; cubeX++) { for (int cubeX = 0; cubeX <= (width >> 4) + 1; cubeX++) {

View file

@ -21,6 +21,7 @@ public class BlockDimensionalPortal extends BlockDimensionalDoor { // TODO: conv
public BlockDimensionalPortal() { public BlockDimensionalPortal() {
super(Material.PORTAL); // This is the only way to make it collide with water but not other entities, but still have a collision box. super(Material.PORTAL); // This is the only way to make it collide with water but not other entities, but still have a collision box.
setHardness(1.0F); setHardness(1.0F);
setLightLevel(0.5F);
setUnlocalizedName(ID); setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID)); setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
setDefaultState(super.getDefaultState().withProperty(OPEN, true)); setDefaultState(super.getDefaultState().withProperty(OPEN, true));

View file

@ -20,6 +20,7 @@ import net.minecraft.util.math.*;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import org.dimdev.dimdoors.shared.tileentities.TileEntityRift;
import java.util.List; import java.util.List;
@ -51,7 +52,7 @@ public class ItemRiftBlade extends ItemSword {
RayTraceResult hit = rayTrace(world, player, true); RayTraceResult hit = rayTrace(world, player, true);
if (world.isRemote) { if (world.isRemote) {
if (RayTraceHelper.isFloatingRift(hit, world) || RayTraceHelper.isLivingEntity(hit)) { if (RayTraceHelper.isRift(hit, world) || RayTraceHelper.isLivingEntity(hit)) {
return new ActionResult<>(EnumActionResult.SUCCESS, stack); return new ActionResult<>(EnumActionResult.SUCCESS, stack);
} else { } else {
player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".rift_miss"), true); player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".rift_miss"), true);
@ -60,8 +61,8 @@ public class ItemRiftBlade extends ItemSword {
} }
} }
if (RayTraceHelper.isFloatingRift(hit, world)) { if (RayTraceHelper.isRift(hit, world)) {
TileEntityFloatingRift rift = (TileEntityFloatingRift) world.getTileEntity(hit.getBlockPos()); TileEntityRift rift = (TileEntityRift) world.getTileEntity(hit.getBlockPos());
rift.teleport(player); rift.teleport(player);
stack.damageItem(1, player); stack.damageItem(1, player);

View file

@ -75,6 +75,7 @@ public class PocketTemplate {
rift.setPos(new BlockPos(x, y, z)); rift.setPos(new BlockPos(x, y, z));
rift.setProperties(DefaultDungeonDestinations.pocketLinkProperties); rift.setProperties(DefaultDungeonDestinations.pocketLinkProperties);
rift.setDestination(DefaultDungeonDestinations.deeperDungeonDestination); rift.setDestination(DefaultDungeonDestinations.deeperDungeonDestination);
rift.setLeaveRiftOnBreak(true);
newNBT = rift.serializeNBT(); newNBT = rift.serializeNBT();
break; break;
case "less_deep_depth_door": case "less_deep_depth_door":
@ -82,6 +83,7 @@ public class PocketTemplate {
rift.setPos(new BlockPos(x, y, z)); rift.setPos(new BlockPos(x, y, z));
rift.setProperties(DefaultDungeonDestinations.pocketLinkProperties); rift.setProperties(DefaultDungeonDestinations.pocketLinkProperties);
rift.setDestination(DefaultDungeonDestinations.shallowerDungeonDestination); rift.setDestination(DefaultDungeonDestinations.shallowerDungeonDestination);
rift.setLeaveRiftOnBreak(true);
newNBT = rift.serializeNBT(); newNBT = rift.serializeNBT();
break; break;
case "overworld_door": case "overworld_door":
@ -89,6 +91,7 @@ public class PocketTemplate {
rift.setPos(new BlockPos(x, y, z)); rift.setPos(new BlockPos(x, y, z));
rift.setProperties(DefaultDungeonDestinations.pocketLinkProperties); rift.setProperties(DefaultDungeonDestinations.pocketLinkProperties);
rift.setDestination(DefaultDungeonDestinations.overworldDestination); rift.setDestination(DefaultDungeonDestinations.overworldDestination);
rift.setLeaveRiftOnBreak(true);
newNBT = rift.serializeNBT(); newNBT = rift.serializeNBT();
break; break;
case "entrance_door": case "entrance_door":
@ -96,6 +99,7 @@ public class PocketTemplate {
rift.setPos(new BlockPos(x, y, z)); rift.setPos(new BlockPos(x, y, z));
rift.setProperties(DefaultDungeonDestinations.pocketLinkProperties); rift.setProperties(DefaultDungeonDestinations.pocketLinkProperties);
rift.setDestination(DefaultDungeonDestinations.twoWayPocketEntrance); rift.setDestination(DefaultDungeonDestinations.twoWayPocketEntrance);
rift.setLeaveRiftOnBreak(true);
newNBT = rift.serializeNBT(); newNBT = rift.serializeNBT();
break; break;
case "gateway_portal": case "gateway_portal":
@ -104,6 +108,7 @@ public class PocketTemplate {
rift.setProperties(DefaultDungeonDestinations.overworldLinkProperties); rift.setProperties(DefaultDungeonDestinations.overworldLinkProperties);
rift.setDestination(DefaultDungeonDestinations.gatewayDestination); rift.setDestination(DefaultDungeonDestinations.gatewayDestination);
rift.setCloseAfterPassThrough(true); rift.setCloseAfterPassThrough(true);
rift.setLeaveRiftOnBreak(true);
newNBT = rift.serializeNBT(); newNBT = rift.serializeNBT();
break; break;
default: default:

View file

@ -27,6 +27,7 @@ public class RiftRegistry extends WorldSavedData {
protected Map<Integer, RiftSubregistry> subregistries = new HashMap<>(); protected Map<Integer, RiftSubregistry> subregistries = new HashMap<>();
private static RiftRegistry riftRegistry = null; // For use by RiftSubregistry only private static RiftRegistry riftRegistry = null; // For use by RiftSubregistry only
private static int currentDim; // For use by RiftSubregistry only
protected DefaultDirectedGraph<RegistryVertex, DefaultEdge> graph = new DefaultDirectedGraph<>(DefaultEdge.class); protected DefaultDirectedGraph<RegistryVertex, DefaultEdge> graph = new DefaultDirectedGraph<>(DefaultEdge.class);
// TODO: add methods that automatically add vertices/edges and mark appropriate subregistries as dirty // TODO: add methods that automatically add vertices/edges and mark appropriate subregistries as dirty
@ -54,9 +55,8 @@ public class RiftRegistry extends WorldSavedData {
} }
@Override public void readFromNBT(NBTTagCompound nbt) { @Override public void readFromNBT(NBTTagCompound nbt) {
// Registry is already loaded dim = currentDim;
if (riftRegistry.subregistries.get(dim) != null) return; if (riftRegistry.subregistries.get(dim) != null) return;
if (riftRegistry == null) RiftRegistry.instance();
// Read rifts in this dimension // Read rifts in this dimension
NBTTagList riftsNBT = (NBTTagList) nbt.getTag("rifts"); NBTTagList riftsNBT = (NBTTagList) nbt.getTag("rifts");
@ -158,13 +158,14 @@ public class RiftRegistry extends WorldSavedData {
// Trigger the subregistry reading code for all dimensions. It would be better if there was some way of forcing // Trigger the subregistry reading code for all dimensions. It would be better if there was some way of forcing
// them to be read from somewhere else, since this is technically more than just reading the NBT and can cause // them to be read from somewhere else, since this is technically more than just reading the NBT and can cause
// problems with recursion without riftRegistry. This has to be done last since links are only // problems with recursion without riftRegistry. This has to be done first since links are only
// in the subregistries. // in the subregistries.
// TODO: If non-dirty but new WorldSavedDatas aren't automatically saved, then create the subregistries here // TODO: If non-dirty but new WorldSavedDatas aren't automatically saved, then create the subregistries here
// TODO: rather then in the markSubregistryDirty method. // TODO: rather then in the markSubregistryDirty method.
// TODO: try to get rid of this code: // TODO: try to get rid of this code:
for (int dim : DimensionManager.getStaticDimensionIDs()) { for (int dim : DimensionManager.getStaticDimensionIDs()) {
MapStorage storage = WorldUtils.getWorld(dim).getPerWorldStorage(); MapStorage storage = WorldUtils.getWorld(dim).getPerWorldStorage();
currentDim = dim;
RiftSubregistry instance = (RiftSubregistry) storage.getOrLoadData(RiftSubregistry.class, SUBREGISTRY_DATA_NAME); RiftSubregistry instance = (RiftSubregistry) storage.getOrLoadData(RiftSubregistry.class, SUBREGISTRY_DATA_NAME);
if (instance != null) { if (instance != null) {
instance.dim = dim; instance.dim = dim;
@ -430,7 +431,7 @@ public class RiftRegistry extends WorldSavedData {
} }
public void setLastPrivatePocketExit(UUID playerUUID, Location rift) { public void setLastPrivatePocketExit(UUID playerUUID, Location rift) {
DimDoors.log.info("Setting last used private pocket entrance for " + playerUUID + " at " + rift); DimDoors.log.info("Setting last used private pocket exit for " + playerUUID + " at " + rift);
setPlayerRiftPointer(playerUUID, rift, lastPrivatePocketExits); setPlayerRiftPointer(playerUUID, rift, lastPrivatePocketExits);
} }
@ -441,7 +442,7 @@ public class RiftRegistry extends WorldSavedData {
} }
public void setOverworldRift(UUID playerUUID, Location rift) { public void setOverworldRift(UUID playerUUID, Location rift) {
DimDoors.log.info("Setting last used private pocket entrance for " + playerUUID + " at " + rift); DimDoors.log.info("Setting last used overworld rift for " + playerUUID + " at " + rift);
setPlayerRiftPointer(playerUUID, rift, overworldRifts); setPlayerRiftPointer(playerUUID, rift, overworldRifts);
} }

View file

@ -1,7 +1,9 @@
package org.dimdev.dimdoors.shared.tileentities; package org.dimdev.dimdoors.shared.tileentities;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -19,6 +21,8 @@ import lombok.Getter;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import org.dimdev.dimdoors.shared.blocks.BlockDimensionalDoor;
import org.dimdev.dimdoors.shared.blocks.ModBlocks;
import java.util.Random; import java.util.Random;
@ -146,4 +150,14 @@ import java.util.Random;
public float getDestinationPitch(float entityPitch) { public float getDestinationPitch(float entityPitch) {
return 0; return 0;
} }
@SideOnly(Side.CLIENT)
@Override
public AxisAlignedBB getRenderBoundingBox() {
Block block = getBlockType();
if (block instanceof BlockDimensionalDoor) {
return new AxisAlignedBB(pos, pos.add(1, 2, 1));
}
return super.getRenderBoundingBox();
}
} }

View file

@ -225,4 +225,9 @@ import java.util.Random;
} }
return curve; return curve;
} }
@SideOnly(Side.CLIENT)
@Override
public AxisAlignedBB getRenderBoundingBox() {
return new AxisAlignedBB(pos.add(-50, -50, -50), pos.add(50, 50, 50));
}
} }

View file

@ -56,7 +56,9 @@ public class WorldProviderLimbo extends WorldProvider {
@Override @Override
public BlockPos getSpawnPoint() { public BlockPos getSpawnPoint() {
return getRandomizedSpawnPoint(); int x = MathHelper.clamp(world.rand.nextInt(), -500, 500);
int z = MathHelper.clamp(world.rand.nextInt(), -500, 500);
return new BlockPos(x, 700, z);
} }
@Override @Override

View file

@ -11,7 +11,7 @@ tile.quartz_dimensional_door.name=Quartz Dimensional Door
tile.unstable_dimensional_door.name=Unstable Dimensional Door tile.unstable_dimensional_door.name=Unstable Dimensional Door
tile.oak_dimensional_door.name=Oak Dimensional Door tile.oak_dimensional_door.name=Oak Dimensional Door
tile.dimensional_trapdoor.name=Oak Dimensional Trapdoor tile.dimensional_trapdoor.name=Oak Dimensional Trapdoor
tile.dimensional_portal.name=Transient Portal tile.dimensional_portal.name=Dimensional Portal
tile.fabric.black.name=Fabric of Reality tile.fabric.black.name=Fabric of Reality
tile.fabric.white.name=Altered Fabric tile.fabric.white.name=Altered Fabric
@ -165,13 +165,13 @@ dimdoors.pockets.loadAllSchematics.tooltip= When true, all available Pocket Sche
dimdoors.world=World Generation Settings dimdoors.world=World Generation Settings
dimdoors.world.tooltip=Settings that determine where dimensional gateways and rift clusters can be generated and at what frequency dimdoors.world.tooltip=Settings that determine where dimensional gateways and rift clusters can be generated and at what frequency
dimdoors.world.clusterGenChance=Cluster Generation Chance dimdoors.world.clusterGenChance=Cluster Generation Chance
dimdoors.world.clusterGenChance.tooltip=Sets the chance (out of 1.0) that a cluster of Rift Scars will generate in a given chunk. dimdoors.world.clusterGenChance.tooltip=Sets the chance (out of 1) that a cluster of rifts will generate in a given chunk.
dimdoors.world.gatewayGenChance=Gateway Generation Chance dimdoors.world.gatewayGenChance=Gateway Generation Chance
dimdoors.world.gatewayGenChance.tooltip=Sets the chance (out of 1.0) that a Transient Portal gateway will generate in a given chunk. dimdoors.world.gatewayGenChance.tooltip=Sets the chance (out of 1) that a dimensional gateway will generate in a given chunk.
dimdoors.world.clusterDimBlacklist=Cluster Dimension Blacklist dimdoors.world.clusterDimBlacklist=Cluster Dimension Blacklist
dimdoors.world.clusterDimBlacklist.tooltip=Dimension Blacklist for the generation of Rift Scar clusters. Add a dimension ID here to prevent generation in certain dimensions. dimdoors.world.clusterDimBlacklist.tooltip=Dimension Blacklist for the generation of Rift Scar clusters. Add a dimension ID here to prevent generation in certain dimensions.
dimdoors.world.gatewayDimBlacklist=Gateway Dimension Blacklist dimdoors.world.gatewayDimBlacklist=Gateway Dimension Blacklist
dimdoors.world.gatewayDimBlacklist.tooltip=Dimension Blacklist for the generation of Transient Portal gateways. Add a dimension ID here to prevent generation in certain dimensions. dimdoors.world.gatewayDimBlacklist.tooltip=Dimension Blacklist for the generation of Dimensional Portal gateways. Add a dimension ID here to prevent generation in certain dimensions.
dimdoors.dungeons=Dungeon Settings dimdoors.dungeons=Dungeon Settings
dimdoors.dungeons.tooltip=Settings that affect the generation of pocket dungeons dimdoors.dungeons.tooltip=Settings that affect the generation of pocket dungeons