mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Duplication glitch fix and performance improvements for Rainbow blocks
This commit is contained in:
parent
bdb25b74ec
commit
bab94652bc
@ -30,15 +30,17 @@
|
|||||||
#### Changes
|
#### Changes
|
||||||
* Coolant Cells now last twice as long
|
* Coolant Cells now last twice as long
|
||||||
* Ticking blocks will now catch more errors caused by addons
|
* Ticking blocks will now catch more errors caused by addons
|
||||||
* Massive performance improvements
|
* Massive performance improvements to GPS/GEO machines, especially Oil Pump and GEO Miner
|
||||||
* Changed the texture for the Nuclear Reactor
|
* Changed the texture for the Nuclear Reactor
|
||||||
* Changed the texture for the Nether Star Reactor
|
* Changed the texture for the Nether Star Reactor
|
||||||
|
* Performance improvements to Rainbow Blocks
|
||||||
|
|
||||||
#### Fixes
|
#### Fixes
|
||||||
* Fixed #2005
|
* Fixed #2005
|
||||||
* Fixed #2009
|
* Fixed #2009
|
||||||
* Fixed a chunk caching issue for GEO resources
|
* Fixed a chunk caching issue for GEO resources
|
||||||
* Fixed Infused Magnet working even if you haven't researched it
|
* Fixed Infused Magnet working even if you haven't researched it
|
||||||
|
* Fixed Rainbow blocks duplication glitch when timing the block break right
|
||||||
|
|
||||||
## Release Candidate 13 (16 Jun 2020)
|
## Release Candidate 13 (16 Jun 2020)
|
||||||
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#13
|
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#13
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.implementation.items.gps;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RainbowBlock;
|
||||||
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.handlers.RainbowTicker;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link TeleporterPylon} is a special kind of {@link RainbowBlock} which is required
|
||||||
|
* for the {@link Teleporter}.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
* @see Teleporter
|
||||||
|
* @see RainbowBlock
|
||||||
|
* @see RainbowTicker
|
||||||
|
*/
|
||||||
|
public class TeleporterPylon extends RainbowBlock {
|
||||||
|
|
||||||
|
public TeleporterPylon(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
||||||
|
super(category, item, recipeType, recipe, recipeOutput, new RainbowTicker(Material.CYAN_STAINED_GLASS, Material.PURPLE_STAINED_GLASS));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -113,6 +113,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSMarkerTool
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSTransmitter;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSTransmitter;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.PersonalActivationPlate;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.PersonalActivationPlate;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.Teleporter;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.Teleporter;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.TeleporterPylon;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.InfernalBonemeal;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.InfernalBonemeal;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.InfusedMagnet;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.InfusedMagnet;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.KnowledgeFlask;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.KnowledgeFlask;
|
||||||
@ -2723,9 +2724,9 @@ public final class SlimefunItemSetup {
|
|||||||
|
|
||||||
}.register(plugin);
|
}.register(plugin);
|
||||||
|
|
||||||
new RainbowBlock(categories.gps, SlimefunItems.GPS_TELEPORTER_PYLON, RecipeType.ENHANCED_CRAFTING_TABLE,
|
new TeleporterPylon(categories.gps, SlimefunItems.GPS_TELEPORTER_PYLON, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||||
new ItemStack[] {SlimefunItems.ZINC_INGOT, new ItemStack(Material.GLASS), SlimefunItems.ZINC_INGOT, new ItemStack(Material.GLASS), SlimefunItems.HEATING_COIL, new ItemStack(Material.GLASS), SlimefunItems.ZINC_INGOT, new ItemStack(Material.GLASS), SlimefunItems.ZINC_INGOT},
|
new ItemStack[] {SlimefunItems.ZINC_INGOT, new ItemStack(Material.GLASS), SlimefunItems.ZINC_INGOT, new ItemStack(Material.GLASS), SlimefunItems.HEATING_COIL, new ItemStack(Material.GLASS), SlimefunItems.ZINC_INGOT, new ItemStack(Material.GLASS), SlimefunItems.ZINC_INGOT},
|
||||||
new CustomItem(SlimefunItems.GPS_TELEPORTER_PYLON, 8), new RainbowTicker(Material.CYAN_STAINED_GLASS, Material.PURPLE_STAINED_GLASS))
|
new CustomItem(SlimefunItems.GPS_TELEPORTER_PYLON, 8))
|
||||||
.register(plugin);
|
.register(plugin);
|
||||||
|
|
||||||
new Teleporter(categories.gps, SlimefunItems.GPS_TELEPORTATION_MATRIX, RecipeType.ENHANCED_CRAFTING_TABLE,
|
new Teleporter(categories.gps, SlimefunItems.GPS_TELEPORTATION_MATRIX, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||||
|
@ -26,30 +26,70 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|||||||
public class RainbowTicker extends BlockTicker {
|
public class RainbowTicker extends BlockTicker {
|
||||||
|
|
||||||
private final LoopIterator<Material> iterator;
|
private final LoopIterator<Material> iterator;
|
||||||
|
private final boolean waterlogged;
|
||||||
private Material material;
|
private Material material;
|
||||||
|
|
||||||
public RainbowTicker(Material... materials) {
|
public RainbowTicker(Material... materials) {
|
||||||
|
if (materials.length == 0) {
|
||||||
|
throw new IllegalArgumentException("A RainbowTicker must have at least one Material associated with it!");
|
||||||
|
}
|
||||||
|
|
||||||
|
waterlogged = containsWaterlogged(materials);
|
||||||
iterator = new LoopIterator<>(Arrays.asList(materials));
|
iterator = new LoopIterator<>(Arrays.asList(materials));
|
||||||
material = iterator.next();
|
material = iterator.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method checks whether a given {@link Material} array contains any {@link Material}
|
||||||
|
* that would result in a {@link Waterlogged} {@link BlockData}.
|
||||||
|
* This is done to save performance, so we don't have to validate {@link BlockData} at
|
||||||
|
* runtime.
|
||||||
|
*
|
||||||
|
* @param materials
|
||||||
|
* The {@link Material} Array to check
|
||||||
|
*
|
||||||
|
* @return Whether the array contained any {@link Waterlogged} materials
|
||||||
|
*/
|
||||||
|
private boolean containsWaterlogged(Material[] materials) {
|
||||||
|
for (Material type : materials) {
|
||||||
|
// This BlockData is purely virtual and only created on startup, it should have
|
||||||
|
// no impact on performance, in fact it should save performance as it preloads
|
||||||
|
// the data but also saves heavy calls for non-waterlogged Materials
|
||||||
|
if (type.createBlockData() instanceof Waterlogged) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public RainbowTicker(MaterialCollection collection) {
|
public RainbowTicker(MaterialCollection collection) {
|
||||||
this(collection.getAsArray());
|
this(collection.getAsArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick(Block b, SlimefunItem item, Config data) {
|
public void tick(Block b, SlimefunItem item, Config data) {
|
||||||
|
if (b.getType() == Material.AIR) {
|
||||||
|
// The block was broken, setting the Material now would result in a
|
||||||
|
// duplication glitch
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (waterlogged) {
|
||||||
BlockData blockData = b.getBlockData();
|
BlockData blockData = b.getBlockData();
|
||||||
boolean waterlogged = blockData instanceof Waterlogged && ((Waterlogged) blockData).isWaterlogged();
|
|
||||||
|
|
||||||
b.setType(material, true);
|
b.setType(material, true);
|
||||||
|
|
||||||
if (waterlogged) {
|
if (blockData instanceof Waterlogged && ((Waterlogged) blockData).isWaterlogged()) {
|
||||||
Waterlogged block = (Waterlogged) b.getBlockData();
|
Waterlogged block = (Waterlogged) b.getBlockData();
|
||||||
block.setWaterlogged(true);
|
block.setWaterlogged(true);
|
||||||
b.setBlockData(block);
|
b.setBlockData(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
b.setType(material, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uniqueTick() {
|
public void uniqueTick() {
|
||||||
|
Loading…
Reference in New Issue
Block a user