Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions verification/src/changes/accepted-core-public-api-changes.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,21 @@
"ANNOTATION_REMOVED"
]
}
],
"Fluid overhaul": [
{
"type": "com.sk89q.worldedit.world.fluid.FluidCategories",
"member": "Method com.sk89q.worldedit.world.fluid.FluidCategories.register(com.sk89q.worldedit.world.fluid.FluidCategory)",
"changes": [
"METHOD_REMOVED"
]
},
{
"type": "com.sk89q.worldedit.world.fluid.FluidTypes",
"member": "Method com.sk89q.worldedit.world.fluid.FluidTypes.register(com.sk89q.worldedit.world.fluid.FluidType)",
"changes": [
"METHOD_REMOVED"
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.fluid.FluidState;
import com.sk89q.worldedit.world.fluid.FluidType;
import com.sk89q.worldedit.world.fluid.FluidTypes;
import com.sk89q.worldedit.world.generation.ConfiguredFeatureType;
import com.sk89q.worldedit.world.generation.StructureType;
import com.sk89q.worldedit.world.generation.TreeType;
Expand Down Expand Up @@ -354,6 +357,23 @@ public net.minecraft.world.level.block.state.BlockState adapt(BlockState blockSt
return Block.stateById(internalId);
}

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public FluidState getFluidState(BlockState state) {
net.minecraft.world.level.material.FluidState fluidState = adapt(state).getFluidState();
if (fluidState.isEmpty()) {
return FluidTypes.EMPTY.getDefaultState();
}
String id = DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.FLUID)
.getKey(fluidState.getType()).toString();
FluidType type = FluidTypes.get(id);
Map<Property<?>, Object> properties = new HashMap<>();
for (net.minecraft.world.level.block.state.properties.Property property : fluidState.getProperties()) {
properties.put(PROPERTY_CACHE.getUnchecked(property), fluidState.getValue(property));
}
return type.getState(properties);
}

@Override
public BlockState getBlock(Location location) {
checkNotNull(location);
Expand Down Expand Up @@ -623,6 +643,20 @@ yield new EnumProperty(state.getName(),
return properties;
}

@SuppressWarnings({ "rawtypes" })
@Override
public Map<String, ? extends Property<?>> getFluidProperties(FluidType fluidType) {
Map<String, Property<?>> properties = new TreeMap<>();
var fluid = DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.FLUID)
.listElements().filter(reference -> reference.key().identifier().toString().equals(fluidType.id()))
.findFirst().orElseThrow();
for (net.minecraft.world.level.block.state.properties.Property state : fluid.value().defaultFluidState().getProperties()) {
Property<?> property = PROPERTY_CACHE.getUnchecked(state);
properties.put(property.name(), property);
}
return properties;
}

@Override
public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData) {
var structureBlock = new StructureBlockEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.fluid.FluidState;
import com.sk89q.worldedit.world.fluid.FluidType;
import com.sk89q.worldedit.world.fluid.FluidTypes;
import com.sk89q.worldedit.world.generation.ConfiguredFeatureType;
import com.sk89q.worldedit.world.generation.StructureType;
import com.sk89q.worldedit.world.generation.TreeType;
Expand Down Expand Up @@ -349,6 +352,23 @@ public net.minecraft.world.level.block.state.BlockState adapt(BlockState blockSt
return Block.stateById(internalId);
}

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public FluidState getFluidState(BlockState state) {
net.minecraft.world.level.material.FluidState fluidState = adapt(state).getFluidState();
if (fluidState.isEmpty()) {
return FluidTypes.EMPTY.getDefaultState();
}
String id = DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.FLUID)
.getKey(fluidState.getType()).toString();
FluidType type = FluidTypes.get(id);
Map<Property<?>, Object> properties = new HashMap<>();
for (net.minecraft.world.level.block.state.properties.Property property : fluidState.getProperties()) {
properties.put(PROPERTY_CACHE.getUnchecked(property), fluidState.getValue(property));
}
return type.getState(properties);
}

@Override
public BlockState getBlock(Location location) {
checkNotNull(location);
Expand Down Expand Up @@ -604,6 +624,19 @@ yield new EnumProperty(state.getName(),
return properties;
}

@SuppressWarnings({ "rawtypes" })
@Override
public Map<String, ? extends Property<?>> getFluidProperties(FluidType fluidType) {
Map<String, Property<?>> properties = new TreeMap<>();
var fluid = DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.FLUID)
.get(ResourceLocation.parse(fluidType.id())).orElseThrow();
for (net.minecraft.world.level.block.state.properties.Property state : fluid.value().defaultFluidState().getProperties()) {
Property<?> property = PROPERTY_CACHE.getUnchecked(state);
properties.put(property.name(), property);
}
return properties;
}

@Override
public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData) {
var structureBlock = new StructureBlockEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.fluid.FluidState;
import com.sk89q.worldedit.world.fluid.FluidType;
import com.sk89q.worldedit.world.fluid.FluidTypes;
import com.sk89q.worldedit.world.generation.ConfiguredFeatureType;
import com.sk89q.worldedit.world.generation.StructureType;
import com.sk89q.worldedit.world.generation.TreeType;
Expand Down Expand Up @@ -349,6 +352,23 @@ public net.minecraft.world.level.block.state.BlockState adapt(BlockState blockSt
return Block.stateById(internalId);
}

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public FluidState getFluidState(BlockState state) {
net.minecraft.world.level.material.FluidState fluidState = adapt(state).getFluidState();
if (fluidState.isEmpty()) {
return FluidTypes.EMPTY.getDefaultState();
}
String id = DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.FLUID)
.getKey(fluidState.getType()).toString();
FluidType type = FluidTypes.get(id);
Map<Property<?>, Object> properties = new HashMap<>();
for (net.minecraft.world.level.block.state.properties.Property property : fluidState.getProperties()) {
properties.put(PROPERTY_CACHE.getUnchecked(property), fluidState.getValue(property));
}
return type.getState(properties);
}

