• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

First Machine Age's Mods (Combined repo.)


Commit MetaInfo

修订版e00a7319a14c585230ff0838eb39aa5cf1778199 (tree)
时间2020-05-05 09:04:57
作者melchior <melchior@user...>
Commitermelchior

Log Message

Fix for B.E. null on absence in world crash,
boudning box for slot

更改概述

差异

--- a/Assorted/AssortedModLoader.cs
+++ b/Assorted/AssortedModLoader.cs
@@ -14,6 +14,8 @@ namespace FirstMachineAge
1414 private ICoreServerAPI ServerAPI;
1515 private ServerCoreAPI ServerCore { get; set; }
1616
17+ public const string BoltableDoorEntityNameKey = @"BoltableDoorEntity";
18+
1719 public override bool AllowRuntimeReload {
1820 get { return false; }
1921 }
@@ -57,7 +59,7 @@ namespace FirstMachineAge
5759 private void RegisterBlockClasses( )
5860 {
5961 CoreAPI.RegisterBlockClass("BoltableDoor", typeof(BoltableDoor));
60- CoreAPI.RegisterBlockEntityClass("BoltableDoorEntity", typeof(BoltableDoorBlockEntity));
62+ CoreAPI.RegisterBlockEntityClass(BoltableDoorEntityNameKey, typeof(BoltableDoorBlockEntity));
6163 }
6264
6365 private void RegisterBehaviorClasses( )
--- a/Assorted/BlockClasses/BoltableDoor.cs
+++ b/Assorted/BlockClasses/BoltableDoor.cs
@@ -28,7 +28,14 @@ namespace FirstMachineAge
2828 upperPos = here.UpCopy( );
2929 }
3030
31- return api.World.BlockAccessor.GetBlockEntity(upperPos) as BoltableDoorBlockEntity;
31+ var doorEntity = api.World.BlockAccessor.GetBlockEntity(upperPos) as BoltableDoorBlockEntity;
32+
33+ if (doorEntity == null) {
34+ api.World.Logger.Warning($"BoltableDoor [{here}]: BlockEntity NULL! (regenerating)" );
35+ api.World.BlockAccessor.SpawnBlockEntity(AssortedModSystems.BoltableDoorEntityNameKey, here);
36+ }
37+
38+ return doorEntity;
3239 }
3340
3441 public override BlockFacing GetDirection( )
@@ -51,9 +58,13 @@ namespace FirstMachineAge
5158 if (!this.DoesBehaviorAllow(world, byPlayer, selBox)) {
5259 return true;
5360 }
61+
5462 BlockPos position = selBox.Position;
5563 var doorEntity = this.Entity(position);
5664 var clientPlayer = byPlayer as IClientPlayer;
65+
66+ if (doorEntity == null) return false;//Corrupted world!
67+
5768 if (selBox.SelectionBoxIndex == 0)
5869 {
5970 if (doorEntity.Bolted == false)
--- a/Assorted/BlockEntityClasses/BoltableDoorBlockEntity.cs
+++ b/Assorted/BlockEntityClasses/BoltableDoorBlockEntity.cs
@@ -41,8 +41,7 @@ namespace FirstMachineAge
4141 public override void GetBlockInfo(IPlayer forPlayer, StringBuilder dsc)
4242 {
4343 base.GetBlockInfo(forPlayer, dsc);
44- var boltableDoor = this.Block as BoltableDoor;
45- BoltableDoorBlockEntity realEntity = boltableDoor.Entity(this.Pos.Copy( ));
44+ BoltableDoorBlockEntity realEntity = (this.Block as BoltableDoor).Entity(this.Pos.Copy( ));
4645 if (realEntity != null) dsc.AppendLine($"Bolted: {(realEntity.Bolted?"<font color='red'>Yes</font>":"No")}");
4746 }
4847 }