Fixed placing doors on rifts
-Registered remaining TileEntities -Fixed Rifts being replaced by doors unregistering because they are being "broken"
This commit is contained in:
parent
f3abbc89b1
commit
9d4ed893a1
6 changed files with 27 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,6 +3,7 @@ build/
|
|||
.gradle/
|
||||
.idea/
|
||||
run/
|
||||
libs/
|
||||
out/
|
||||
*.iml
|
||||
*.ipr
|
||||
|
|
|
@ -4,8 +4,10 @@ import com.zixiken.dimdoors.shared.blocks.BlockDimDoorBase;
|
|||
import com.zixiken.dimdoors.shared.blocks.ModBlocks;
|
||||
import com.zixiken.dimdoors.shared.items.ModItems;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoor;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorChaos;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorGold;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorPersonal;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorWarp;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityRift;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityTransTrapdoor;
|
||||
import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
|
||||
|
@ -30,10 +32,11 @@ public abstract class DDProxyCommon implements IDDProxy {
|
|||
|
||||
GameRegistry.registerTileEntity(TileEntityDimDoor.class, "TileEntityDimDoor");
|
||||
GameRegistry.registerTileEntity(TileEntityRift.class, "TileEntityRift");
|
||||
GameRegistry.registerTileEntity(TileEntityTransTrapdoor.class, "TileEntityDimHatch");
|
||||
GameRegistry.registerTileEntity(TileEntityTransTrapdoor.class, "TileEntityTransTrapdoor");
|
||||
GameRegistry.registerTileEntity(TileEntityDimDoorGold.class, "TileEntityDimDoorGold");
|
||||
GameRegistry.registerTileEntity(TileEntityDimDoorPersonal.class, "TileEntityDimDoorPersonal");
|
||||
//@todo register other TileEntities
|
||||
GameRegistry.registerTileEntity(TileEntityDimDoorChaos.class, "TileEntityDimDoorChaos");
|
||||
GameRegistry.registerTileEntity(TileEntityDimDoorWarp.class, "TileEntityDimDoorWarp");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -374,7 +374,7 @@ public class RiftRegistry {
|
|||
Location destinationRiftLocation = getRiftLocation(riftId);
|
||||
DDTileEntityBase destinationRift = (DDTileEntityBase) destinationRiftLocation.getTileEntity();
|
||||
if (destinationRift == null) {
|
||||
DimDoors.warn(this.getClass(), "The rift that an entity is trying to teleport to seems to be null.");
|
||||
DimDoors.warn(this.getClass(), "The rift that an entity is trying to teleport to seems to be null. RiftID: " + riftId + ". Expecting to crash in 3... 2... 1..");
|
||||
}
|
||||
return destinationRift.getTeleportTargetLocation();
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ public class RiftRegistry {
|
|||
lastBrokenRift = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getPocketID(int riftID) {
|
||||
DDTileEntityBase rift = (DDTileEntityBase) rifts.get(riftID).getTileEntity();
|
||||
return rift.getPocketID();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.zixiken.dimdoors.shared.blocks;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.client.ClosingRiftFX;
|
||||
import com.zixiken.dimdoors.shared.RiftRegistry;
|
||||
import com.zixiken.dimdoors.shared.items.ModItems;
|
||||
|
@ -198,7 +199,14 @@ public class BlockRift extends Block implements ITileEntityProvider {
|
|||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state) {
|
||||
RiftRegistry.INSTANCE.unregisterLastChangedRift();
|
||||
TileEntityRift riftTile = (TileEntityRift) world.getTileEntity(pos);
|
||||
if (riftTile == null || !riftTile.placingDoorOnRift) {
|
||||
DimDoors.log(this.getClass(), "Unregistering rift at position " + pos.toString() + ", because it is destroyed (creative) or has closed.");
|
||||
RiftRegistry.INSTANCE.unregisterLastChangedRift();
|
||||
} else {
|
||||
DimDoors.log(this.getClass(), "Not unregistering rift at position " + pos.toString() + ", because it is being replaced by a door.");
|
||||
riftTile.placingDoorOnRift = false; //probably not needed, but it shouldn't hurt to do this
|
||||
}
|
||||
world.removeTileEntity(pos);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.zixiken.dimdoors.DimDoors;
|
|||
import com.zixiken.dimdoors.shared.blocks.BlockDimDoorBase;
|
||||
import com.zixiken.dimdoors.shared.RayTraceHelper;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoor;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityRift;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -67,6 +68,8 @@ public abstract class ItemDoorBase extends ItemDoor {
|
|||
return new ActionResult(canDoorBePlacedOnGroundBelowRift, stack);
|
||||
}
|
||||
return new ActionResult(EnumActionResult.FAIL, stack); //@todo, should return onItemUse(params) here? will door placement on block not work otherwise?
|
||||
|
||||
//@todo personal and chaos doors can be placed on top of a rift? Should not be possible
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -109,6 +112,10 @@ public abstract class ItemDoorBase extends ItemDoor {
|
|||
boolean flag = i < 0 && hitZ < 0.5F || i > 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F; //Vanilla Minecraft code not consistently using EnumFacing
|
||||
//fetch "the" tile entity at the top block of where the door is going to be placed
|
||||
TileEntity possibleOldRift = world.getTileEntity(pos.up());
|
||||
if (possibleOldRift != null && possibleOldRift instanceof TileEntityRift) {
|
||||
TileEntityRift oldRift = (TileEntityRift) possibleOldRift;
|
||||
oldRift.placingDoorOnRift = true;
|
||||
}
|
||||
//place the door
|
||||
placeDoor(world, pos, enumfacing, doorBlock, flag);
|
||||
SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, playerIn);
|
||||
|
|
|
@ -23,6 +23,8 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable {
|
|||
private static final int MAX_HOSTILE_ENDERMAN_CHANCE = 3;
|
||||
private static final int UPDATE_PERIOD = 200; //10 seconds
|
||||
|
||||
public boolean placingDoorOnRift = false; //to track whether a Rift is getting broken because it is replaced by a door (do not unregister in this case) or because it is being broken another way (do unregister in this case)
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
//Need to be saved:
|
||||
|
@ -35,7 +37,7 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable {
|
|||
|
||||
public TileEntityRift() {
|
||||
super();
|
||||
this.loadDataFrom(RiftRegistry.INSTANCE.getLastChangedRift());
|
||||
this.loadDataFrom(RiftRegistry.INSTANCE.getLastChangedRift()); //@todo this should absolutely not be done in this constructor...
|
||||
|
||||
// Vary the update times of rifts to prevent all the rifts in a cluster
|
||||
// from updating at the same time.
|
||||
|
|
Loading…
Reference in a new issue