geforkt von Mirrors/Paper
SPIGOT-1292: BlockState based FlowerPot API.
Dieser Commit ist enthalten in:
Ursprung
cee5bbf00c
Commit
a28041daa7
@ -296,6 +296,8 @@ public class CraftBlock implements Block {
|
|||||||
case WALL_BANNER:
|
case WALL_BANNER:
|
||||||
case STANDING_BANNER:
|
case STANDING_BANNER:
|
||||||
return new CraftBanner(this);
|
return new CraftBanner(this);
|
||||||
|
case FLOWER_POT:
|
||||||
|
return new CraftFlowerPot(this);
|
||||||
default:
|
default:
|
||||||
return new CraftBlockState(this);
|
return new CraftBlockState(this);
|
||||||
}
|
}
|
||||||
|
40
src/main/java/org/bukkit/craftbukkit/block/CraftFlowerPot.java
Normale Datei
40
src/main/java/org/bukkit/craftbukkit/block/CraftFlowerPot.java
Normale Datei
@ -0,0 +1,40 @@
|
|||||||
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import net.minecraft.server.TileEntityFlowerPot;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.FlowerPot;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
|
public class CraftFlowerPot extends CraftBlockState implements FlowerPot {
|
||||||
|
|
||||||
|
private final TileEntityFlowerPot pot;
|
||||||
|
|
||||||
|
public CraftFlowerPot(Block block) {
|
||||||
|
super(block);
|
||||||
|
|
||||||
|
pot = (TileEntityFlowerPot) ((CraftWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CraftFlowerPot(Material material, TileEntityFlowerPot pot) {
|
||||||
|
super(material);
|
||||||
|
|
||||||
|
this.pot = pot;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MaterialData getContents() {
|
||||||
|
return (pot.d() == null) ? null : CraftMagicNumbers.getMaterial(pot.d()).getNewData((byte) pot.e()); // PAIL: rename
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setContents(MaterialData item) {
|
||||||
|
if (item == null) {
|
||||||
|
pot.a(null, 0);
|
||||||
|
} else {
|
||||||
|
pot.a(CraftMagicNumbers.getItem(item.getItemType()), item.getData()); // PAIL: rename
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,7 @@ import net.minecraft.server.TileEntityCommand;
|
|||||||
import net.minecraft.server.TileEntityDispenser;
|
import net.minecraft.server.TileEntityDispenser;
|
||||||
import net.minecraft.server.TileEntityDropper;
|
import net.minecraft.server.TileEntityDropper;
|
||||||
import net.minecraft.server.TileEntityEndGateway;
|
import net.minecraft.server.TileEntityEndGateway;
|
||||||
|
import net.minecraft.server.TileEntityFlowerPot;
|
||||||
import net.minecraft.server.TileEntityFurnace;
|
import net.minecraft.server.TileEntityFurnace;
|
||||||
import net.minecraft.server.TileEntityHopper;
|
import net.minecraft.server.TileEntityHopper;
|
||||||
import net.minecraft.server.TileEntityMobSpawner;
|
import net.minecraft.server.TileEntityMobSpawner;
|
||||||
@ -36,6 +37,7 @@ import org.bukkit.craftbukkit.block.CraftCreatureSpawner;
|
|||||||
import org.bukkit.craftbukkit.block.CraftDispenser;
|
import org.bukkit.craftbukkit.block.CraftDispenser;
|
||||||
import org.bukkit.craftbukkit.block.CraftDropper;
|
import org.bukkit.craftbukkit.block.CraftDropper;
|
||||||
import org.bukkit.craftbukkit.block.CraftEndGateway;
|
import org.bukkit.craftbukkit.block.CraftEndGateway;
|
||||||
|
import org.bukkit.craftbukkit.block.CraftFlowerPot;
|
||||||
import org.bukkit.craftbukkit.block.CraftFurnace;
|
import org.bukkit.craftbukkit.block.CraftFurnace;
|
||||||
import org.bukkit.craftbukkit.block.CraftHopper;
|
import org.bukkit.craftbukkit.block.CraftHopper;
|
||||||
import org.bukkit.craftbukkit.block.CraftJukebox;
|
import org.bukkit.craftbukkit.block.CraftJukebox;
|
||||||
@ -279,6 +281,11 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
|||||||
te = new TileEntityBanner();
|
te = new TileEntityBanner();
|
||||||
}
|
}
|
||||||
return new CraftBanner(material, (TileEntityBanner) te);
|
return new CraftBanner(material, (TileEntityBanner) te);
|
||||||
|
case FLOWER_POT_ITEM:
|
||||||
|
if (te == null) {
|
||||||
|
te = new TileEntityFlowerPot();
|
||||||
|
}
|
||||||
|
return new CraftFlowerPot(material, (TileEntityFlowerPot) te);
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Missing blockState for " + material);
|
throw new IllegalStateException("Missing blockState for " + material);
|
||||||
}
|
}
|
||||||
@ -346,6 +353,9 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
|||||||
case STANDING_BANNER:
|
case STANDING_BANNER:
|
||||||
valid = te instanceof TileEntityBanner;
|
valid = te instanceof TileEntityBanner;
|
||||||
break;
|
break;
|
||||||
|
case FLOWER_POT_ITEM:
|
||||||
|
valid = te instanceof TileEntityFlowerPot;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
valid = false;
|
valid = false;
|
||||||
break;
|
break;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren