mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Better skylight handling and fix opacity on materials
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user