Skip to content

Commit

Permalink
Remove flowerpot implementation for 1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphan1 committed Oct 25, 2018
1 parent 801be95 commit cd75990
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
21 changes: 16 additions & 5 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dLocation.java
Expand Up @@ -759,11 +759,18 @@ public String getAttribute(Attribute attribute) {
// @returns Element
// @description
// Returns the flower pot contents at the location.
// NOTE: Replaced by materials (such as POTTED_CACTUS) in 1.13 and above.
// -->
if (attribute.startsWith("flowerpot_contents") && getBlock().getType() == Material.FLOWER_POT) {
MaterialData contents = NMSHandler.getInstance().getBlockHelper().getFlowerpotContents(getBlock());
return dMaterial.getMaterialFrom(contents.getItemType(), contents.getData())
.getAttribute(attribute.fulfill(1));
if (attribute.startsWith("flowerpot_contents")) {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_13_R2)) {
dB.echoError("As of Minecraft version 1.13 potted flowers each have their own material, such as POTTED_CACTUS.");
}
else if (getBlock().getType() == Material.FLOWER_POT) {
MaterialData contents = NMSHandler.getInstance().getBlockHelper().getFlowerpotContents(getBlock());
return dMaterial.getMaterialFrom(contents.getItemType(), contents.getData())
.getAttribute(attribute.fulfill(1));
}
return null;
}


Expand Down Expand Up @@ -2267,13 +2274,17 @@ && getBlock().getState() instanceof CreatureSpawner) {
// @input dMaterial
// @description
// Sets the contents of a flower pot.
// NOTE: Replaced by materials (such as POTTED_CACTUS) in 1.13 and above.
// NOTE: Flowerpot contents will not update client-side until players refresh the chunk.
// Refresh a chunk manually with mechanism: refresh_chunk_sections for dChunk objects
// @tags
// <l@location.flowerpot_contents>
// -->
if (mechanism.matches("flowerpot_contents") && mechanism.requireObject(dMaterial.class)) {
if (getBlock().getType() == Material.FLOWER_POT) {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_13_R2)) {
dB.echoError("As of Minecraft version 1.13 potted flowers each have their own material, such as POTTED_CACTUS.");
}
else if (getBlock().getType() == Material.FLOWER_POT) {
MaterialData data = value.asType(dMaterial.class).getMaterialData();
NMSHandler.getInstance().getBlockHelper().setFlowerpotContents(getBlock(), data);
}
Expand Down
Expand Up @@ -18,7 +18,6 @@
import net.minecraft.server.v1_13_R2.TileEntitySkull;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.FlowerPot;
import org.bukkit.block.Skull;
import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlockEntityState;
import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlockState;
Expand Down Expand Up @@ -57,14 +56,12 @@ public int idFor(Material mat) {

@Override
public MaterialData getFlowerpotContents(Block block) {
return ((FlowerPot) block.getState()).getContents();
throw new UnsupportedOperationException("As of Minecraft version 1.13 potted flowers each have their own material, such as POTTED_CACTUS.");
}

@Override
public void setFlowerpotContents(Block block, MaterialData data) {
FlowerPot flowerPot = (FlowerPot) block.getState();
flowerPot.setContents(data);
flowerPot.update();
throw new UnsupportedOperationException("As of Minecraft version 1.13 potted flowers each have their own material, such as POTTED_CACTUS.");
}

@Override
Expand Down

0 comments on commit cd75990

Please sign in to comment.