Skip to content

Commit 62a7e6e

Browse files
committed
Add post-merge changes
1 parent 7539714 commit 62a7e6e

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

worldedit-bukkit/adapters/adapter-1.21.9/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_21_9/PaperweightAdapter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import com.sk89q.worldedit.world.generation.ConfiguredFeatureType;
7171
import com.sk89q.worldedit.world.generation.StructureType;
7272
import com.sk89q.worldedit.world.item.ItemType;
73+
import com.sk89q.worldedit.world.registry.BlockMaterial;
7374
import net.minecraft.SharedConstants;
7475
import net.minecraft.Util;
7576
import net.minecraft.core.BlockPos;
@@ -564,6 +565,12 @@ public Component getRichItemName(BaseItemStack itemStack) {
564565
);
565566
}
566567

568+
@Override
569+
public BlockMaterial getBlockMaterial(BlockType blockType) {
570+
net.minecraft.world.level.block.state.BlockState mcBlockState = getBlockFromType(blockType).defaultBlockState();
571+
return new PaperweightBlockMaterial(mcBlockState);
572+
}
573+
567574
@SuppressWarnings({ "unchecked", "rawtypes" })
568575
private static final LoadingCache<net.minecraft.world.level.block.state.properties.Property, Property<?>> PROPERTY_CACHE = CacheBuilder.newBuilder().build(new CacheLoader<>() {
569576
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/*
2+
* WorldEdit, a Minecraft world manipulation toolkit
3+
* Copyright (C) sk89q <http://www.sk89q.com>
4+
* Copyright (C) WorldEdit team and contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
package com.sk89q.worldedit.bukkit.adapter.impl.v1_21_9;
21+
22+
import com.sk89q.worldedit.world.registry.BlockMaterial;
23+
import net.minecraft.core.BlockPos;
24+
import net.minecraft.world.Clearable;
25+
import net.minecraft.world.level.EmptyBlockGetter;
26+
import net.minecraft.world.level.block.Block;
27+
import net.minecraft.world.level.block.EntityBlock;
28+
import net.minecraft.world.level.block.state.BlockState;
29+
import net.minecraft.world.level.material.PushReaction;
30+
31+
public class PaperweightBlockMaterial implements BlockMaterial {
32+
33+
private final BlockState block;
34+
35+
public PaperweightBlockMaterial(BlockState block) {
36+
this.block = block;
37+
}
38+
39+
@Override
40+
public boolean isAir() {
41+
return block.isAir();
42+
}
43+
44+
@Override
45+
public boolean isFullCube() {
46+
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
47+
}
48+
49+
@Override
50+
public boolean isOpaque() {
51+
return block.canOcclude();
52+
}
53+
54+
@Override
55+
public boolean isPowerSource() {
56+
return block.isSignalSource();
57+
}
58+
59+
@Override
60+
@SuppressWarnings("deprecation")
61+
public boolean isLiquid() {
62+
return block.liquid();
63+
}
64+
65+
@Override
66+
@SuppressWarnings("deprecation")
67+
public boolean isSolid() {
68+
return block.isSolid();
69+
}
70+
71+
@Override
72+
public float getHardness() {
73+
return block.getDestroySpeed(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
74+
}
75+
76+
@Override
77+
@SuppressWarnings("deprecation")
78+
public float getResistance() {
79+
return block.getBlock().getExplosionResistance();
80+
}
81+
82+
@Override
83+
public float getSlipperiness() {
84+
return block.getBlock().getFriction();
85+
}
86+
87+
@Override
88+
@SuppressWarnings("deprecation")
89+
public int getLightValue() {
90+
return block.getLightEmission();
91+
}
92+
93+
@Override
94+
public boolean isFragileWhenPushed() {
95+
return block.getPistonPushReaction() == PushReaction.DESTROY;
96+
}
97+
98+
@Override
99+
public boolean isUnpushable() {
100+
return block.getPistonPushReaction() == PushReaction.BLOCK;
101+
}
102+
103+
@Override
104+
public boolean isTicksRandomly() {
105+
return block.isRandomlyTicking();
106+
}
107+
108+
@Override
109+
@SuppressWarnings("deprecation")
110+
public boolean isMovementBlocker() {
111+
return block.blocksMotion();
112+
}
113+
114+
@Override
115+
public boolean isBurnable() {
116+
return block.ignitedByLava();
117+
}
118+
119+
@Override
120+
public boolean isToolRequired() {
121+
return block.requiresCorrectToolForDrops();
122+
}
123+
124+
@Override
125+
public boolean isReplacedDuringPlacement() {
126+
return block.canBeReplaced();
127+
}
128+
129+
@Override
130+
public boolean isTranslucent() {
131+
return !block.canOcclude();
132+
}
133+
134+
@Override
135+
public boolean hasContainer() {
136+
return block.getBlock() instanceof EntityBlock entityBlock
137+
&& entityBlock.newBlockEntity(BlockPos.ZERO, block) instanceof Clearable;
138+
}
139+
140+
}

0 commit comments

Comments
 (0)