Skip to content

Commit

Permalink
refactor(android): use cache when update kv
Browse files Browse the repository at this point in the history
  • Loading branch information
StarWishsama committed Dec 22, 2024
1 parent 9107bf8 commit 36ba243
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;

import city.norain.slimefun4.api.menu.UniversalMenu;
import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import java.util.HashMap;
Expand Down Expand Up @@ -74,15 +75,15 @@ public enum Instruction {
*/
TURN_LEFT(AndroidType.NONE, HeadTexture.SCRIPT_LEFT, (android, b, inv, face) -> {
int mod = -1;
android.rotate(b, face, mod);
android.rotate(b, StorageCacheUtils.getUniversalBlock(inv.getUuid()), face, mod);
}),

/**
* This will make the {@link ProgrammableAndroid} rotate to the right side.
*/
TURN_RIGHT(AndroidType.NONE, HeadTexture.SCRIPT_RIGHT, (android, b, inv, face) -> {
int mod = 1;
android.rotate(b, face, mod);
android.rotate(b, StorageCacheUtils.getUniversalBlock(inv.getUuid()), face, mod);
}),

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ private void executeInstruction(
}
}

protected void rotate(Block b, BlockFace current, int mod) {
protected void rotate(Block b, SlimefunUniversalBlockData uniData, BlockFace current, int mod) {
int index = POSSIBLE_ROTATIONS.indexOf(current) + mod;

if (index == POSSIBLE_ROTATIONS.size()) {
Expand All @@ -878,7 +878,7 @@ protected void rotate(Block b, BlockFace current, int mod) {
}
}));

StorageCacheUtils.setData(b.getLocation(), "rotation", rotation.name());
uniData.setData("rotation", rotation.name());
}

protected void depositItems(UniversalMenu menu, Block facedBlock) {
Expand Down

0 comments on commit 36ba243

Please sign in to comment.