@Override
public BlockState getBlock(Location location) {
checkNotNull(location);
Expand Down Expand Up @@ -602,6 +622,19 @@ yield new EnumProperty(state.getName(),
return properties;
}

@SuppressWarnings({ "rawtypes" })
@Override
public Map<String, ? extends Property<?>> getFluidProperties(FluidType fluidType) {
Map<String, Property<?>> properties = new TreeMap<>();
var fluid = DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.FLUID)
.get(ResourceLocation.parse(fluidType.id())).orElseThrow();
for (net.minecraft.world.level.block.state.properties.Property state : fluid.value().defaultFluidState().getProperties()) {
Property<?> property = PROPERTY_CACHE.getUnchecked(state);
properties.put(property.name(), property);
}
return properties;
}

@Override
public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData) {
var structureBlock = new StructureBlockEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.fluid.FluidState;
import com.sk89q.worldedit.world.fluid.FluidType;
import com.sk89q.worldedit.world.fluid.FluidTypes;
import com.sk89q.worldedit.world.generation.ConfiguredFeatureType;
import com.sk89q.worldedit.world.generation.StructureType;
import com.sk89q.worldedit.world.generation.TreeType;
Expand Down Expand Up @@ -355,6 +358,23 @@ public net.minecraft.world.level.block.state.BlockState adapt(BlockState blockSt
return Block.stateById(internalId);
}

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public FluidState getFluidState(BlockState state) {
net.minecraft.world.level.material.FluidState fluidState = adapt(state).getFluidState();
if (fluidState.isEmpty()) {
return FluidTypes.EMPTY.getDefaultState();
}
String id = DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.FLUID)
.getKey(fluidState.getType()).toString();
FluidType type = FluidTypes.get(id);
Map<Property<?>, Object> properties = new HashMap<>();
for (net.minecraft.world.level.block.state.properties.Property property : fluidState.getProperties()) {
properties.put(PROPERTY_CACHE.getUnchecked(property), fluidState.getValue(property));
}
return type.getState(properties);
}

@Override
public BlockState getBlock(Location location) {
checkNotNull(location);
Expand Down Expand Up @@ -624,6 +644,19 @@ yield new EnumProperty(state.getName(),
return properties;
}

@SuppressWarnings({ "rawtypes" })
@Override
public Map<String, ? extends Property<?>> getFluidProperties(FluidType fluidType) {
Map<String, Property<?>> properties = new TreeMap<>();
var fluid = DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.FLUID)
.get(ResourceLocation.parse(fluidType.id())).orElseThrow();
for (net.minecraft.world.level.block.state.properties.Property state : fluid.value().defaultFluidState().getProperties()) {
Property<?> property = PROPERTY_CACHE.getUnchecked(state);
properties.put(property.name(), property);
}
return properties;
}

