Skip to content

Commit

Permalink
npc selections glow again
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Feb 8, 2024
1 parent faafb65 commit cc5c8c8
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 135 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/fabric-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ jobs:
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
run: ./gradlew fabric:build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' }}
uses: actions/upload-artifact@v2
with:
name: Artifacts
path: fabric/build/libs/
path: build/libs/
6 changes: 3 additions & 3 deletions .github/workflows/fabric-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ jobs:
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew fabric:build --stacktrace
run: ./gradlew :build --stacktrace

- name: Upload GitHub release
uses: AButler/upload-release-assets@v2.0
with:
files: 'fabric/build/libs/*.jar'
files: 'build/libs/*.jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Publish with Gradle
run: ./gradlew fabric:modrinth fabric:curseforge --stacktrace
run: ./gradlew modrinth curseforge --stacktrace
env:
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
Expand Down
46 changes: 0 additions & 46 deletions .github/workflows/forge-build.yml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/workflows/forge-release.yml

This file was deleted.

5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Dependencies
// Mod Dependencies

// Carpet Mod
modCompileOnly("com.github.gnembon:fabric-carpet:${project.carpet_core_version}")
// Disguiselib
//modCompileOnly("xyz.nucleoid:disguiselib-fabric:${project.disguiselib_version}")
//modCompileOnly 'com.github.NucleoidMC:DisguiseLib:1.20.4-SNAPSHOT'
//modImplementation(include('com.github.NucleoidMC:DisguiseLib:90bf223196'))

// Permission API
modImplementation(include('me.lucko:fabric-permissions-api:0.1-SNAPSHOT'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public Taterzens(Platform platform) {
LanguageUtil.setupLanguage();

PolymerEntityUtils.registerType(TATERZEN_TYPE.get());

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private static int loadTaterzenFromPreset(CommandContext<CommandSourceStack> con

((ITaterzenEditor) source.getPlayerOrException()).selectNpc(taterzenNPC);

taterzenNPC.sendProfileUpdates();
taterzenNPC.broadcastProfileUpdates();

source.sendSuccess(() ->
successText("taterzens.command.preset.import.success", filename),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static int mountTaterzen(CommandContext<CommandSourceStack> context) thro
taterzen.startRiding(finalToMount, true);
feedbackText = successText("taterzens.command.mount", taterzen.getName().getString(), finalToMount.getName().getString());
}
taterzen.sendProfileUpdates();
taterzen.broadcastProfileUpdates();
src.sendSuccess(() -> feedbackText, false);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private static int setCustomSkin(CommandContext<CommandSourceStack> context) thr
skinTag.putString("signature", signature);

taterzen.setSkinFromTag(skinTag);
taterzen.sendProfileUpdates();
taterzen.broadcastProfileUpdates();


context.getSource().sendSuccess(() ->
Expand All @@ -147,7 +147,7 @@ private static int copySkinLayers(CommandContext<CommandSourceStack> context) th
Byte skinLayers = player.getEntityData().get(getPLAYER_MODE_CUSTOMISATION());
taterzen.setSkinLayers(skinLayers);

taterzen.sendProfileUpdates();
taterzen.broadcastProfileUpdates();
source.sendSuccess(() ->
successText("taterzens.command.skin.mirrored", taterzen.getName().getString()),
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ public boolean selectNpc(@Nullable TaterzenNPC npc) {
this.selectedNpc = npc;

if (npc != null) {
npc.sendProfileUpdates();
npc.broadcastProfileUpdates();
}

if (selectedNpc != null) {
selectedNpc.sendProfileUpdates();
selectedNpc.broadcastProfileUpdates();
}

return true;
Expand Down
35 changes: 17 additions & 18 deletions src/main/java/org/samo_lego/taterzens/common/npc/TaterzenNPC.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.samo_lego.taterzens.common.npc;

import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
Expand Down Expand Up @@ -578,14 +577,14 @@ public void setCustomName(Component name) {
this.gameProfile = new GameProfile(this.getUUID(), profileName);
if (skin != null) {
this.setSkinFromTag(skin);
this.sendProfileUpdates();
this.broadcastProfileUpdates();
}
}

/**
* Updates Taterzen's {@link GameProfile} for others.
*/
public void sendProfileUpdates() {
public void broadcastProfileUpdates() {
if (this.level().isClientSide()) return;

ServerChunkCache manager = (ServerChunkCache) this.level().getChunkSource();
Expand All @@ -610,7 +609,7 @@ public void applySkin(GameProfile texturesProfile) {
setSkinFromTag(writeSkinToTag(texturesProfile));

// Sending updates
this.sendProfileUpdates();
this.broadcastProfileUpdates();
}

/**
Expand Down Expand Up @@ -726,7 +725,7 @@ public void readAdditionalSaveData(CompoundTag tag) {

ListTag pathTargets = (ListTag) npcTag.get("PathTargets");
if (pathTargets != null) {
if (pathTargets.size() > 0) {
if (!pathTargets.isEmpty()) {
pathTargets.forEach(posTag -> {
if (posTag instanceof CompoundTag pos) {
BlockPos target = new BlockPos(pos.getInt("x"), pos.getInt("y"), pos.getInt("z"));
Expand All @@ -739,7 +738,7 @@ public void readAdditionalSaveData(CompoundTag tag) {
this.npcData.currentMoveTarget = npcTag.getInt("CurrentMoveTarget");

ListTag messages = (ListTag) npcTag.get("Messages");
if (messages != null && messages.size() > 0) {
if (messages != null && !messages.isEmpty()) {
messages.forEach(msgTag -> {
CompoundTag msgCompound = (CompoundTag) msgTag;
this.addMessage(TextUtil.fromNbtElement(msgCompound.get("Message")), msgCompound.getInt("Delay"));
Expand Down Expand Up @@ -768,7 +767,7 @@ public void readAdditionalSaveData(CompoundTag tag) {

// Profession initialising
ListTag professions = (ListTag) npcTag.get("Professions");
if (professions != null && professions.size() > 0) {
if (professions != null && !professions.isEmpty()) {
professions.forEach(professionTag -> {
CompoundTag professionCompound = (CompoundTag) professionTag;

Expand Down Expand Up @@ -1884,17 +1883,17 @@ public EntityType<?> getPolymerEntityType(ServerPlayer player) {
@Override
public void modifyRawTrackedData(List<SynchedEntityData.DataValue<?>> data, ServerPlayer player, boolean initial) {
// Change game profile + skin layers
}

@Override
public List<Pair<EquipmentSlot, ItemStack>> getPolymerVisibleEquipment(List<Pair<EquipmentSlot, ItemStack>> items, ServerPlayer player) {
List<Pair<EquipmentSlot, ItemStack>> list = Lists.newArrayListWithCapacity(EquipmentSlot.values().length);

for (var slot : EquipmentSlot.values()) {
list.add(Pair.of(slot, this.getItemBySlot(slot)));
}

return list;
((ITaterzenEditor) player).getSelectedNpc().ifPresent(npc -> {
if (this == npc && config.glowSelectedNpc) {
data.removeIf(value -> value.id() == 7);
// Modify Taterzen to have fake glowing effect for the player
var flags = this.entityData.get(Entity.DATA_SHARED_FLAGS_ID);
flags = (byte) (flags | 1 << Entity.FLAG_GLOWING);

SynchedEntityData.DataValue<Byte> glowingTag = SynchedEntityData.DataValue.create(Entity.DATA_SHARED_FLAGS_ID, flags);
data.add(glowingTag);
}
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@
/**
* Base class for platform implementations.
*/
public abstract class Platform {
public interface Platform {

/**
* Gets the path to the directory where the config files are stored.
* @return the path to the directory where the config files are stored.
*/
public abstract Path getConfigDirPath();
Path getConfigDirPath();

/**
* Checks whether certain mod is loaded.
* @param modId the mod id.
* @return true if the mod is loaded, false otherwise.
*/
public abstract boolean isModLoaded(String modId);
boolean isModLoaded(String modId);

/**
* Gets size of item registry.
* @return size of item registry.
*/
public abstract int getItemRegistrySize();
int getItemRegistrySize();

/**
* Checks for permission of provided command source.
Expand All @@ -38,18 +38,17 @@ public abstract class Platform {
* @param fallbackLevel the fallback level to use if the permission node is not set.
* @return true if the command source has the permission node, false otherwise.
*/
public abstract boolean checkPermission(CommandSourceStack source, String permissionNode, int fallbackLevel);
boolean checkPermission(CommandSourceStack source, String permissionNode, int fallbackLevel);

/**
* Registers the taterzen entity type.
*/
public abstract void registerTaterzenType();
void registerTaterzenType();

public void openEditorGui(ServerPlayer player) {
}
void openEditorGui(ServerPlayer player);


public abstract void disguiseAs(TaterzenNPC taterzen, Entity entity);
void disguiseAs(TaterzenNPC taterzen, Entity entity);

public abstract void clearDisguise(TaterzenNPC taterzen);
void clearDisguise(TaterzenNPC taterzen);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static SimpleGui createCommandGui(ServerPlayer player, @Nullable SimpleGu
CommandNode<CommandSourceStack> childNode = (CommandNode<CommandSourceStack>) parentNode.getChildren().toArray()[0];
if (childNode instanceof ArgumentCommandNode) {
givenInput = false;
} else if (childNode.getChildren().size() > 0) {
} else if (!childNode.getChildren().isEmpty()) {
currentCommandPath.add(parentNode.getName());
} else {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import static org.samo_lego.taterzens.common.commands.NpcCommand.npcNode;
import static org.samo_lego.taterzens.fabric.gui.EditorGUI.createCommandGui;

public class FabricPlatform extends Platform {
public class FabricPlatform implements Platform {

private static final int REGISTRY_ITEMS_SIZE = ((AMappedRegistry<?>) BuiltInRegistries.ITEM).getById().size();

Expand Down

0 comments on commit cc5c8c8

Please sign in to comment.