geforkt von Mirrors/FastAsyncWorldEdit
Better skylight handling and fix opacity on materials
Dieser Commit ist enthalten in:
Ursprung
d6c9a887ac
Commit
3d2052b0c8
@ -3,6 +3,8 @@ package com.boydti.fawe.bukkit.adapter.mc1_14;
|
|||||||
import com.sk89q.util.ReflectionUtil;
|
import com.sk89q.util.ReflectionUtil;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
import net.minecraft.server.v1_14_R1.Block;
|
import net.minecraft.server.v1_14_R1.Block;
|
||||||
|
import net.minecraft.server.v1_14_R1.BlockAccessAir;
|
||||||
|
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||||
import net.minecraft.server.v1_14_R1.EnumPistonReaction;
|
import net.minecraft.server.v1_14_R1.EnumPistonReaction;
|
||||||
import net.minecraft.server.v1_14_R1.IBlockData;
|
import net.minecraft.server.v1_14_R1.IBlockData;
|
||||||
import net.minecraft.server.v1_14_R1.ITileEntity;
|
import net.minecraft.server.v1_14_R1.ITileEntity;
|
||||||
@ -16,6 +18,7 @@ public class BlockMaterial_1_14 implements BlockMaterial {
|
|||||||
private final boolean isTranslucent;
|
private final boolean isTranslucent;
|
||||||
private final CraftBlockData craftBlockData;
|
private final CraftBlockData craftBlockData;
|
||||||
private final org.bukkit.Material craftMaterial;
|
private final org.bukkit.Material craftMaterial;
|
||||||
|
private final int opacity;
|
||||||
|
|
||||||
public BlockMaterial_1_14(Block block) {
|
public BlockMaterial_1_14(Block block) {
|
||||||
this(block, block.getBlockData());
|
this(block, block.getBlockData());
|
||||||
@ -28,6 +31,7 @@ public class BlockMaterial_1_14 implements BlockMaterial {
|
|||||||
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
||||||
this.craftMaterial = craftBlockData.getMaterial();
|
this.craftMaterial = craftBlockData.getMaterial();
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getBlock() {
|
public Block getBlock() {
|
||||||
@ -98,7 +102,7 @@ public class BlockMaterial_1_14 implements BlockMaterial {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLightOpacity() {
|
public int getLightOpacity() {
|
||||||
return !isTranslucent() ? 15 : 0;
|
return opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,6 +12,7 @@ public class BlockMaterial_1_15_2 implements BlockMaterial {
|
|||||||
private final boolean isTranslucent;
|
private final boolean isTranslucent;
|
||||||
private final CraftBlockData craftBlockData;
|
private final CraftBlockData craftBlockData;
|
||||||
private final org.bukkit.Material craftMaterial;
|
private final org.bukkit.Material craftMaterial;
|
||||||
|
private final int opacity;
|
||||||
|
|
||||||
public BlockMaterial_1_15_2(Block block) {
|
public BlockMaterial_1_15_2(Block block) {
|
||||||
this(block, block.getBlockData());
|
this(block, block.getBlockData());
|
||||||
@ -24,6 +25,7 @@ public class BlockMaterial_1_15_2 implements BlockMaterial {
|
|||||||
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
||||||
this.craftMaterial = craftBlockData.getMaterial();
|
this.craftMaterial = craftBlockData.getMaterial();
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getBlock() {
|
public Block getBlock() {
|
||||||
@ -94,7 +96,7 @@ public class BlockMaterial_1_15_2 implements BlockMaterial {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLightOpacity() {
|
public int getLightOpacity() {
|
||||||
return !isTranslucent() ? 15 : 0;
|
return opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,6 +12,7 @@ public class BlockMaterial_1_16_1 implements BlockMaterial {
|
|||||||
private final boolean isTranslucent;
|
private final boolean isTranslucent;
|
||||||
private final CraftBlockData craftBlockData;
|
private final CraftBlockData craftBlockData;
|
||||||
private final org.bukkit.Material craftMaterial;
|
private final org.bukkit.Material craftMaterial;
|
||||||
|
private final int opacity;
|
||||||
|
|
||||||
public BlockMaterial_1_16_1(Block block) {
|
public BlockMaterial_1_16_1(Block block) {
|
||||||
this(block, block.getBlockData());
|
this(block, block.getBlockData());
|
||||||
@ -23,7 +24,9 @@ public class BlockMaterial_1_16_1 implements BlockMaterial {
|
|||||||
this.material = defaultState.getMaterial();
|
this.material = defaultState.getMaterial();
|
||||||
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
||||||
this.craftMaterial = craftBlockData.getMaterial();
|
this.craftMaterial = craftBlockData.getMaterial();
|
||||||
this.isTranslucent = !(boolean) ReflectionUtil.getField(Block.class, block, "at"); //TODO Update Mapping for 1.16.1
|
BlockBase.Info blockInfo = ReflectionUtil.getField(Block.class, block, "aB");
|
||||||
|
this.isTranslucent = !(boolean)ReflectionUtil.getField(BlockBase.Info.class, blockInfo, "n");
|
||||||
|
opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getBlock() {
|
public Block getBlock() {
|
||||||
@ -94,7 +97,7 @@ public class BlockMaterial_1_16_1 implements BlockMaterial {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLightOpacity() {
|
public int getLightOpacity() {
|
||||||
return !isTranslucent() ? 15 : 0;
|
return opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,6 +12,7 @@ public class BlockMaterial_1_16_2 implements BlockMaterial {
|
|||||||
private final boolean isTranslucent;
|
private final boolean isTranslucent;
|
||||||
private final CraftBlockData craftBlockData;
|
private final CraftBlockData craftBlockData;
|
||||||
private final org.bukkit.Material craftMaterial;
|
private final org.bukkit.Material craftMaterial;
|
||||||
|
private final int opacity;
|
||||||
|
|
||||||
public BlockMaterial_1_16_2(Block block) {
|
public BlockMaterial_1_16_2(Block block) {
|
||||||
this(block, block.getBlockData());
|
this(block, block.getBlockData());
|
||||||
@ -23,7 +24,9 @@ public class BlockMaterial_1_16_2 implements BlockMaterial {
|
|||||||
this.material = defaultState.getMaterial();
|
this.material = defaultState.getMaterial();
|
||||||
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
||||||
this.craftMaterial = craftBlockData.getMaterial();
|
this.craftMaterial = craftBlockData.getMaterial();
|
||||||
this.isTranslucent = !(boolean) ReflectionUtil.getField(Block.class, block, "at"); //TODO Update Mapping for 1.16.1
|
BlockBase.Info blockInfo = ReflectionUtil.getField(Block.class, block, "aB");
|
||||||
|
this.isTranslucent = !(boolean)ReflectionUtil.getField(BlockBase.Info.class, blockInfo, "n");
|
||||||
|
opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getBlock() {
|
public Block getBlock() {
|
||||||
@ -94,7 +97,7 @@ public class BlockMaterial_1_16_2 implements BlockMaterial {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLightOpacity() {
|
public int getLightOpacity() {
|
||||||
return !isTranslucent() ? 15 : 0;
|
return opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -110,8 +110,6 @@ public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements I
|
|||||||
public BlockMaterial getMaterial(BlockState state) {
|
public BlockMaterial getMaterial(BlockState state) {
|
||||||
IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState();
|
IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState();
|
||||||
return new BlockMaterial_1_16_2(bs.getBlock(), bs);
|
return new BlockMaterial_1_16_2(bs.getBlock(), bs);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getBlock(BlockType blockType) {
|
public Block getBlock(BlockType blockType) {
|
||||||
|
@ -5,17 +5,16 @@ import com.boydti.fawe.beta.IQueueExtent;
|
|||||||
import com.boydti.fawe.beta.implementation.chunk.ChunkHolder;
|
import com.boydti.fawe.beta.implementation.chunk.ChunkHolder;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.object.collection.BitArray;
|
|
||||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
|
import com.sk89q.worldedit.registry.state.BooleanProperty;
|
||||||
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
||||||
import com.sk89q.worldedit.registry.state.EnumProperty;
|
import com.sk89q.worldedit.registry.state.EnumProperty;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||||
@ -39,12 +38,14 @@ public class NMSRelighter implements Relighter {
|
|||||||
private static final EnumProperty stairHalf;
|
private static final EnumProperty stairHalf;
|
||||||
private static final EnumProperty stairShape;
|
private static final EnumProperty stairShape;
|
||||||
private static final EnumProperty slabHalf;
|
private static final EnumProperty slabHalf;
|
||||||
|
private static final BooleanProperty waterLogged;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
stairDirection = (DirectionalProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("facing");
|
stairDirection = (DirectionalProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("facing");
|
||||||
stairHalf = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("half");
|
stairHalf = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("half");
|
||||||
stairShape = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("shape");
|
stairShape = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("shape");
|
||||||
slabHalf = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_SLAB.getProperty("type");
|
slabHalf = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_SLAB.getProperty("type");
|
||||||
|
waterLogged = (BooleanProperty) (Property<?>) BlockTypes.SANDSTONE_SLAB.getProperty("waterlogged");
|
||||||
}
|
}
|
||||||
|
|
||||||
public final MutableBlockVector3 mutableBlockPos = new MutableBlockVector3(0, 0, 0);
|
public final MutableBlockVector3 mutableBlockPos = new MutableBlockVector3(0, 0, 0);
|
||||||
@ -801,7 +802,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
if (calculateHeightMaps && heightMaps != null) {
|
if (calculateHeightMaps && heightMaps != null) {
|
||||||
Map<HeightMapType, int[]> heightMapList = heightMaps.get(pair);
|
Map<HeightMapType, int[]> heightMapList = heightMaps.get(pair);
|
||||||
if (heightMapList != null) {
|
if (heightMapList != null) {
|
||||||
for (Map.Entry<HeightMapType, int[]> heightMapEntry : heightMapList.entrySet()){
|
for (Map.Entry<HeightMapType, int[]> heightMapEntry : heightMapList.entrySet()) {
|
||||||
chunk.setHeightMap(heightMapEntry.getKey(), heightMapEntry.getValue());
|
chunk.setHeightMap(heightMapEntry.getKey(), heightMapEntry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -933,11 +934,10 @@ public class NMSRelighter implements Relighter {
|
|||||||
int x = j & 15;
|
int x = j & 15;
|
||||||
int z = j >> 4;
|
int z = j >> 4;
|
||||||
byte value = mask[j];
|
byte value = mask[j];
|
||||||
BlockType type = iChunk.getBlock(x, y, z).getBlockType();
|
BlockState state = iChunk.getBlock(x, y, z);
|
||||||
BlockMaterial material = type.getMaterial();
|
BlockMaterial material = state.getMaterial();
|
||||||
int opacity = material.getLightOpacity();
|
int opacity = material.getLightOpacity();
|
||||||
int brightness = iChunk.getBrightness(x, y, z);
|
int brightness = material.getLightValue();
|
||||||
boolean solidNeedsLight = (!material.isSolid() || !material.isFullCube()) && material.getLightOpacity() > 0;
|
|
||||||
if (brightness > 1) {
|
if (brightness > 1) {
|
||||||
addLightUpdate(bx + x, y, bz + z);
|
addLightUpdate(bx + x, y, bz + z);
|
||||||
}
|
}
|
||||||
@ -950,11 +950,11 @@ public class NMSRelighter implements Relighter {
|
|||||||
if (heightMapList.get(HeightMapType.OCEAN_FLOOR)[j] == 0 && material.isSolid()) {
|
if (heightMapList.get(HeightMapType.OCEAN_FLOOR)[j] == 0 && material.isSolid()) {
|
||||||
heightMapList.get(HeightMapType.OCEAN_FLOOR)[j] = y + 1;
|
heightMapList.get(HeightMapType.OCEAN_FLOOR)[j] = y + 1;
|
||||||
}
|
}
|
||||||
if (heightMapList.get(HeightMapType.MOTION_BLOCKING)[j] == 0 && (material.isSolid() || material.isLiquid())) {
|
if (heightMapList.get(HeightMapType.MOTION_BLOCKING)[j] == 0 && (material.isSolid() || material.isLiquid() || state.getState(waterLogged))) {
|
||||||
heightMapList.get(HeightMapType.MOTION_BLOCKING)[j] = y + 1;
|
heightMapList.get(HeightMapType.MOTION_BLOCKING)[j] = y + 1;
|
||||||
}
|
}
|
||||||
if (heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] == 0 && (material.isSolid() || material.isLiquid()) && !type
|
if (heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] == 0 && (material.isSolid() || material.isLiquid() || state
|
||||||
.getId().toLowerCase().contains("leaves")) {
|
.getState(waterLogged)) && !state.getBlockType().getId().toLowerCase().contains("leaves")) {
|
||||||
heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] = y + 1;
|
heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] = y + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -982,7 +982,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
case 14:
|
case 14:
|
||||||
if (opacity >= value) {
|
if (opacity >= value) {
|
||||||
mask[j] = 0;
|
mask[j] = 0;
|
||||||
if (solidNeedsLight) {
|
if (!isStairOrTrueTop(state, true) || !(isSlabOrTrueValue(state, "top") || isSlabOrTrueValue(state, "double"))) {
|
||||||
iChunk.setSkyLight(x, y, z, value);
|
iChunk.setSkyLight(x, y, z, value);
|
||||||
} else {
|
} else {
|
||||||
iChunk.setSkyLight(x, y, z, 0);
|
iChunk.setSkyLight(x, y, z, 0);
|
||||||
@ -996,11 +996,11 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
if (opacity > 1) {
|
if (opacity > 0) {
|
||||||
value -= opacity;
|
value -= opacity;
|
||||||
mask[j] = value;
|
mask[j] = value;
|
||||||
}
|
}
|
||||||
if (solidNeedsLight) {
|
if (!isStairOrTrueTop(state, true) || !(isSlabOrTrueValue(state, "top") || isSlabOrTrueValue(state, "double"))) {
|
||||||
iChunk.setSkyLight(x, y, z, value + opacity);
|
iChunk.setSkyLight(x, y, z, value + opacity);
|
||||||
} else {
|
} else {
|
||||||
iChunk.setSkyLight(x, y, z, value);
|
iChunk.setSkyLight(x, y, z, value);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren