Skip to content

Commit

Permalink
1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Dec 17, 2021
1 parent 8134fdb commit 2924b3d
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 42 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
name: Javadoc but Dokka

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types:
- published
workflow_dispatch:

jobs:
build:
Expand Down
4 changes: 3 additions & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
// Dokka docs
id "org.jetbrains.kotlin.jvm"
id("org.jetbrains.dokka")
}

Expand All @@ -11,6 +10,9 @@ dependencies {

modCompileOnly "xyz.nucleoid:disguiselib-fabric:${rootProject.disguiselib_version}"
modCompileOnly "com.github.samolego.Config2Brigadier:config2brigadier:${rootProject.c2b_version}"

// Built using vanillagradle, no need for remapping
//compileOnly("com.github.samolego:Config2Brigadier:55370d49b3")
modCompileOnly "eu.pb4:sgui:${rootProject.sgui_version}"
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.samo_lego.taterzens.api.professions;

import org.samo_lego.taterzens.npc.TaterzenNPC;

/**
* Class that you can extend to create your own professions.
*/
public class AbstractProfession implements TaterzenProfession {

/**
* TaterzenNPC that this profession is assigned to.
*/
protected TaterzenNPC npc;

public AbstractProfession() {
}

@Override
public TaterzenProfession create(TaterzenNPC taterzen) {
AbstractProfession profession = new AbstractProfession();
profession.npc = taterzen;
return profession;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package org.samo_lego.taterzens.commands.edit;

import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.suggestion.SuggestionProvider;
import com.mojang.brigadier.tree.LiteralCommandNode;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.synchronization.SuggestionProviders;
import net.minecraft.resources.ResourceLocation;
import org.samo_lego.taterzens.commands.NpcCommand;
import org.samo_lego.taterzens.npc.NPCData;

import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.synchronization.SuggestionProviders;
import net.minecraft.resources.ResourceLocation;

import static com.mojang.brigadier.arguments.StringArgumentType.word;
import static net.minecraft.commands.Commands.argument;
Expand All @@ -34,7 +35,7 @@ public class MovementCommand {
public static void registerNode(LiteralCommandNode<CommandSourceStack> editNode) {
LiteralCommandNode<CommandSourceStack> movementNode = literal("movement")
.requires(src -> permissions$checkPermission(src, "taterzens.npc.edit.movement", config.perms.npcCommandPermissionLevel))
.then(literal("FOLLOW")
.then(literal("follow")
.requires(src -> permissions$checkPermission(src, "taterzens.npc.edit.movement.follow", config.perms.npcCommandPermissionLevel))
.then(argument("follow type", word())
.suggests(FOLLOW_TYPES)
Expand All @@ -48,6 +49,11 @@ public static void registerNode(LiteralCommandNode<CommandSourceStack> editNode)
.suggests(MOVEMENT_TYPES)
.executes(context -> changeMovement(context, StringArgumentType.getString(context, "movement type")))
)
.then(literal("allowFlight")
.then(argument("allowFlight", BoolArgumentType.bool())
.executes(MovementCommand::setAllowFlight)
)
)
.build();


Expand All @@ -60,6 +66,14 @@ public static void registerNode(LiteralCommandNode<CommandSourceStack> editNode)
editNode.addChild(lookNode);
}

private static int setAllowFlight(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
CommandSourceStack source = context.getSource();
boolean allowFlight = BoolArgumentType.getBool(context, "allowFlight");
return NpcCommand.selectedTaterzenExecutor(source.getEntityOrException(), taterzen -> {
taterzen.setAllowFlight(allowFlight);
});
}

private static int changeMovement(CommandContext<CommandSourceStack> context, String movement) throws CommandSyntaxException {
CommandSourceStack source = context.getSource();
return NpcCommand.selectedTaterzenExecutor(source.getEntityOrException(), taterzen -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class EditorGUI {
private static final ItemStack NO_BUTTON = new ItemStack(Items.RED_STAINED_GLASS_PANE);
private static final HashMap<String, ItemStack> itemCommandMap = new HashMap<>();

@SuppressWarnings("unchecked")
public static SimpleGui createCommandGui(ServerPlayer player, SimpleGui previousScreen, CommandNode<CommandSourceStack> parentNode, List<String> currentCommandPath, boolean givenInput) {
// If node is not an argument, we skip to first child node that is an argument or has more than 1 child node
while (parentNode.getChildren().size() == 1 && !(parentNode instanceof ArgumentCommandNode<?, ?>)) {
Expand Down
7 changes: 4 additions & 3 deletions common/src/main/java/org/samo_lego/taterzens/npc/NPCData.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package org.samo_lego.taterzens.npc;

import com.mojang.datafixers.util.Pair;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;
import org.apache.commons.lang3.tuple.Triple;
import org.jetbrains.annotations.Nullable;
import org.samo_lego.taterzens.compatibility.BungeeCompatibility;

import java.util.ArrayList;
import java.util.UUID;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;

import static org.samo_lego.taterzens.Taterzens.config;

Expand Down Expand Up @@ -72,6 +72,7 @@ public class NPCData {
public Follow follow = new Follow();
public boolean allowSounds = !config.defaults.ambientSounds.isEmpty();
public ArrayList<Triple<BungeeCompatibility, String, String>> bungeeCommands = new ArrayList<>();
public boolean allowFlight = config.defaults.allowFlight;

public static class Follow {
/**
Expand Down
42 changes: 42 additions & 0 deletions common/src/main/java/org/samo_lego/taterzens/npc/TaterzenNPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -1544,4 +1544,46 @@ public ArrayList<Triple<BungeeCompatibility, String, String>> getBungeeCommands(
public void setRespawnPos(@Nullable Vec3 respawnPos) {
this.respawnPosition = respawnPos;
}

/**
* Sets whether taterzen should be able to fly.
* @param allowFlight whether to allow taterzen to fly or not.
*/
public void setAllowFlight(boolean allowFlight) {
this.npcData.allowFlight = allowFlight;
this.getNavigation().setCanFloat(allowFlight);
}

@Override
public void travel(Vec3 vec3) {
if (this.npcData.allowFlight) {
if (this.isInWater()) {
this.moveRelative(0.02F, vec3);
this.move(MoverType.SELF, this.getDeltaMovement());
this.setDeltaMovement(this.getDeltaMovement().scale(0.8F));
} else if (this.isInLava()) {
this.moveRelative(0.02F, vec3);
this.move(MoverType.SELF, this.getDeltaMovement());
this.setDeltaMovement(this.getDeltaMovement().scale(0.5));
} else {
float f = 0.91F;
if (this.onGround) {
f = this.level.getBlockState(new BlockPos(this.getX(), this.getY() - 1.0, this.getZ())).getBlock().getFriction() * 0.91F;
}

float g = 0.16277137F / (f * f * f);
f = 0.91F;
if (this.onGround) {
f = this.level.getBlockState(new BlockPos(this.getX(), this.getY() - 1.0, this.getZ())).getBlock().getFriction() * 0.91F;
}

this.moveRelative(this.onGround ? 0.1F * g : 0.02F, vec3);
this.move(MoverType.SELF, this.getDeltaMovement());
this.setDeltaMovement(this.getDeltaMovement().scale((double) f));
}
this.calculateEntityAnimation(this, false);
} else {
super.travel(vec3);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,26 @@ public static class Defaults {
/**
* Whether Taterzen is invulnerable by default.
*/
@BrigadierDescription(defaultOption = "true")
public boolean invulnerable = true;

@BrigadierDescription(defaultOption = "true")
@SerializedName("// Enable jumps when Taterzen is in attack mode.")
public final String _comment_jumpWhileAttacking = "";
/**
* Whether to enable jumps when Taterzen
* is in attack mode.
*/
@BrigadierDescription(defaultOption = "true")
@SerializedName("jump_while_attacking")
public boolean jumpWhileAttacking = true;

@SerializedName("// Whether Taterzen is able to fly.")
public final String _comment_allowFlight = "";

@BrigadierDescription(defaultOption = "false")
@SerializedName("allow_flight")
public boolean allowFlight = false;
}

/**
Expand Down
5 changes: 2 additions & 3 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
id 'com.matthewprenger.cursegradle'
id "com.modrinth.minotaur"
// Dokka docs
id "org.jetbrains.kotlin.jvm"
id("org.jetbrains.dokka")
}

Expand Down Expand Up @@ -42,14 +41,14 @@ dependencies {
modImplementation(include("com.github.samolego.Config2Brigadier:config2brigadier-fabric:${rootProject.c2b_version}"))

// Permission API
modImplementation(include('me.lucko:fabric-permissions-api:0.1-SNAPSHOT'))
modCompileOnly('me.lucko:fabric-permissions-api:0.1-SNAPSHOT')

// SGUI
modImplementation(include("eu.pb4:sgui:${rootProject.sgui_version}"))

// Carpet
//modImplementation("carpet:fabric-carpet:${rootProject.minecraft_version}-${project.carpet_core_version}")
modImplementation("carpet:fabric-carpet:1.18-pre4-${project.carpet_core_version}")
modCompileOnly("carpet:fabric-carpet:1.18-pre4-${project.carpet_core_version}")

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
import org.samo_lego.taterzens.api.professions.TaterzenProfession;
import org.samo_lego.taterzens.api.professions.AbstractProfession;
import org.samo_lego.taterzens.npc.NPCData;
import org.samo_lego.taterzens.npc.TaterzenNPC;

Expand All @@ -24,7 +24,7 @@

import static org.samo_lego.taterzens.Taterzens.MODID;

public class ScarpetProfession implements TaterzenProfession {
public class ScarpetProfession extends AbstractProfession {
private TaterzenNPC taterzen;
private static final TaterzenScarpetEvent PICKUP_EVENT = new TaterzenScarpetEvent("taterzen_tries_pickup", 3);
private static final TaterzenScarpetEvent INTERACTION_EVENT = new TaterzenScarpetEvent("taterzen_interacted", 5);
Expand Down Expand Up @@ -66,6 +66,7 @@ public boolean removeTrait(String scarpetTrait) {
public HashSet<Value> getTraits() {
return this.SCARPET_TRAITS;
}

@Override
public boolean tryPickupItem(ItemEntity itemEntity) {
PICKUP_EVENT.triggerCustomEvent(this.taterzen, this.getTraits(), itemEntity);
Expand All @@ -76,13 +77,13 @@ public boolean tryPickupItem(ItemEntity itemEntity) {
public InteractionResult interactAt(Player player, Vec3 pos, InteractionHand hand) {
INTERACTION_EVENT.triggerCustomEvent(this.taterzen, this.getTraits(), player, ValueConversions.of(pos), hand);

return TaterzenProfession.super.interactAt(player, pos, hand);
return super.interactAt(player, pos, hand);
}

@Override
public boolean handleAttack(Entity attacker) {
BEING_ATTACKED_EVENT.triggerCustomEvent(this.taterzen, this.getTraits(), attacker);
return TaterzenProfession.super.handleAttack(attacker);
return super.handleAttack(attacker);
}

@Override
Expand All @@ -93,7 +94,7 @@ public void onPlayersNearby(List<ServerPlayer> players) {
@Override
public InteractionResult tickMovement() {
TICK_MOVEMENT_EVENT.triggerCustomEvent(this.taterzen, this.getTraits());
return TaterzenProfession.super.tickMovement();
return super.tickMovement();
}

@Override
Expand Down Expand Up @@ -135,19 +136,12 @@ public void onBehaviourSet(NPCData.Behaviour behaviourLevel) {
@Override
public boolean cancelRangedAttack(LivingEntity target) {
TRY_RANGED_ATTACK_EVENT.triggerCustomEvent(this.taterzen, this.getTraits(), target);
return TaterzenProfession.super.cancelRangedAttack(target);
return super.cancelRangedAttack(target);
}

@Override
public boolean cancelMeleeAttack(Entity target) {
TRY_MELEE_ATTACK_EVENT.triggerCustomEvent(this.taterzen, this.getTraits(), target);
return TaterzenProfession.super.cancelMeleeAttack(target);
}

@Override
public TaterzenProfession create(TaterzenNPC taterzen) {
ScarpetProfession profession = new ScarpetProfession();
profession.taterzen = taterzen;
return profession;
return super.cancelMeleeAttack(target);
}
}
5 changes: 2 additions & 3 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
id 'com.matthewprenger.cursegradle'
id "com.modrinth.minotaur"
// Dokka docs
id "org.jetbrains.kotlin.jvm"
id("org.jetbrains.dokka")
}

Expand Down Expand Up @@ -34,11 +33,11 @@ dependencies {
forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}"

// Libs
modApi("com.github.samolego.Config2Brigadier:config2brigadier-forge:${rootProject.c2b_version}")
modImplementation("com.github.samolego.Config2Brigadier:config2brigadier-forge:${rootProject.c2b_version}")
shadowCommon("com.github.samolego.Config2Brigadier:config2brigadier-forge:${rootProject.c2b_version}") { transitive false }

// SGUI
modApi("com.github.samolego:forgified-sgui:${project.fsgui_version}")
modImplementation("com.github.samolego:forgified-sgui:${project.fsgui_version}")
shadowCommon("com.github.samolego:forgified-sgui:${project.fsgui_version}") { transitive false }


Expand Down
2 changes: 1 addition & 1 deletion forge/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
loom.platform=forge
fsgui_version = 1.0.0-rc5
fsgui_version = 1.0.0-rc8
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
@Mod(MODID)
public class TaterzensForge {

@SuppressWarnings("unchecked")
public TaterzensForge() {
taterDir = new File(FMLPaths.CONFIGDIR.get() + "/Taterzens/presets");
DISGUISELIB_LOADED = ModList.get().isLoaded("disguiselib");

//noinspection
TATERZEN_TYPE = (EntityType<TaterzenNPC>) EntityType.Builder
.of(TaterzenNPC::new, MobCategory.MISC)
.sized(0.6F, 1.8F)
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
minecraft_version=1.18
yarn_mappings=1.18+build.1
loader_version=0.12.8
minecraft_version=1.18.1
yarn_mappings=1.18.1+build.5
loader_version=0.12.12

#Fabric api
fabric_version=0.43.1+1.18
fabric_version=0.44.0+1.18

#Forge
forge_version=38.0.10
forge_version=39.0.5

# Mod Properties
mod_version = 1.6.4
mod_version = 1.6.5
maven_group = org.samo_lego
archives_base_name = taterzens

Expand Down

0 comments on commit 2924b3d

Please sign in to comment.