Get Colors from ShulkerBox; Implement CustomName for Tiles.

This commit is contained in:
Senmori 2016-11-18 11:24:41 +11:00 committed by md_5
parent f15e07b1a9
commit 26377b763b
10 changed files with 86 additions and 5 deletions

View file

@ -1,5 +1,14 @@
--- a/net/minecraft/server/BlockShulkerBox.java
+++ b/net/minecraft/server/BlockShulkerBox.java
@@ -3,7 +3,7 @@
public class BlockShulkerBox extends BlockTileEntity {
public static final BlockStateEnum<EnumDirection> a = BlockStateDirection.of("facing");
- private final EnumColor b;
+ public final EnumColor b; // PAIL: public, rename
public BlockShulkerBox(EnumColor enumcolor) {
super(Material.STONE, MaterialMapColor.b);
@@ -89,7 +89,32 @@
tileentityshulkerbox.d(entityhuman);
}

View file

@ -88,4 +88,14 @@ public class CraftBeacon extends CraftContainer implements Beacon {
public void setSecondaryEffect(PotionEffectType effect) {
beacon.secondaryEffect = (effect != null) ? MobEffectList.fromId(effect.getId()) : null;
}
@Override
public String getCustomName() {
return beacon.hasCustomName() ? beacon.getName() : null;
}
@Override
public void setCustomName(String name) {
beacon.a(name); // PAIL: setCustomName
}
}

View file

@ -59,4 +59,14 @@ public class CraftBrewingStand extends CraftContainer implements BrewingStand {
public void setFuelLevel(int level) {
brewingStand.setProperty(1, level);
}
@Override
public String getCustomName() {
return brewingStand.hasCustomName() ? brewingStand.getName() : null;
}
@Override
public void setCustomName(String name) {
brewingStand.a(name); // PAIL: setCustomName
}
}

View file

@ -11,7 +11,7 @@ import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest;
import org.bukkit.inventory.Inventory;
public class CraftChest extends CraftContainer implements Chest {
public class CraftChest extends CraftLootable implements Chest {
private final CraftWorld world;
private final TileEntityChest chest;

View file

@ -14,7 +14,7 @@ import org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource;
import org.bukkit.inventory.Inventory;
import org.bukkit.projectiles.BlockProjectileSource;
public class CraftDispenser extends CraftContainer implements Dispenser {
public class CraftDispenser extends CraftLootable implements Dispenser {
private final CraftWorld world;
private final TileEntityDispenser dispenser;

View file

@ -12,7 +12,7 @@ import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;
public class CraftDropper extends CraftContainer implements Dropper {
public class CraftDropper extends CraftLootable implements Dropper {
private final CraftWorld world;
private final TileEntityDropper dropper;

View file

@ -53,6 +53,16 @@ public class CraftFurnace extends CraftContainer implements Furnace {
furnace.setProperty(2, cookTime);
}
@Override
public String getCustomName() {
return furnace.hasCustomName() ? furnace.getName() : null;
}
@Override
public void setCustomName(String name) {
furnace.a(name); // PAIL: setCustomName
}
@Override
public TileEntityFurnace getTileEntity() {
return furnace;

View file

@ -8,7 +8,7 @@ import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;
public class CraftHopper extends CraftContainer implements Hopper {
public class CraftHopper extends CraftLootable implements Hopper {
private final TileEntityHopper hopper;
public CraftHopper(final Block block) {

View file

@ -0,0 +1,35 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntity;
import net.minecraft.server.TileEntityLootable;
import org.bukkit.Material;
import org.bukkit.Nameable;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftWorld;
public class CraftLootable extends CraftContainer implements Nameable {
private final TileEntityLootable te;
public CraftLootable(Block block) {
super(block);
te = (TileEntityLootable) ((CraftWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ());
}
public CraftLootable(Material material, TileEntity tileEntity) {
super(material, tileEntity);
te = (TileEntityLootable) tileEntity;
}
@Override
public String getCustomName() {
return te.hasCustomName() ? te.getName() : null;
}
@Override
public void setCustomName(String name) {
te.a(name); // PAIL: setCustomName
}
}

View file

@ -1,7 +1,9 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.BlockShulkerBox;
import net.minecraft.server.TileEntity;
import net.minecraft.server.TileEntityShulkerBox;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.ShulkerBox;
@ -9,7 +11,7 @@ import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;
public class CraftShulkerBox extends CraftContainer implements ShulkerBox {
public class CraftShulkerBox extends CraftLootable implements ShulkerBox {
private final CraftWorld world;
private final TileEntityShulkerBox box;
@ -37,4 +39,9 @@ public class CraftShulkerBox extends CraftContainer implements ShulkerBox {
public Inventory getInventory() {
return new CraftInventory(box);
}
@Override
public DyeColor getColor() {
return DyeColor.getByWoolData((byte) ((BlockShulkerBox) box.getBlock()).b.getColorIndex());
}
}