@Override
public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData) {
var structureBlock = new StructureBlockEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.fluid.FluidState;
import com.sk89q.worldedit.world.fluid.FluidType;
import com.sk89q.worldedit.world.fluid.FluidTypes;
import com.sk89q.worldedit.world.generation.ConfiguredFeatureType;
import com.sk89q.worldedit.world.generation.StructureType;
import com.sk89q.worldedit.world.generation.TreeType;
Expand Down Expand Up @@ -354,6 +357,23 @@ public net.minecraft.world.level.block.state.BlockState adapt(BlockState blockSt
return Block.stateById(internalId);
}

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public FluidState getFluidState(BlockState state) {
net.minecraft.world.level.material.FluidState fluidState = adapt(state).getFluidState();
if (fluidState.isEmpty()) {
return FluidTypes.EMPTY.getDefaultState();
}
String id = DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.FLUID)
.getKey(fluidState.getType()).toString();
FluidType type = FluidTypes.get(id);
Map<Property<?>, Object> properties = new HashMap<>();
for (net.minecraft.world.level.block.state.properties.Property property : fluidState.getProperties()) {
properties.put(PROPERTY_CACHE.getUnchecked(property), fluidState.getValue(property));
}
return type.getState(properties);
}

@Override
public BlockState getBlock(Location location) {
checkNotNull(location);
Expand Down Expand Up @@ -623,6 +643,19 @@ yield new EnumProperty(state.getName(),
return properties;
}

@SuppressWarnings({ "rawtypes" })
@Override
public Map<String, ? extends Property<?>> getFluidProperties(FluidType fluidType) {
Map<String, Property<?>> properties = new TreeMap<>();
var fluid = DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.FLUID)
.get(ResourceLocation.parse(fluidType.id())).orElseThrow();
for (net.minecraft.world.level.block.state.properties.Property state : fluid.value().defaultFluidState().getProperties()) {
Property<?> property = PROPERTY_CACHE.getUnchecked(state);
properties.put(property.name(), property);
}
return properties;
}

@Override
public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData) {
var structureBlock = new StructureBlockEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.fluid.FluidState;
import com.sk89q.worldedit.world.fluid.FluidType;
import com.sk89q.worldedit.world.fluid.FluidTypes;
import com.sk89q.worldedit.world.generation.ConfiguredFeatureType;
import com.sk89q.worldedit.world.generation.StructureType;
import com.sk89q.worldedit.world.generation.TreeType;
Expand Down Expand Up @@ -365,6 +368,23 @@ public net.minecraft.world.level.block.state.BlockState adapt(BlockState blockSt
return Block.stateById(internalId);
}

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public FluidState getFluidState(BlockState state) {
net.minecraft.world.level.material.FluidState fluidState = adapt(state).getFluidState();
if (fluidState.isEmpty()) {
return FluidTypes.EMPTY.getDefaultState();
}
String id = DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.FLUID)
.getKey(fluidState.getType()).toString();
FluidType type = FluidTypes.get(id);
Map<Property<?>, Object> properties = new HashMap<>();
for (net.minecraft.world.level.block.state.properties.Property property : fluidState.getProperties()) {
properties.put(PROPERTY_CACHE.getUnchecked(property), fluidState.getValue(property));
}
return type.getState(properties);
}

@Override
public BlockState getBlock(Location location) {
checkNotNull(location);
Expand Down Expand Up @@ -640,6 +660,20 @@ yield new EnumProperty(state.getName(),
return properties;
}

@SuppressWarnings({ "rawtypes" })
@Override
public Map<String, ? extends Property<?>> getFluidProperties(FluidType fluidType) {
Map<String, Property<?>> properties = new TreeMap<>();
var fluid = DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.FLUID)
.listElements().filter(reference -> reference.key().identifier().toString().equals(fluidType.id()))
.findFirst().orElseThrow();
for (net.minecraft.world.level.block.state.properties.Property state : fluid.value().defaultFluidState().getProperties()) {
Property<?> property = PROPERTY_CACHE.getUnchecked(state);
properties.put(property.name(), property);
}
return properties;
}

@Override
public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData) {
var structureBlock = new StructureBlockEntity(
Expand Down
Loading
Loading