Skip to content

Commit

Permalink
Update paperweight 1.20.4 - isOpaque does not exist (anymore) (#2629)
Browse files Browse the repository at this point in the history
* chore/fix: update paperweight 1.20.4 - isOpaque does not exist (anymore)

* chore: update paperweight yet again (i feel scammed)

* chore: missing invert of canOcclude in isTranslucent
  • Loading branch information
PierreSchwang committed Mar 17, 2024
1 parent d2ca3ed commit b93f01c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts
Expand Up @@ -12,6 +12,6 @@ repositories {

dependencies {
// url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.4-R0.1-20240106.182028-62")
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.4-R0.1-20240316.193646-135")
compileOnly(libs.paperlib)
}
Expand Up @@ -2,26 +2,22 @@

import com.google.common.base.Suppliers;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.util.ReflectionUtil;
import com.sk89q.worldedit.bukkit.adapter.Refraction;
import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R3.nbt.PaperweightLazyCompoundTag;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.PushReaction;
import org.bukkit.craftbukkit.v1_20_R3.block.data.CraftBlockData;

public class PaperweightBlockMaterial implements BlockMaterial {

private final Block block;
private final BlockState blockState;
private final boolean isTranslucent;
private final CraftBlockData craftBlockData;
private final org.bukkit.Material craftMaterial;
private final int opacity;
Expand All @@ -36,11 +32,6 @@ public PaperweightBlockMaterial(Block block, BlockState blockState) {
this.blockState = blockState;
this.craftBlockData = CraftBlockData.fromData(blockState);
this.craftMaterial = craftBlockData.getMaterial();
BlockBehaviour.Properties blockInfo = ReflectionUtil.getField(BlockBehaviour.class, block,
Refraction.pickName("properties", "aP"));
this.isTranslucent = !(boolean) ReflectionUtil.getField(BlockBehaviour.Properties.class, blockInfo,
Refraction.pickName("canOcclude", "n")
);
opacity = blockState.getLightBlock(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
BlockEntity tileEntity = !(block instanceof EntityBlock) ? null : ((EntityBlock) block).newBlockEntity(
BlockPos.ZERO,
Expand Down Expand Up @@ -75,7 +66,7 @@ public boolean isFullCube() {

@Override
public boolean isOpaque() {
return blockState.isOpaque();
return blockState.canOcclude();
}

@Override
Expand All @@ -85,14 +76,13 @@ public boolean isPowerSource() {

@Override
public boolean isLiquid() {
// TODO: Better check ?
return block instanceof LiquidBlock;
return !blockState.getFluidState().is(Fluids.EMPTY);
}

@Override
public boolean isSolid() {
// TODO: Replace
return blockState.isSolid();
// No access to world -> EmptyBlockGetter
return blockState.isSolidRender(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
}

@Override
Expand Down Expand Up @@ -158,7 +148,7 @@ public boolean isReplacedDuringPlacement() {

@Override
public boolean isTranslucent() {
return isTranslucent;
return !blockState.canOcclude();
}

@Override
Expand Down

0 comments on commit b93f01c

Please sign in to comment.