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.worldedit.world.registry.BlockMaterial;
|
||||
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.IBlockData;
|
||||
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 CraftBlockData craftBlockData;
|
||||
private final org.bukkit.Material craftMaterial;
|
||||
private final int opacity;
|
||||
|
||||
public BlockMaterial_1_14(Block block) {
|
||||
this(block, block.getBlockData());
|
||||
@ -28,6 +31,7 @@ public class BlockMaterial_1_14 implements BlockMaterial {
|
||||
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
||||
this.craftMaterial = craftBlockData.getMaterial();
|
||||
this.isTranslucent = !(boolean) ReflectionUtil.getField(Block.class, block, "v");
|
||||
opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO);
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
@ -98,7 +102,7 @@ public class BlockMaterial_1_14 implements BlockMaterial {
|
||||
|
||||
@Override
|
||||
public int getLightOpacity() {
|
||||
return !isTranslucent() ? 15 : 0;
|
||||
return opacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,6 +12,7 @@ public class BlockMaterial_1_15_2 implements BlockMaterial {
|
||||
private final boolean isTranslucent;
|
||||
private final CraftBlockData craftBlockData;
|
||||
private final org.bukkit.Material craftMaterial;
|
||||
private final int opacity;
|
||||
|
||||
public BlockMaterial_1_15_2(Block block) {
|
||||
this(block, block.getBlockData());
|
||||
@ -24,6 +25,7 @@ public class BlockMaterial_1_15_2 implements BlockMaterial {
|
||||
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
||||
this.craftMaterial = craftBlockData.getMaterial();
|
||||
this.isTranslucent = !(boolean) ReflectionUtil.getField(Block.class, block, "v");
|
||||
opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO);
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
@ -94,7 +96,7 @@ public class BlockMaterial_1_15_2 implements BlockMaterial {
|
||||
|
||||
@Override
|
||||
public int getLightOpacity() {
|
||||
return !isTranslucent() ? 15 : 0;
|
||||
return opacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,6 +12,7 @@ public class BlockMaterial_1_16_1 implements BlockMaterial {
|
||||
private final boolean isTranslucent;
|
||||
private final CraftBlockData craftBlockData;
|
||||
private final org.bukkit.Material craftMaterial;
|
||||
private final int opacity;
|
||||
|
||||
public BlockMaterial_1_16_1(Block block) {
|
||||
this(block, block.getBlockData());
|
||||
@ -23,7 +24,9 @@ public class BlockMaterial_1_16_1 implements BlockMaterial {
|
||||
this.material = defaultState.getMaterial();
|
||||
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
||||
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() {
|
||||
@ -94,7 +97,7 @@ public class BlockMaterial_1_16_1 implements BlockMaterial {
|
||||
|
||||
@Override
|
||||
public int getLightOpacity() {
|
||||
return !isTranslucent() ? 15 : 0;
|
||||
return opacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,6 +12,7 @@ public class BlockMaterial_1_16_2 implements BlockMaterial {
|
||||
private final boolean isTranslucent;
|
||||
private final CraftBlockData craftBlockData;
|
||||
private final org.bukkit.Material craftMaterial;
|
||||
private final int opacity;
|
||||
|
||||
public BlockMaterial_1_16_2(Block block) {
|
||||
this(block, block.getBlockData());
|
||||
@ -23,7 +24,9 @@ public class BlockMaterial_1_16_2 implements BlockMaterial {
|
||||
this.material = defaultState.getMaterial();
|
||||
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
||||
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() {
|
||||
@ -94,7 +97,7 @@ public class BlockMaterial_1_16_2 implements BlockMaterial {
|
||||
|
||||
@Override
|
||||
public int getLightOpacity() {
|
||||
return !isTranslucent() ? 15 : 0;
|
||||
return opacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -110,8 +110,6 @@ public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements I
|
||||
public BlockMaterial getMaterial(BlockState state) {
|
||||
IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState();
|
||||
return new BlockMaterial_1_16_2(bs.getBlock(), bs);
|
||||
|
||||
|
||||
}
|
||||
|
||||
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.config.Settings;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.object.collection.BitArray;
|
||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
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.EnumProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
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.registry.BlockMaterial;
|
||||
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 stairShape;
|
||||
private static final EnumProperty slabHalf;
|
||||
private static final BooleanProperty waterLogged;
|
||||
|
||||
static {
|
||||
stairDirection = (DirectionalProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("facing");
|
||||
stairHalf = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("half");
|
||||
stairShape = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("shape");
|
||||
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);
|
||||
@ -933,11 +934,10 @@ public class NMSRelighter implements Relighter {
|
||||
int x = j & 15;
|
||||
int z = j >> 4;
|
||||
byte value = mask[j];
|
||||
BlockType type = iChunk.getBlock(x, y, z).getBlockType();
|
||||
BlockMaterial material = type.getMaterial();
|
||||
BlockState state = iChunk.getBlock(x, y, z);
|
||||
BlockMaterial material = state.getMaterial();
|
||||
int opacity = material.getLightOpacity();
|
||||
int brightness = iChunk.getBrightness(x, y, z);
|
||||
boolean solidNeedsLight = (!material.isSolid() || !material.isFullCube()) && material.getLightOpacity() > 0;
|
||||
int brightness = material.getLightValue();
|
||||
if (brightness > 1) {
|
||||
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()) {
|
||||
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;
|
||||
}
|
||||
if (heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] == 0 && (material.isSolid() || material.isLiquid()) && !type
|
||||
.getId().toLowerCase().contains("leaves")) {
|
||||
if (heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] == 0 && (material.isSolid() || material.isLiquid() || state
|
||||
.getState(waterLogged)) && !state.getBlockType().getId().toLowerCase().contains("leaves")) {
|
||||
heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] = y + 1;
|
||||
}
|
||||
}
|
||||
@ -982,7 +982,7 @@ public class NMSRelighter implements Relighter {
|
||||
case 14:
|
||||
if (opacity >= value) {
|
||||
mask[j] = 0;
|
||||
if (solidNeedsLight) {
|
||||
if (!isStairOrTrueTop(state, true) || !(isSlabOrTrueValue(state, "top") || isSlabOrTrueValue(state, "double"))) {
|
||||
iChunk.setSkyLight(x, y, z, value);
|
||||
} else {
|
||||
iChunk.setSkyLight(x, y, z, 0);
|
||||
@ -996,11 +996,11 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
if (opacity > 1) {
|
||||
if (opacity > 0) {
|
||||
value -= opacity;
|
||||
mask[j] = value;
|
||||
}
|
||||
if (solidNeedsLight) {
|
||||
if (!isStairOrTrueTop(state, true) || !(isSlabOrTrueValue(state, "top") || isSlabOrTrueValue(state, "double"))) {
|
||||
iChunk.setSkyLight(x, y, z, value + opacity);
|
||||
} else {
|
||||
iChunk.setSkyLight(x, y, z, value);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren