Rift Connection Tool basic visuals
Cleaned up a lot of logging code Added a function to send chat messages to the player
This commit is contained in:
parent
a9fb3f5445
commit
5ebf7aab70
11 changed files with 50 additions and 42 deletions
|
@ -5,7 +5,9 @@ import com.zixiken.dimdoors.shared.PocketSavedData;
|
|||
import com.zixiken.dimdoors.shared.RiftRegistry;
|
||||
import com.zixiken.dimdoors.shared.RiftSavedData;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
@ -65,6 +67,10 @@ public class DimDoors {
|
|||
return proxy.getDefWorld(); //gets the server or client world dim 0 handler
|
||||
}
|
||||
|
||||
public static void chat(EntityPlayer player, String text) {
|
||||
player.sendMessage(new TextComponentString(text));
|
||||
}
|
||||
|
||||
public static void log(Class classFiredFrom, String text) {
|
||||
FMLLog.info("[DimDoors] " + text + " (" + classFiredFrom.toString() + " )", 0);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.zixiken.dimdoors;
|
|||
|
||||
import com.zixiken.dimdoors.blocks.ModBlocks;
|
||||
import com.zixiken.dimdoors.items.ModItems;
|
||||
import static com.zixiken.dimdoors.items.ModItems.itemRiftConnectionTool;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
|
@ -35,6 +36,7 @@ public class ModelManager {
|
|||
register(ModItems.itemDimDoorChaos);
|
||||
register(ModItems.itemDimDoorWarp);
|
||||
register(ModItems.itemWorldThread);
|
||||
register(ModItems.itemRiftConnectionTool);
|
||||
}
|
||||
|
||||
public static void registerModelVariants() {
|
||||
|
|
|
@ -41,8 +41,6 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT
|
|||
&& (entity.timeUntilPortal < 1) //to prevent the player from teleporting all over the place we have a 150-tick cooldown
|
||||
&& isEntityFacingDoor(down, (EntityLivingBase) entity)) {
|
||||
this.toggleDoor(world, pos, false);
|
||||
DimDoors.log(this.getClass(), "Facing direction of Door-block that was just entered by an entity is: "
|
||||
+ world.getBlockState(pos).getValue(BlockDoor.FACING));
|
||||
enterDimDoor(world, pos, entity);
|
||||
}
|
||||
}
|
||||
|
@ -123,12 +121,13 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT
|
|||
public void enterDimDoor(World world, BlockPos pos, Entity entity) {
|
||||
DDTileEntityBase riftTile = getRiftTile(world, pos, world.getBlockState(pos));
|
||||
if (riftTile.tryTeleport(entity)) {
|
||||
DimDoors.log(this.getClass(), "Entity was teleported succesfully");
|
||||
//player is succesfully teleported
|
||||
} else {
|
||||
DimDoors.log(this.getClass(), "Entity was NOT teleported succesfully");
|
||||
//@todo some kind of message that teleporting wasn't successfull
|
||||
//probably should only happen on personal dimdoors
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer entityPlayer = (EntityPlayer) entity;
|
||||
DimDoors.chat(entityPlayer, "[DimDoors:] Teleporting failed, please report this to the mod authors.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +159,6 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT
|
|||
world.setBlockState(pos, ModBlocks.blockRift.getDefaultState());
|
||||
DDTileEntityBase newRift = (DDTileEntityBase) world.getTileEntity(pos);
|
||||
newRift.loadDataFrom(origRift);
|
||||
DimDoors.log(this.getClass(), "New Rift rift-ID after breaking door " + newRift.getRiftID());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,17 +67,14 @@ public abstract class ItemDoorBase extends ItemDoor {
|
|||
}
|
||||
RayTraceResult hit = ItemDoorBase.doRayTrace(worldIn, playerIn, true);
|
||||
if (hit != null) {
|
||||
DimDoors.log(this.getClass(), "Raytrace hit is not null");
|
||||
BlockPos pos = hit.getBlockPos();
|
||||
if (worldIn.getBlockState(pos).getBlock() == ModBlocks.blockRift) {
|
||||
DimDoors.log(this.getClass(), "Raytrace hit Block is a BlockRift");
|
||||
EnumActionResult canDoorBePlacedOnGroundBelowRift
|
||||
= onItemUse(stack, playerIn, worldIn, pos.down(2), hand, EnumFacing.UP,
|
||||
(float) hit.hitVec.xCoord, (float) hit.hitVec.yCoord, (float) hit.hitVec.zCoord);
|
||||
return new ActionResult(canDoorBePlacedOnGroundBelowRift, stack);
|
||||
}
|
||||
}
|
||||
DimDoors.log(this.getClass(), "Raytrace hit is null, or doesn't hit a BlockRift");
|
||||
return new ActionResult(EnumActionResult.PASS, stack);
|
||||
}
|
||||
|
||||
|
@ -110,16 +107,9 @@ public abstract class ItemDoorBase extends ItemDoor {
|
|||
&& doorBlock.canPlaceBlockAt(worldIn, pos)) {
|
||||
|
||||
TileEntity possibleOldRift = worldIn.getTileEntity(pos.up());
|
||||
//start logging code
|
||||
if (possibleOldRift instanceof DDTileEntityBase) { //
|
||||
DDTileEntityBase oldRift = (DDTileEntityBase) possibleOldRift;
|
||||
DimDoors.log(this.getClass(), "Old Rift rift-ID before placement: " + oldRift.getRiftID());
|
||||
}
|
||||
//end of logging code
|
||||
EnumFacing enumfacing = EnumFacing.fromAngle((double) playerIn.rotationYaw);
|
||||
int i = enumfacing.getFrontOffsetX();
|
||||
int j = enumfacing.getFrontOffsetZ();
|
||||
DimDoors.log(this.getClass(), "Facing direction of door is being set to: " + enumfacing);
|
||||
boolean flag = i < 0 && hitZ < 0.5F || i > 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F;
|
||||
placeDoor(worldIn, pos, enumfacing, doorBlock, flag);
|
||||
SoundType soundtype = worldIn.getBlockState(pos).getBlock().getSoundType(worldIn.getBlockState(pos), worldIn, pos, playerIn);
|
||||
|
@ -129,14 +119,10 @@ public abstract class ItemDoorBase extends ItemDoor {
|
|||
DDTileEntityBase newTileEntityDimDoor = (DDTileEntityBase) worldIn.getTileEntity(pos.up());
|
||||
if (possibleOldRift instanceof DDTileEntityBase) { //
|
||||
DDTileEntityBase oldRift = (DDTileEntityBase) possibleOldRift;
|
||||
DimDoors.log(this.getClass(), "Old Rift rift-ID after placement: " + oldRift.getRiftID());
|
||||
newTileEntityDimDoor.loadDataFrom(oldRift);
|
||||
} else {
|
||||
newTileEntityDimDoor.register();
|
||||
}
|
||||
DimDoors.log(this.getClass(), "New Door rift-ID after placement: " + newTileEntityDimDoor.getRiftID());
|
||||
DimDoors.log(this.getClass(), "Facing direction of Door-block at pos of this Rift tile entity is: "
|
||||
+ newTileEntityDimDoor.getWorld().getBlockState(newTileEntityDimDoor.getPos()).getValue(BlockDimDoor.FACING));
|
||||
if (newTileEntityDimDoor instanceof TileEntityDimDoor) {
|
||||
TileEntityDimDoor tileEntityDimDoor = (TileEntityDimDoor) newTileEntityDimDoor;
|
||||
tileEntityDimDoor.orientation
|
||||
|
|
|
@ -54,38 +54,42 @@ public class ItemRiftConnectionTool extends ItemTool {
|
|||
return selectRift(stack, worldIn, rift, playerIn); //new ActionResult(EnumActionResult.PASS, stack));
|
||||
}
|
||||
} else {
|
||||
return changeMode(stack);
|
||||
return changeMode(stack, playerIn);
|
||||
}
|
||||
|
||||
return new ActionResult(EnumActionResult.FAIL, stack);
|
||||
}
|
||||
|
||||
private ActionResult<ItemStack> selectRift(ItemStack stack, World worldIn, DDTileEntityBase rift, EntityPlayer playerIn) {
|
||||
DimDoors.log(this.getClass(), "Selecting rift with ID: " + rift.getRiftID());
|
||||
NBTTagCompound compound = stack.getTagCompound();
|
||||
if (compound.getBoolean("isInConnectMode")) {
|
||||
if (compound.hasKey("RiftID")) {
|
||||
int primaryRiftID = compound.getInteger("RiftID");
|
||||
int secondaryRiftID = rift.getRiftID();
|
||||
if (!worldIn.isRemote) {
|
||||
DimDoors.log(this.getClass(), "Pairing rifts with IDs: " + primaryRiftID + " and " + secondaryRiftID);
|
||||
DimDoors.chat(playerIn, "Pairing rift " + primaryRiftID
|
||||
+ " with rift " + secondaryRiftID + ".");
|
||||
RiftRegistry.Instance.pair(primaryRiftID, secondaryRiftID);
|
||||
}
|
||||
compound.removeTag("RiftID");
|
||||
stack.damageItem(1, playerIn);
|
||||
} else {
|
||||
compound.setInteger("RiftID", rift.getRiftID());
|
||||
int riftID = rift.getRiftID();
|
||||
compound.setInteger("RiftID", riftID);
|
||||
DimDoors.chat(playerIn, "Rift " + riftID + " stored for connecting.");
|
||||
}
|
||||
} else {
|
||||
if (!worldIn.isRemote) {
|
||||
RiftRegistry.Instance.unpair(rift.getRiftID());
|
||||
int riftID = rift.getRiftID();
|
||||
RiftRegistry.Instance.unpair(riftID);
|
||||
DimDoors.chat(playerIn, "Rift " + riftID + " and its paired rift are now disconnected.");
|
||||
}
|
||||
stack.damageItem(1, playerIn);
|
||||
}
|
||||
return new ActionResult(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
|
||||
private ActionResult<ItemStack> changeMode(ItemStack stack) {
|
||||
private ActionResult<ItemStack> changeMode(ItemStack stack, EntityPlayer player) {
|
||||
NBTTagCompound compound = stack.getTagCompound();
|
||||
if (compound.getBoolean("isInConnectMode")) {
|
||||
compound.setBoolean("isInConnectMode", false);
|
||||
|
@ -95,7 +99,8 @@ public class ItemRiftConnectionTool extends ItemTool {
|
|||
} else {
|
||||
compound.setBoolean("isInConnectMode", true);
|
||||
}
|
||||
DimDoors.log(this.getClass(), "isInConnectMode set to: " + compound.getBoolean("isInConnectMode"));
|
||||
DimDoors.chat(player, "Connection tool mode set to: "
|
||||
+ (compound.getBoolean("isInConnectMode") ? "Connect" : "Disconnect"));
|
||||
return new ActionResult(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,6 @@ public class RiftRegistry {
|
|||
}
|
||||
|
||||
public Location getRiftLocation(int ID) {
|
||||
DimDoors.log(this.getClass(), "Fetching rift location of rift with ID: " + ID);
|
||||
return riftList.get(ID);
|
||||
}
|
||||
|
||||
|
@ -89,7 +88,6 @@ public class RiftRegistry {
|
|||
if (riftID < 0 || riftID2 < 0) {
|
||||
return;
|
||||
}
|
||||
DimDoors.log(this.getClass(), "pairing rift with ID " + riftID + " to rift with ID " + riftID2);
|
||||
Location location = riftList.get(riftID);
|
||||
TileEntity tileEntity = location.getTileEntity(); //@todo this method might need to be in another class?
|
||||
if (tileEntity != null && tileEntity instanceof DDTileEntityBase) {
|
||||
|
@ -104,7 +102,7 @@ public class RiftRegistry {
|
|||
}
|
||||
Location location = riftList.get(riftID);
|
||||
if (location == null) {
|
||||
DimDoors.log(this.getClass(), "riftID with null location = " + riftID);
|
||||
DimDoors.log(this.getClass(), "RiftID with null location = " + riftID);
|
||||
}
|
||||
TileEntity tileEntity = location.getTileEntity();
|
||||
if (tileEntity != null && tileEntity instanceof DDTileEntityBase) {
|
||||
|
|
|
@ -26,7 +26,7 @@ public class TeleportHelper extends Teleporter {
|
|||
|
||||
public static boolean teleport(Entity entity, Location newLocation) {
|
||||
if (entity instanceof EntityPlayerSP) {
|
||||
DimDoors.log(TeleportHelper.class, "Not teleporting, because EntityPlayerSP.");
|
||||
//DimDoors.log(TeleportHelper.class, "Not teleporting, because EntityPlayerSP.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -35,10 +35,10 @@ public class TeleportHelper extends Teleporter {
|
|||
int newDimID = newLocation.getDimensionID();
|
||||
WorldServer oldWorldServer = DimDoors.proxy.getWorldServer(oldDimID);
|
||||
WorldServer newWorldServer = DimDoors.proxy.getWorldServer(newDimID);
|
||||
DimDoors.log(TeleportHelper.class, "Starting teleporting now:");
|
||||
//DimDoors.log(TeleportHelper.class, "Starting teleporting now:");
|
||||
if (oldDimID == newDimID) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
DimDoors.log(TeleportHelper.class, "Using teleport method 1");
|
||||
//DimDoors.log(TeleportHelper.class, "Using teleport method 1");
|
||||
EntityPlayerMP player = (EntityPlayerMP) entity;
|
||||
|
||||
player.setPositionAndUpdate(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
||||
|
@ -46,7 +46,7 @@ public class TeleportHelper extends Teleporter {
|
|||
//player.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
|
||||
player.timeUntilPortal = 150;
|
||||
} else {
|
||||
DimDoors.log(TeleportHelper.class, "Using teleport method 2");
|
||||
//DimDoors.log(TeleportHelper.class, "Using teleport method 2");
|
||||
WorldServer world = (WorldServer) entity.world;
|
||||
|
||||
entity.setPosition(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
||||
|
@ -55,14 +55,14 @@ public class TeleportHelper extends Teleporter {
|
|||
}
|
||||
} else {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
DimDoors.log(TeleportHelper.class, "Using teleport method 3");
|
||||
//DimDoors.log(TeleportHelper.class, "Using teleport method 3");
|
||||
EntityPlayerMP player = (EntityPlayerMP) entity;
|
||||
player.changeDimension(newDimID); //@todo, this only works for Vanilla dimensions, I've heard?
|
||||
player.setPositionAndUpdate(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
||||
player.world.updateEntityWithOptionalForce(player, false);
|
||||
//player.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
|
||||
} else if (!entity.world.isRemote) {
|
||||
DimDoors.log(TeleportHelper.class, "Using teleport method 4");
|
||||
//DimDoors.log(TeleportHelper.class, "Using teleport method 4");
|
||||
entity.changeDimension(newDimID);
|
||||
entity.setPosition(newPos.getX() + 0.5, newPos.getY() + 0.5, newPos.getZ() + 0.5);
|
||||
oldWorldServer.resetUpdateEntityTick();
|
||||
|
|
|
@ -17,12 +17,6 @@ public abstract class DDTileEntityBase extends TileEntity {
|
|||
private int riftID = -1; //should not start at 0
|
||||
private int pairedRiftID = -1;
|
||||
|
||||
public DDTileEntityBase() {
|
||||
super();
|
||||
DimDoors.log(this.getClass(), "Printing stacktrace for debugging purposes:");
|
||||
Thread.dumpStack();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return an array of floats representing RGBA color where 1.0 = 255.
|
||||
|
|
|
@ -23,6 +23,7 @@ item.itemDimDoor.name=Dimensional Door
|
|||
item.itemDimDoorWarp.name=Warp Door
|
||||
item.itemLinkSignature.name=Rift Signature
|
||||
item.itemStabilizedRiftSig.name=Stabilized Rift Signature
|
||||
item.itemRiftConnectionTool.name=Below Average Rift Connection Tool
|
||||
item.itemRiftRemover.name=Rift Remover
|
||||
item.itemStableFabric.name=Stable Fabric
|
||||
item.itemChaosDoor.name=Unstable Door
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"parent": "builtin/generated",
|
||||
"textures": {
|
||||
"layer0": "dimdoors:items/itemRiftConnectionTool"
|
||||
},
|
||||
"display": {
|
||||
"thirdperson": {
|
||||
"rotation": [ -90, 0, 0 ],
|
||||
"translation": [ 0, 1, -3 ],
|
||||
"scale": [ 0.55, 0.55, 0.55 ]
|
||||
},
|
||||
"firstperson": {
|
||||
"rotation": [ 0, -135, 25 ],
|
||||
"translation": [ 0, 4, 2 ],
|
||||
"scale": [ 1.7, 1.7, 1.7 ]
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 360 B |
Loading…
Reference in a new issue