From 0ea9aeac018b1065a715f9864c9c2c0eda410cef Mon Sep 17 00:00:00 2001 From: PseudoKnight Date: Tue, 17 Oct 2023 05:39:20 -0700 Subject: [PATCH] Add display entities to entity_spec --- .../bukkit/entities/BukkitMCBlockDisplay.java | 28 ++++ .../bukkit/entities/BukkitMCDisplay.java | 134 ++++++++++++++++++ .../bukkit/entities/BukkitMCItemDisplay.java | 47 ++++++ .../bukkit/entities/BukkitMCTextDisplay.java | 86 +++++++++++ .../abstraction/entities/MCBlockDisplay.java | 11 ++ .../abstraction/entities/MCDisplay.java | 73 ++++++++++ .../abstraction/entities/MCItemDisplay.java | 26 ++++ .../abstraction/entities/MCTextDisplay.java | 38 +++++ .../core/functions/EntityManagement.java | 110 ++++++++++++++ src/main/resources/functionDocs/entity_spec | 18 +++ 10 files changed, 571 insertions(+) create mode 100644 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCBlockDisplay.java create mode 100644 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCDisplay.java create mode 100644 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCItemDisplay.java create mode 100644 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCTextDisplay.java create mode 100644 src/main/java/com/laytonsmith/abstraction/entities/MCBlockDisplay.java create mode 100644 src/main/java/com/laytonsmith/abstraction/entities/MCDisplay.java create mode 100644 src/main/java/com/laytonsmith/abstraction/entities/MCItemDisplay.java create mode 100644 src/main/java/com/laytonsmith/abstraction/entities/MCTextDisplay.java diff --git a/src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCBlockDisplay.java b/src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCBlockDisplay.java new file mode 100644 index 000000000..eba51affd --- /dev/null +++ b/src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCBlockDisplay.java @@ -0,0 +1,28 @@ +package com.laytonsmith.abstraction.bukkit.entities; + +import com.laytonsmith.abstraction.blocks.MCBlockData; +import com.laytonsmith.abstraction.bukkit.blocks.BukkitMCBlockData; +import com.laytonsmith.abstraction.entities.MCBlockDisplay; +import org.bukkit.block.data.BlockData; +import org.bukkit.entity.BlockDisplay; +import org.bukkit.entity.Entity; + +public class BukkitMCBlockDisplay extends BukkitMCDisplay implements MCBlockDisplay { + + BlockDisplay bd; + + public BukkitMCBlockDisplay(Entity e) { + super(e); + this.bd = (BlockDisplay) e; + } + + @Override + public MCBlockData getBlockData() { + return new BukkitMCBlockData(this.bd.getBlock()); + } + + @Override + public void setBlockData(MCBlockData data) { + this.bd.setBlock((BlockData) data.getHandle()); + } +} diff --git a/src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCDisplay.java b/src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCDisplay.java new file mode 100644 index 000000000..372086ebb --- /dev/null +++ b/src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCDisplay.java @@ -0,0 +1,134 @@ +package com.laytonsmith.abstraction.bukkit.entities; + +import com.laytonsmith.abstraction.MCColor; +import com.laytonsmith.abstraction.bukkit.BukkitMCColor; +import com.laytonsmith.abstraction.entities.MCDisplay; +import org.bukkit.Color; +import org.bukkit.entity.Display; +import org.bukkit.entity.Entity; + +public class BukkitMCDisplay extends BukkitMCEntity implements MCDisplay { + + Display d; + + public BukkitMCDisplay(Entity e) { + super(e); + this.d = (Display) e; + } + + @Override + public MCDisplay.Billboard getBillboard() { + return MCDisplay.Billboard.valueOf(this.d.getBillboard().name()); + } + + @Override + public void setBillboard(MCDisplay.Billboard billboard) { + this.d.setBillboard(Display.Billboard.valueOf(billboard.name())); + } + + @Override + public MCDisplay.Brightness getBrightness() { + Display.Brightness brightness = this.d.getBrightness(); + if(brightness == null) { + return null; + } + return new MCDisplay.Brightness(brightness.getBlockLight(), brightness.getSkyLight()); + } + + @Override + public void setBrightness(MCDisplay.Brightness brightness) { + if(brightness == null) { + this.d.setBrightness(null); + } else { + this.d.setBrightness(new Display.Brightness(brightness.block(), brightness.sky())); + } + } + + @Override + public MCColor getGlowColorOverride() { + Color color = this.d.getGlowColorOverride(); + if(color == null) { + return null; + } + return BukkitMCColor.GetMCColor(color); + } + + @Override + public void setGlowColorOverride(MCColor color) { + if(color == null) { + this.d.setGlowColorOverride(null); + } else { + this.d.setGlowColorOverride(BukkitMCColor.GetColor(color)); + } + } + + @Override + public float getDisplayHeight() { + return this.d.getDisplayHeight(); + } + + @Override + public void setDisplayHeight(float height) { + this.d.setDisplayHeight(height); + } + + @Override + public float getDisplayWidth() { + return this.d.getDisplayWidth(); + } + + @Override + public void setDisplayWidth(float width) { + this.d.setDisplayWidth(width); + } + + @Override + public int getInterpolationDurationTicks() { + return this.d.getInterpolationDuration(); + } + + @Override + public void setInterpolationDurationTicks(int ticks) { + this.d.setInterpolationDuration(ticks); + } + + @Override + public int getInterpolationDelayTicks() { + return this.d.getInterpolationDelay(); + } + + @Override + public void setInterpolationDelayTicks(int ticks) { + this.d.setInterpolationDuration(ticks); + } + + @Override + public float getShadowRadius() { + return this.d.getShadowRadius(); + } + + @Override + public void setShadowRadius(float radius) { + this.d.setShadowRadius(radius); + } + + @Override + public float getShadowStrength() { + return this.d.getShadowStrength(); + } + + @Override + public void setShadowStrength(float strength) { + this.d.setShadowStrength(strength); + } + + @Override + public float getViewRange() { + return this.d.getViewRange(); + } + + @Override + public void setViewRange(float range) { + this.d.setViewRange(range); + } +} diff --git a/src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCItemDisplay.java b/src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCItemDisplay.java new file mode 100644 index 000000000..fa1cb76da --- /dev/null +++ b/src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCItemDisplay.java @@ -0,0 +1,47 @@ +package com.laytonsmith.abstraction.bukkit.entities; + +import com.laytonsmith.abstraction.MCItemStack; +import com.laytonsmith.abstraction.bukkit.BukkitMCItemStack; +import com.laytonsmith.abstraction.entities.MCItemDisplay; +import org.bukkit.entity.Entity; +import org.bukkit.entity.ItemDisplay; +import org.bukkit.entity.ItemDisplay.ItemDisplayTransform; +import org.bukkit.inventory.ItemStack; + +public class BukkitMCItemDisplay extends BukkitMCDisplay implements MCItemDisplay { + + ItemDisplay id; + + public BukkitMCItemDisplay(Entity e) { + super(e); + this.id = (ItemDisplay) e; + } + + @Override + public MCItemStack getItem() { + ItemStack item = this.id.getItemStack(); + if(item == null) { + return null; + } + return new BukkitMCItemStack(item); + } + + @Override + public void setItem(MCItemStack item) { + if(item == null) { + this.id.setItemStack(null); + } else { + this.id.setItemStack((ItemStack) item.getHandle()); + } + } + + @Override + public ModelTransform getItemModelTransform() { + return ModelTransform.valueOf(this.id.getItemDisplayTransform().name()); + } + + @Override + public void setItemModelTransform(ModelTransform transform) { + this.id.setItemDisplayTransform(ItemDisplayTransform.valueOf(transform.name())); + } +} diff --git a/src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCTextDisplay.java b/src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCTextDisplay.java new file mode 100644 index 000000000..6a09122ae --- /dev/null +++ b/src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCTextDisplay.java @@ -0,0 +1,86 @@ +package com.laytonsmith.abstraction.bukkit.entities; + +import com.laytonsmith.abstraction.entities.MCTextDisplay; +import org.bukkit.entity.Entity; +import org.bukkit.entity.TextDisplay; +import org.bukkit.entity.TextDisplay.TextAlignment; + +public class BukkitMCTextDisplay extends BukkitMCDisplay implements MCTextDisplay { + + TextDisplay td; + + public BukkitMCTextDisplay(Entity e) { + super(e); + this.td = (TextDisplay) e; + } + + @Override + public MCTextDisplay.Alignment getAlignment() { + return MCTextDisplay.Alignment.valueOf(td.getAlignment().name()); + } + + @Override + public void setAlignment(MCTextDisplay.Alignment alignment) { + td.setAlignment(TextAlignment.valueOf(alignment.name())); + } + + @Override + public boolean usesDefaultBackground() { + return td.isDefaultBackground(); + } + + @Override + public void setUsesDefaultBackground(boolean defaultBackground) { + td.setDefaultBackground(defaultBackground); + } + + @Override + public int getLineWidth() { + return td.getLineWidth(); + } + + @Override + public void setLineWidth(int width) { + td.setLineWidth(width); + } + + @Override + public boolean isVisibleThroughBlocks() { + return td.isSeeThrough(); + } + + @Override + public void setVisibleThroughBlocks(boolean visible) { + td.setSeeThrough(visible); + } + + @Override + public boolean hasShadow() { + return td.isShadowed(); + } + + @Override + public void setHasShadow(boolean hasShadow) { + td.setShadowed(hasShadow); + } + + @Override + public String getText() { + return td.getText(); + } + + @Override + public void setText(String text) { + td.setText(text); + } + + @Override + public byte getOpacity() { + return td.getTextOpacity(); + } + + @Override + public void setOpacity(byte opacity) { + td.setTextOpacity(opacity); + } +} diff --git a/src/main/java/com/laytonsmith/abstraction/entities/MCBlockDisplay.java b/src/main/java/com/laytonsmith/abstraction/entities/MCBlockDisplay.java new file mode 100644 index 000000000..d7b397dc8 --- /dev/null +++ b/src/main/java/com/laytonsmith/abstraction/entities/MCBlockDisplay.java @@ -0,0 +1,11 @@ +package com.laytonsmith.abstraction.entities; + +import com.laytonsmith.abstraction.blocks.MCBlockData; + +public interface MCBlockDisplay extends MCDisplay { + + MCBlockData getBlockData(); + + void setBlockData(MCBlockData data); + +} diff --git a/src/main/java/com/laytonsmith/abstraction/entities/MCDisplay.java b/src/main/java/com/laytonsmith/abstraction/entities/MCDisplay.java new file mode 100644 index 000000000..af07f7239 --- /dev/null +++ b/src/main/java/com/laytonsmith/abstraction/entities/MCDisplay.java @@ -0,0 +1,73 @@ +package com.laytonsmith.abstraction.entities; + +import com.laytonsmith.abstraction.MCColor; +import com.laytonsmith.abstraction.MCEntity; + +public interface MCDisplay extends MCEntity { + + Billboard getBillboard(); + + void setBillboard(Billboard billboard); + + Brightness getBrightness(); + + void setBrightness(Brightness brightness); + + MCColor getGlowColorOverride(); + + void setGlowColorOverride(MCColor color); + + float getDisplayHeight(); + + void setDisplayHeight(float height); + + float getDisplayWidth(); + + void setDisplayWidth(float width); + + int getInterpolationDurationTicks(); + + void setInterpolationDurationTicks(int ticks); + + int getInterpolationDelayTicks(); + + void setInterpolationDelayTicks(int ticks); + + float getShadowRadius(); + + void setShadowRadius(float radius); + + float getShadowStrength(); + + void setShadowStrength(float strength); + + float getViewRange(); + + void setViewRange(float range); + + enum Billboard { + CENTER, + FIXED, + HORIZONTAL, + VERTICAL + } + + class Brightness { + + final int block; + final int sky; + + public Brightness(int block, int sky) { + this.block = block; + this.sky = sky; + } + + public int block() { + return this.block; + } + + public int sky() { + return this.sky; + } + } +} diff --git a/src/main/java/com/laytonsmith/abstraction/entities/MCItemDisplay.java b/src/main/java/com/laytonsmith/abstraction/entities/MCItemDisplay.java new file mode 100644 index 000000000..3ddfedf61 --- /dev/null +++ b/src/main/java/com/laytonsmith/abstraction/entities/MCItemDisplay.java @@ -0,0 +1,26 @@ +package com.laytonsmith.abstraction.entities; + +import com.laytonsmith.abstraction.MCItemStack; + +public interface MCItemDisplay extends MCDisplay { + + MCItemStack getItem(); + + void setItem(MCItemStack item); + + ModelTransform getItemModelTransform(); + + void setItemModelTransform(ModelTransform transform); + + enum ModelTransform { + FIRSTPERSON_LEFTHAND, + FIRSTPERSON_RIGHTHAND, + FIXED, + GROUND, + GUI, + HEAD, + NONE, + THIRDPERSON_LEFTHAND, + THIRDPERSON_RIGHTHAND + } +} diff --git a/src/main/java/com/laytonsmith/abstraction/entities/MCTextDisplay.java b/src/main/java/com/laytonsmith/abstraction/entities/MCTextDisplay.java new file mode 100644 index 000000000..c71fe0b99 --- /dev/null +++ b/src/main/java/com/laytonsmith/abstraction/entities/MCTextDisplay.java @@ -0,0 +1,38 @@ +package com.laytonsmith.abstraction.entities; + +public interface MCTextDisplay extends MCDisplay { + + Alignment getAlignment(); + + void setAlignment(Alignment alignment); + + boolean usesDefaultBackground(); + + void setUsesDefaultBackground(boolean defaultBackground); + + int getLineWidth(); + + void setLineWidth(int width); + + boolean isVisibleThroughBlocks(); + + void setVisibleThroughBlocks(boolean visible); + + boolean hasShadow(); + + void setHasShadow(boolean hasShadow); + + String getText(); + + void setText(String text); + + byte getOpacity(); + + void setOpacity(byte opacity); + + enum Alignment { + CENTER, + LEFT, + RIGHT + } +} diff --git a/src/main/java/com/laytonsmith/core/functions/EntityManagement.java b/src/main/java/com/laytonsmith/core/functions/EntityManagement.java index cec9986bd..07e560be8 100644 --- a/src/main/java/com/laytonsmith/core/functions/EntityManagement.java +++ b/src/main/java/com/laytonsmith/core/functions/EntityManagement.java @@ -30,6 +30,7 @@ import com.laytonsmith.abstraction.entities.MCArrow; import com.laytonsmith.abstraction.entities.MCAxolotl; import com.laytonsmith.abstraction.entities.MCBee; +import com.laytonsmith.abstraction.entities.MCBlockDisplay; import com.laytonsmith.abstraction.entities.MCBoat; import com.laytonsmith.abstraction.entities.MCCat; import com.laytonsmith.abstraction.entities.MCChestedHorse; @@ -56,6 +57,8 @@ import com.laytonsmith.abstraction.entities.MCInteraction.MCPreviousInteraction; import com.laytonsmith.abstraction.entities.MCIronGolem; import com.laytonsmith.abstraction.entities.MCItem; +import com.laytonsmith.abstraction.entities.MCItemDisplay; +import com.laytonsmith.abstraction.entities.MCItemDisplay.ModelTransform; import com.laytonsmith.abstraction.entities.MCItemFrame; import com.laytonsmith.abstraction.entities.MCItemProjectile; import com.laytonsmith.abstraction.entities.MCLightningStrike; @@ -81,6 +84,7 @@ import com.laytonsmith.abstraction.entities.MCSpectralArrow; import com.laytonsmith.abstraction.entities.MCStrider; import com.laytonsmith.abstraction.entities.MCTNT; +import com.laytonsmith.abstraction.entities.MCTextDisplay; import com.laytonsmith.abstraction.entities.MCThrownPotion; import com.laytonsmith.abstraction.entities.MCTrident; import com.laytonsmith.abstraction.entities.MCTropicalFish; @@ -1809,6 +1813,7 @@ public String docs() { docs = docs.replace("%PANDA_GENE%", StringUtils.Join(MCPanda.Gene.values(), ", ", ", or ", " or ")); docs = docs.replace("%AXOLOTL_TYPE%", StringUtils.Join(MCAxolotlType.values(), ", ", ", or ", " or ")); docs = docs.replace("%FROG_TYPE%", StringUtils.Join(MCFrogType.values(), ", ", ", or ", " or ")); + docs = docs.replace("%ITEM_DISPLAY%", StringUtils.Join(ModelTransform.values(), ", ", ", or ")); for(Field field : entity_spec.class.getDeclaredFields()) { try { String name = field.getName(); @@ -1904,6 +1909,10 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi specArray.set(entity_spec.KEY_BEE_HIVE_LOCATION, ObjectGenerator.GetGenerator().location(hive), t); } break; + case BLOCK_DISPLAY: + MCBlockDisplay blockDisplay = (MCBlockDisplay) entity; + specArray.set(KEY_DISPLAY_BLOCK, ObjectGenerator.GetGenerator().blockData(blockDisplay.getBlockData(), t), t); + break; case BOAT: MCBoat boat = (MCBoat) entity; specArray.set(entity_spec.KEY_BOAT_TYPE, new CString(boat.getWoodType().name(), t), t); @@ -2067,6 +2076,11 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi MCIronGolem golem = (MCIronGolem) entity; specArray.set(entity_spec.KEY_IRON_GOLEM_PLAYERCREATED, CBoolean.get(golem.isPlayerCreated()), t); break; + case ITEM_DISPLAY: + MCItemDisplay itemDisplay = (MCItemDisplay) entity; + specArray.set(KEY_DISPLAY_ITEM, ObjectGenerator.GetGenerator().item(itemDisplay.getItem(), t), t); + specArray.set(KEY_DISPLAY_ITEM_DISPLAY, itemDisplay.getItemModelTransform().name(), t); + break; case ITEM_FRAME: case GLOW_ITEM_FRAME: MCItemFrame frame = (MCItemFrame) entity; @@ -2209,6 +2223,19 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi MCStrider strider = (MCStrider) entity; specArray.set(entity_spec.KEY_STEERABLE_SADDLED, CBoolean.get(strider.isSaddled()), t); break; + case TEXT_DISPLAY: + MCTextDisplay tDisplay = (MCTextDisplay) entity; + specArray.set(entity_spec.KEY_DISPLAY_TEXT, tDisplay.getText()); + specArray.set(entity_spec.KEY_DISPLAY_TEXT_ALIGNMENT, tDisplay.getAlignment().name()); + specArray.set(entity_spec.KEY_DISPLAY_TEXT_LINE_WIDTH, new CInt(tDisplay.getLineWidth(), t), t); + specArray.set(entity_spec.KEY_DISPLAY_TEXT_SEE_THROUGH, CBoolean.get(tDisplay.isVisibleThroughBlocks()), t); + specArray.set(entity_spec.KEY_DISPLAY_TEXT_SHADOW, CBoolean.get(tDisplay.hasShadow()), t); + long opacity = tDisplay.getOpacity(); + if(opacity < 0) { + opacity += 256; + } + specArray.set(entity_spec.KEY_DISPLAY_TEXT_OPACITY, new CInt(opacity, t), t); + break; case TRIDENT: MCTrident trident = (MCTrident) entity; specArray.set(entity_spec.KEY_ARROW_CRITICAL, CBoolean.get(trident.isCritical()), t); @@ -2322,6 +2349,15 @@ public MSVersion since() { private static final String KEY_CREEPER_FUSETICKS = "fuseticks"; private static final String KEY_CREEPER_MAXFUSETICKS = "maxfuseticks"; private static final String KEY_CREEPER_EXPLOSIONRADIUS = "explosionradius"; + private static final String KEY_DISPLAY_BLOCK = "blockdata"; + private static final String KEY_DISPLAY_ITEM = "item"; + private static final String KEY_DISPLAY_ITEM_DISPLAY = "itemdisplay"; + private static final String KEY_DISPLAY_TEXT = "text"; + private static final String KEY_DISPLAY_TEXT_ALIGNMENT = "alignment"; + private static final String KEY_DISPLAY_TEXT_LINE_WIDTH = "linewidth"; + private static final String KEY_DISPLAY_TEXT_SEE_THROUGH = "seethrough"; + private static final String KEY_DISPLAY_TEXT_SHADOW = "shadow"; + private static final String KEY_DISPLAY_TEXT_OPACITY = "opacity"; private static final String KEY_DROPPED_ITEM_ITEMSTACK = "itemstack"; private static final String KEY_DROPPED_ITEM_PICKUPDELAY = "pickupdelay"; private static final String KEY_DROPPED_ITEM_OWNER = "owner"; @@ -2747,6 +2783,25 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi } } break; + case BLOCK_DISPLAY: + MCBlockDisplay bDisplay = (MCBlockDisplay) entity; + for(String index : specArray.stringKeySet()) { + switch(index.toLowerCase()) { + case entity_spec.KEY_DISPLAY_BLOCK: + MCBlockData bd; + Mixed m = specArray.get(index, t); + if(m.isInstanceOf(CArray.TYPE)) { + bd = ObjectGenerator.GetGenerator().blockData((CArray) m, t); + } else { + bd = Static.getServer().createBlockData(m.val()); + } + bDisplay.setBlockData(bd); + break; + default: + throwException(index, t); + } + } + break; case BOAT: MCBoat boat = (MCBoat) entity; for(String index : specArray.stringKeySet()) { @@ -3192,6 +3247,26 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi } } break; + case ITEM_DISPLAY: + MCItemDisplay itemDisplay = (MCItemDisplay) entity; + for(String index : specArray.stringKeySet()) { + switch(index.toLowerCase()) { + case entity_spec.KEY_DISPLAY_ITEM: + itemDisplay.setItem(ObjectGenerator.GetGenerator().item(specArray.get(index, t), t)); + break; + case entity_spec.KEY_DISPLAY_ITEM_DISPLAY: + try { + itemDisplay.setItemModelTransform(ModelTransform.valueOf(specArray.get(index, t).val())); + } catch (IllegalArgumentException ex) { + throw new CREFormatException("Invalid display item model transform: " + + specArray.get(index, t).val(), t); + } + break; + default: + throwException(index, t); + } + } + break; case ITEM_FRAME: case GLOW_ITEM_FRAME: MCItemFrame frame = (MCItemFrame) entity; @@ -3645,6 +3720,41 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi } } break; + case TEXT_DISPLAY: + MCTextDisplay tDisplay = (MCTextDisplay) entity; + for(String index : specArray.stringKeySet()) { + switch(index.toLowerCase()) { + case entity_spec.KEY_DISPLAY_TEXT: + tDisplay.setText(specArray.get(index, t).val()); + break; + case entity_spec.KEY_DISPLAY_TEXT_ALIGNMENT: + try { + tDisplay.setAlignment(MCTextDisplay.Alignment.valueOf(specArray.get(index, t).val())); + } catch (IllegalArgumentException ex) { + throw new CREFormatException("Invalid text alignment: " + specArray.get(index, t).val(), t); + } + break; + case entity_spec.KEY_DISPLAY_TEXT_LINE_WIDTH: + tDisplay.setLineWidth(ArgumentValidation.getInt32(specArray.get(index, t), t)); + break; + case entity_spec.KEY_DISPLAY_TEXT_SEE_THROUGH: + tDisplay.setVisibleThroughBlocks(ArgumentValidation.getBooleanObject(specArray.get(index, t), t)); + break; + case entity_spec.KEY_DISPLAY_TEXT_SHADOW: + tDisplay.setHasShadow(ArgumentValidation.getBooleanObject(specArray.get(index, t), t)); + break; + case entity_spec.KEY_DISPLAY_TEXT_OPACITY: + long opacity = ArgumentValidation.getInt(specArray.get(index, t), t); + if(opacity < 0 || opacity > 255) { + throw new CRERangeException("Text opacity outside valid range.", t); + } + tDisplay.setOpacity((byte) opacity); + break; + default: + throwException(index, t); + } + } + break; case TRIDENT: MCTrident trident = (MCTrident) entity; for(String index : specArray.stringKeySet()) { diff --git a/src/main/resources/functionDocs/entity_spec b/src/main/resources/functionDocs/entity_spec index f2df609c5..7f884f1e7 100644 --- a/src/main/resources/functionDocs/entity_spec +++ b/src/main/resources/functionDocs/entity_spec @@ -56,6 +56,10 @@ without knowing the rotations on the other axis or of other body parts beforehan * %KEY_BEE_NECTAR%: Whether or not the bee is carrying pollen. * %KEY_BEE_STUNG%: Whether or not the bee has stung something. |- +| BLOCK_DISPLAY +| +* %KEY_DISPLAY_BLOCK%: A blockdata array (or optionally string) for the block to be displayed. +|- | BOAT | * %KEY_BOAT_TYPE%: Which tree species the boat is composed of. (can be %TREE_SPECIES%) @@ -167,6 +171,11 @@ without knowing the rotations on the other axis or of other body parts beforehan | * %KEY_IRON_GOLEM_PLAYERCREATED%: Whether the iron golem was built by a player or not. |- +| ITEM_DISPLAY +| +* %KEY_DISPLAY_ITEM%: The item array for the item to be displayed. +* %KEY_DISPLAY_ITEM_DISPLAY%: The item display model transform to use. Can be %ITEM_DISPLAY%. +|- | ITEM_FRAME, GLOW_ITEM_FRAME | * %KEY_ITEM_FRAME_FIXED%: If true, the item frame cannot be manipulated. (destroyed, rotated, removed, etc) (default false) @@ -289,6 +298,15 @@ without knowing the rotations on the other axis or of other body parts beforehan | * %KEY_SPLASH_POTION_ITEM%: The item for the thrown potion. |- +| TEXT_DISPLAY +| +* %KEY_DISPLAY_TEXT_ALIGNMENT%: The text alignment. Can be CENTER (default), LEFT or RIGHT. +* %KEY_DISPLAY_TEXT%: The text for this display entity. +* %KEY_DISPLAY_TEXT_LINE_WIDTH%: The max width for a line of text before splitting. (default: 200) +* %KEY_DISPLAY_TEXT_SEE_THROUGH%: Whether the text is visible through blocks. (default: false) +* %KEY_DISPLAY_TEXT_SHADOW%: Whether the text has a shadow. (default: false) Not to be confused with an entity shadow. +* %KEY_DISPLAY_TEXT_OPACITY%: The alpha opacity of the text from 0 to 255. (default: 255) +|- | TRIDENT | * %KEY_ARROW_CRITICAL%: If this trident is critical. (boolean)