How to use calculateBase method of be.seeseemelk.mockbukkit.block.state.BeaconMock class

Best MockBukkit code snippet using be.seeseemelk.mockbukkit.block.state.BeaconMock.calculateBase

Source:BeaconMock.java Github

copy

Full Screen

...65 * Calculates the Beacon's tier based off the blocks below it, just as in vanilla.66 */67 public void updateTier()68 {69 this.tier = calculateBase();70 }71 /**72 * Sets the tier of the Beacon.73 * Clamped between 1-4 (inclusive).74 *75 * @param tier The tier to set.76 */77 @Test78 public void setTier(int tier)79 {80 this.tier = Math.max(1, Math.min(4, tier));81 }82 @Override83 public int getTier()84 {85 return this.tier;86 }87 @Override88 public @Nullable PotionEffect getPrimaryEffect()89 {90 return this.primaryEffect != null91 ? new PotionEffect(this.primaryEffect, calculateEffectDuration(), calculateEffectAmplifier())92 : null;93 }94 @Override95 public void setPrimaryEffect(@Nullable PotionEffectType effect)96 {97 this.primaryEffect = effect;98 }99 @Override100 public @Nullable PotionEffect getSecondaryEffect()101 {102 return this.hasSecondaryEffect()103 ? new PotionEffect(this.secondaryEffect, calculateEffectDuration(), calculateEffectAmplifier())104 : null;105 }106 @Override107 public void setSecondaryEffect(@Nullable PotionEffectType effect)108 {109 this.secondaryEffect = effect;110 }111 @Override112 public double getEffectRange()113 {114 return (this.effectRange < 0) ? this.getTier() * 10 + 10 : this.effectRange;115 }116 @Override117 public void setEffectRange(double range)118 {119 this.effectRange = range;120 }121 @Override122 public void resetEffectRange()123 {124 this.effectRange = -1;125 }126 @Override127 public @Nullable Component customName()128 {129 return this.customName;130 }131 @Override132 public void customName(@Nullable Component customName)133 {134 this.customName = customName;135 }136 @Override137 public @Nullable String getCustomName()138 {139 return this.customName == null ? null : LegacyComponentSerializer.legacySection().serialize(this.customName);140 }141 @Override142 public void setCustomName(@Nullable String name)143 {144 this.customName = name == null ? null : LegacyComponentSerializer.legacySection().deserialize(name);145 }146 @Override147 public boolean isLocked()148 {149 return this.lock != null && !this.lock.isEmpty();150 }151 @Override152 public @NotNull String getLock()153 {154 return this.lock;155 }156 @Override157 public void setLock(@Nullable String key)158 {159 this.lock = key;160 }161 /**162 * @return The tier of the beacon based on the blocks below it.163 */164 private int calculateBase()165 {166 int level = 0;167 for (int y = getY() - 1; y >= getY() - 4; y--)168 {169 if (y < getWorld().getMinHeight())170 {171 break;172 }173 int yOffset = getY() - y;174 for (int x = getX() - yOffset; x <= getX() + yOffset; ++x)175 {176 for (int z = getZ() - yOffset; z <= getZ() + yOffset; ++z)177 {178 if (!Bukkit.getTag(Tag.REGISTRY_BLOCKS, NamespacedKey.minecraft("beacon_base_blocks"), Material.class).isTagged(getWorld().getBlockAt(x, y, z).getType()))...

Full Screen

Full Screen

calculateBase

Using AI Code Generation

copy

Full Screen

1public void testCalculateBase()2{3 WorldMock world = server.addSimpleWorld("world");4 BeaconMock beacon = new BeaconMock(Material.BEACON, 1);5 Location location = new Location(world, 0, 0, 0);6 beacon.setLocation(location);7 beacon.calculateBase();8 assertEquals(location, beacon.getBaseLocation());9}

Full Screen

Full Screen

calculateBase

Using AI Code Generation

copy

Full Screen

1BeaconMock beacon = new BeaconMock(Material.BEACON);2beacon.calculateBase();3public void testCalculateBase()4{5 BeaconMock beacon = new BeaconMock(Material.BEACON);6 beacon.calculateBase();7}8BeaconMock beacon = new BeaconMock(Material.BEACON);9beacon.calculateBase();10public void testCalculateBase()11{12 BeaconMock beacon = new BeaconMock(Material.BEACON);13 beacon.calculateBase();14}15BeaconMock beacon = new BeaconMock(Material.BEACON);16beacon.calculateBase();17public void testCalculateBase()18{19 BeaconMock beacon = new BeaconMock(Material.BEACON);20 beacon.calculateBase();21}22BeaconMock beacon = new BeaconMock(Material.BEACON);23beacon.calculateBase();24public void testCalculateBase()25{26 BeaconMock beacon = new BeaconMock(Material.BEACON);27 beacon.calculateBase();28}

Full Screen

Full Screen

calculateBase

Using AI Code Generation

copy

Full Screen

1import be.seeseemelk.mockbukkit.block.state.BeaconMock2import org.bukkit.Location3import org.bukkit.block.Beacon4import org.jetbrains.annotations.NotNull5public static Location getBeaconBase(@NotNull Beacon beacon) {6 if (beacon instanceof BeaconMock) {7 return ((BeaconMock) beacon).calculateBase();8 }9 return beacon.getLocation();10}11package be.seeseemelk.mockbukkit;12import be.seeseemelk.mockbukkit.block.state.BeaconMock;13import org.bukkit.Location;14import org.bukkit.Material;15import org.bukkit.World;16import org.bukkit.block.Beacon;17import org.junit.After;18import org.junit.Before;19import org.junit.Test;20import static org.junit.Assert.*;21public class BeaconMockTest {22 private BeaconMock beaconMock;23 private BeaconMock beaconMockWithBase;24 public void setUp() {25 beaconMock = new BeaconMock();26 beaconMockWithBase = new BeaconMock();27 beaconMockWithBase.setBaseLocation(new Location(beaconMockWithBase.getWorld(), 0, 0, 0));28 }29 public void tearDown() {30 beaconMock = null;31 beaconMockWithBase = null;32 }33 public void calculateBase() {34 assertEquals(beaconMock.getLocation(), BeaconMock.calculateBase(beaconMock));35 assertEquals(beaconMockWithBase.getBaseLocation(), BeaconMock.calculateBase(beaconMockWithBase));36 }37 public void calculateBaseNotABeacon() {38 assertNull(BeaconMock.calculateBase(new MockBlockState(Material.DIAMOND_BLOCK)));39 }40 public void getBaseLocation() {41 assertNull(beaconMock.getBaseLocation());42 assertEquals(new Location(beaconMockWithBase.getWorld(), 0, 0, 0), beaconMockWithBase.getBaseLocation());43 }

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful