3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 02:50:06 +01:00

Add null check to creating default NBT data

Dieser Commit ist enthalten in:
dordsor21 2021-06-10 19:59:17 +01:00
Ursprung 717a1b5db4
Commit f6c87b6726
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
6 geänderte Dateien mit 13 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -39,7 +39,7 @@ public class BlockMaterial_1_15_2 implements BlockMaterial {
this.isTranslucent = !(boolean) ReflectionUtil.getField(Block.class, block, "v"); this.isTranslucent = !(boolean) ReflectionUtil.getField(Block.class, block, "v");
opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO); opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO);
TileEntity tileEntity = !block.isTileEntity() ? null : ((ITileEntity)block).createTile(null); TileEntity tileEntity = !block.isTileEntity() ? null : ((ITileEntity)block).createTile(null);
tile = new LazyCompoundTag_1_15_2(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); tile = tileEntity == null ? null : new LazyCompoundTag_1_15_2(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
} }
public Block getBlock() { public Block getBlock() {

Datei anzeigen

@ -41,7 +41,7 @@ public class BlockMaterial_1_16_1 implements BlockMaterial {
this.isTranslucent = !(boolean)ReflectionUtil.getField(BlockBase.Info.class, blockInfo, "n"); this.isTranslucent = !(boolean)ReflectionUtil.getField(BlockBase.Info.class, blockInfo, "n");
opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO); opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO);
TileEntity tileEntity = !block.isTileEntity() ? null : ((ITileEntity)block).createTile(null); TileEntity tileEntity = !block.isTileEntity() ? null : ((ITileEntity)block).createTile(null);
tile = new LazyCompoundTag_1_16_1(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); tile = tileEntity == null ? null : new LazyCompoundTag_1_16_1(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
} }
public Block getBlock() { public Block getBlock() {

Datei anzeigen

@ -41,7 +41,7 @@ public class BlockMaterial_1_16_2 implements BlockMaterial {
this.isTranslucent = !(boolean)ReflectionUtil.getField(BlockBase.Info.class, blockInfo, "n"); this.isTranslucent = !(boolean)ReflectionUtil.getField(BlockBase.Info.class, blockInfo, "n");
opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO); opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO);
TileEntity tileEntity = !block.isTileEntity() ? null : ((ITileEntity)block).createTile(null); TileEntity tileEntity = !block.isTileEntity() ? null : ((ITileEntity)block).createTile(null);
tile = new LazyCompoundTag_1_16_2(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); tile = tileEntity == null ? null : new LazyCompoundTag_1_16_2(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
} }
public Block getBlock() { public Block getBlock() {

Datei anzeigen

@ -41,7 +41,7 @@ public class BlockMaterial_1_16_5 implements BlockMaterial {
this.isTranslucent = !(boolean)ReflectionUtil.getField(BlockBase.Info.class, blockInfo, "n"); this.isTranslucent = !(boolean)ReflectionUtil.getField(BlockBase.Info.class, blockInfo, "n");
opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO); opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO);
TileEntity tileEntity = !block.isTileEntity() ? null : ((ITileEntity)block).createTile(null); TileEntity tileEntity = !block.isTileEntity() ? null : ((ITileEntity)block).createTile(null);
tile = new LazyCompoundTag_1_16_5(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); tile = tileEntity == null ? null : new LazyCompoundTag_1_16_5(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
} }
public Block getBlock() { public Block getBlock() {

Datei anzeigen

@ -2,6 +2,7 @@ package com.sk89q.worldedit.world.block;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.google.common.primitives.Booleans; import com.google.common.primitives.Booleans;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
@ -98,7 +99,9 @@ public class BlockTypesCache {
int ordinal = this.stateOrdinals[propId]; int ordinal = this.stateOrdinals[propId];
if (ordinal != -1) { if (ordinal != -1) {
int stateId = internalId + (propId << BIT_OFFSET); int stateId = internalId + (propId << BIT_OFFSET);
BlockState state = new BlockState(type, stateId, ordinal, blockMaterial.getDefaultTile()); CompoundTag defaultNBT = blockMaterial.getDefaultTile();
BlockState state = defaultNBT != null ? new BlockState(type, stateId, ordinal, blockMaterial.getDefaultTile()) :
new BlockState(type, stateId, ordinal);
states.add(state); states.add(state);
} }
} }
@ -106,7 +109,9 @@ public class BlockTypesCache {
this.defaultState = states.get(this.stateOrdinals[defaultPropId]); this.defaultState = states.get(this.stateOrdinals[defaultPropId]);
} else { } else {
this.defaultState = new BlockState(type, internalId, states.size(), blockMaterial.getDefaultTile()); CompoundTag defaultNBT = blockMaterial.getDefaultTile();
this.defaultState = defaultNBT != null ? new BlockState(type, internalId, states.size(), blockMaterial.getDefaultTile()) :
new BlockState(type, internalId, states.size());
states.add(this.defaultState); states.add(this.defaultState);
} }
} }

Datei anzeigen

@ -20,6 +20,7 @@
package com.sk89q.worldedit.world.registry; package com.sk89q.worldedit.world.registry;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import org.jetbrains.annotations.Nullable;
/** /**
* Describes the material for a block. * Describes the material for a block.
@ -179,6 +180,7 @@ public interface BlockMaterial {
* *
* @return default tile entity data * @return default tile entity data
*/ */
@Nullable
CompoundTag getDefaultTile(); CompoundTag getDefaultTile();
/** /**