Skip to content

Commit

Permalink
1.0.1 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Oct 13, 2019
2 parents 12ad92b + 20193bd commit dcdd5c0
Show file tree
Hide file tree
Showing 15 changed files with 119 additions and 61 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.json]
indent_size = 2
35 changes: 22 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins {
id "net.minecrell.licenser" version "0.4.1"
id "com.matthewprenger.cursegradle" version "1.1.2"
id "maven-publish"
id "com.wynprice.cursemaven" version "1.2.3"
}

group = rootProject.maven_group
Expand Down Expand Up @@ -59,10 +60,6 @@ allprojects {
url "http://maven.fabricmc.net/"
name "Fabric"
}
maven {
url "https://jitpack.io"
name "JitPack"
}
}

task apiJar(type: Jar, dependsOn: apiClasses) {
Expand Down Expand Up @@ -95,7 +92,7 @@ allprojects {

// Fabric API. This is technically optional, but you probably want it anyway.
modApi "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Lazily evaluated callable returning a non-live (unlike a FileCollection) list of files
sourceSets.api.compileClasspath += files({sourceSets.main.compileClasspath.toList()})

Expand Down Expand Up @@ -138,16 +135,28 @@ allprojects {
}
}

repositories {
maven {
name = "NerdHubMC"
url = "https://maven.abusedmaster.xyz"
}
maven {
url "https://jitpack.io"
name "JitPack"
}
}

dependencies {
modImplementation("com.github.Ladysnake:Satin:${rootProject.satin_version}")
modApi("com.github.Ladysnake:Satin:${rootProject.satin_version}")
include "com.github.Ladysnake:Satin:${satin_version}"
modRuntime "io.github.prospector.modmenu:ModMenu:${modmenu_version}"
modApi "com.github.Pyrofab.Cardinal-Components-API:cardinal-components-base:${cca_version}"
include "com.github.Pyrofab.Cardinal-Components-API:cardinal-components-base:${cca_version}"
modImplementation "com.github.Pyrofab.Cardinal-Components-API:cardinal-components-entity:${cca_version}"
include "com.github.Pyrofab.Cardinal-Components-API:cardinal-components-entity:${cca_version}"
modImplementation "com.github.Pyrofab.Cardinal-Components-API:cardinal-components-world:${cca_version}"
include "com.github.Pyrofab.Cardinal-Components-API:cardinal-components-world:${cca_version}"
modApi "com.github.NerdHubMC.Cardinal-Components-API:cardinal-components-base:${cca_version}"
include "com.github.NerdHubMC.Cardinal-Components-API:cardinal-components-base:${cca_version}"
modImplementation "com.github.NerdHubMC.Cardinal-Components-API:cardinal-components-entity:${cca_version}"
include "com.github.NerdHubMC.Cardinal-Components-API:cardinal-components-entity:${cca_version}"
modImplementation "com.github.NerdHubMC.Cardinal-Components-API:cardinal-components-world:${cca_version}"
include "com.github.NerdHubMC.Cardinal-Components-API:cardinal-components-world:${cca_version}"
modImplementation curse.resolve('immersive-portals-mod', 2806496)
}

jar {
Expand All @@ -157,4 +166,4 @@ jar {

license {
exclude "**/RayHelper.java"
}
}
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
------------------------------------------------------
Version 1.0.1
------------------------------------------------------
Bug Fixes
- Possessed mobs now raise their arms when attacking or using a bow
- Fixed most incompatibilities with Immersive Portals

------------------------------------------------------
Version 1.0.0
------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion expansions/pandemonium/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
dependencies {
compile rootProject
modImplementation("com.github.Ladysnake:Satin:${rootProject.satin_version}")
}

jar {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
org.gradle.jvmargs = -Xmx5G

# Base properties
mod_version = 1.0.0
mod_version = 1.0.1
maven_group = io.github.Ladysnake

#General
Expand All @@ -15,7 +15,7 @@ loader_version=0.4.8+build.159
fabric_version=0.3.0+build.207

# Minecraft dependencies
cca_version = 2.0.1-pre2
cca_version = 2.0.3
modmenu_version=1.6.3-95
satin_version = 1.3.2

Expand Down
5 changes: 1 addition & 4 deletions src/main/java/ladysnake/requiem/Requiem.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,16 @@
import ladysnake.requiem.common.command.RequiemCommand;
import ladysnake.requiem.common.impl.ApiInitializer;
import ladysnake.requiem.common.impl.movement.MovementAltererManager;
import ladysnake.requiem.common.impl.remnant.RevivingDeathSuspender;
import ladysnake.requiem.common.impl.remnant.dialogue.ReloadableDialogueRegistry;
import ladysnake.requiem.common.impl.resurrection.ResurrectionDataLoader;
import ladysnake.requiem.common.item.RequiemItems;
import ladysnake.requiem.common.network.RequiemNetworking;
import ladysnake.requiem.common.network.ServerMessageHandling;
import ladysnake.requiem.common.sound.RequiemSoundEvents;
import nerdhub.cardinal.components.api.event.EntityComponentCallback;
import nerdhub.cardinal.components.api.event.WorldComponentCallback;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.registry.CommandRegistry;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -68,7 +65,7 @@ public void onInitialize() {
CommandRegistry.INSTANCE.register(false, RequiemCommand::register);
this.registerSubDataManagers();
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(ResurrectionDataLoader.INSTANCE);
EntityComponentCallback.event(PlayerEntity.class).register((player, components) -> components.put(RequiemComponents.DEATH_SUSPENDER, new RevivingDeathSuspender(player)));
RequiemComponents.initComponents();
SyncServerResourcesCallback.EVENT.register(player -> RequiemNetworking.sendTo(player, RequiemNetworking.createDataSyncMessage(SubDataManagerHelper.getServerHelper())));
ApiInitializer.setPluginCallback(this::registerPlugin);
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/ladysnake/requiem/common/RequiemComponents.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
import ladysnake.requiem.api.v1.remnant.DeathSuspender;
import ladysnake.requiem.api.v1.util.SubDataManager;
import ladysnake.requiem.common.impl.movement.MovementAltererManager;
import ladysnake.requiem.common.impl.remnant.RevivingDeathSuspender;
import nerdhub.cardinal.components.api.ComponentRegistry;
import nerdhub.cardinal.components.api.ComponentType;
import nerdhub.cardinal.components.api.component.ComponentProvider;
import nerdhub.cardinal.components.api.event.EntityComponentCallback;
import nerdhub.cardinal.components.api.util.ObjectPath;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;

public final class RequiemComponents {
Expand All @@ -46,4 +49,10 @@ public final class RequiemComponents {
public static final ComponentType<DeathSuspender> DEATH_SUSPENDER = ComponentRegistry.INSTANCE.registerIfAbsent(
Requiem.id("death_suspension"), DeathSuspender.class
);

public static void initComponents() {
EntityComponentCallback.event(PlayerEntity.class).register((player, components) -> {
components.put(DEATH_SUSPENDER, new RevivingDeathSuspender(player));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public boolean trigger(PlayerEntity player, Entity target) {
// We actually need to check if the entity has an attack damage attribute, because mojang doesn't.
boolean success = (ignoreDamageAttribute || owner.getAttributeInstance(EntityAttributes.ATTACK_DAMAGE) != null) && owner.tryAttack(target);
if (success && target instanceof LivingEntity) {
this.owner.setAttacking(true);
player.getMainHandStack().postHit((LivingEntity) target, player);
// Reset cooldown
player.resetLastAttackedTicks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ public final class PossessionComponentImpl implements PossessionComponent {
private static final Set<PlayerEntity> attributeUpdated = Collections.newSetFromMap(new MapMaker().weakKeys().makeMap());

private final PlayerEntity player;
@Nullable private UUID possessedUuid;
private int possessedNetworkId;
@Nullable private MobEntity possessed;
private int conversionTimer = -1;

public PossessionComponentImpl(PlayerEntity player) {
this.player = player;
this.possessedNetworkId = -1;
}

@Override
Expand Down Expand Up @@ -121,10 +119,9 @@ private void startPossessing0(MobEntity host, Possessable possessable) {
}
}
// Actually set the possessed entity
this.possessedUuid = host.getUuid();
this.possessedNetworkId = host.getEntityId();
this.possessed = host;
possessable.setPossessor(this.player);
this.syncPossessed();
this.syncPossessed(host.getEntityId());
// Update some attributes
this.player.copyPositionAndRotation(host);
this.player.calculateDimensions(); // update size
Expand Down Expand Up @@ -162,7 +159,6 @@ public void stopPossessing() {
public void stopPossessing(boolean transfer) {
LivingEntity possessed = this.getPossessedEntity();
if (possessed != null) {
this.possessedUuid = null;
this.resetState();
((Possessable)possessed).setPossessor(null);
if (player instanceof ServerPlayerEntity && transfer) {
Expand All @@ -181,9 +177,9 @@ public void stopPossessing(boolean transfer) {
}
}

private void syncPossessed() {
private void syncPossessed(int entityId) {
if (!this.player.world.isClient) {
sendToAllTrackingIncluding(this.player, createPossessionMessage(this.player.getUuid(), this.possessedNetworkId));
sendToAllTrackingIncluding(this.player, createPossessionMessage(this.player.getUuid(), entityId));
}
}

Expand All @@ -196,44 +192,36 @@ public MobEntity getPossessedEntity() {
if (!isPossessing()) {
return null;
}
// First attempt: use the network id (client & server)
Entity host = this.player.world.getEntityById(this.possessedNetworkId);
if (host == null) {

if (this.possessed.removed) {
UUID possessedUuid = this.possessed.getUuid();
Requiem.LOGGER.debug("{}: this player's possessed entity has disappeared", this.player);
this.resetState();
// Attempt to find an equivalent entity using the UUID
if (this.player.world instanceof ServerWorld) {
// Second attempt: use the UUID (server)
// method_14190 == getEntityByUuid
host = ((ServerWorld)this.player.world).getEntity(this.getPossessedEntityUuid());
}
// Set the possessed uuid to null to avoid infinite recursion
this.possessedUuid = null;
if (host instanceof MobEntity && host instanceof Possessable) {
this.startPossessing((MobEntity) host);
} else {
if (host != null) {
Requiem.LOGGER.warn("{}: this player's supposedly possessed entity ({}) cannot be possessed!", this.player, host);
Entity host = ((ServerWorld)this.player.world).getEntity(possessedUuid);
if (host instanceof MobEntity && host instanceof Possessable) {
this.startPossessing((MobEntity) host);
}
Requiem.LOGGER.debug("{}: this player's possessed entity is nowhere to be found", this);
this.resetState();
host = null;
}
}
return (MobEntity) host;
return this.possessed;
}

private void resetState() {
this.possessedNetworkId = -1;
this.possessed = null;
((RequiemPlayer) this.player).getMovementAlterer().setConfig(((RequiemPlayer)player).asRemnant().isSoul() ? SerializableMovementConfig.SOUL : null);
this.player.calculateDimensions(); // update size
this.player.setBreath(this.player.getMaxBreath());
syncPossessed();
syncPossessed(-1);
}

/**
* {@inheritDoc}
*/
@Override
public boolean isPossessing() {
return this.possessedUuid != null;
return this.possessed != null;
}

@Override
Expand Down Expand Up @@ -262,11 +250,6 @@ public void update() {
}
}

@CheckForNull
public UUID getPossessedEntityUuid() {
return this.possessedUuid;
}

@Override
public CompoundTag toTag(CompoundTag tag) {
tag.putInt("conversionTimer", this.conversionTimer);
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/ladysnake/requiem/common/item/DebugItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ public DebugItem(Settings item$Settings_1) {

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
if (player.isSneaking() && !world.isClient) {
debugMode = (debugMode + 1) % 2;
player.addChatMessage(new TranslatableText("Switched mode to %s", debugMode), true);
if (player.isSneaking()) {
if (!world.isClient) {
debugMode = (debugMode + 1) % 2;
player.addChatMessage(new TranslatableText("Switched mode to %s", debugMode), true);
}
} else {
switch (debugMode) {
case 0:
Expand Down
19 changes: 18 additions & 1 deletion src/main/java/ladysnake/requiem/mixin/item/BowItemMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,23 @@
import ladysnake.requiem.common.entity.internal.ItemStackConvertible;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.AbstractSkeletonEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.item.BowItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.RangedWeaponItem;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(BowItem.class)
public abstract class BowItemMixin extends RangedWeaponItem {
Expand All @@ -42,6 +47,14 @@ public BowItemMixin(Item.Settings settings) {
super(settings);
}

@Inject(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;setCurrentHand(Lnet/minecraft/util/Hand;)V"))
private void setAttackingMode(World world, PlayerEntity player, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> cir) {
MobEntity possessed = RequiemPlayer.from(player).asPossessor().getPossessedEntity();
if (possessed != null) {
possessed.setAttacking(true);
}
}

@Inject(
method = "onStoppedUsing",
at = @At(
Expand All @@ -52,7 +65,11 @@ public BowItemMixin(Item.Settings settings) {
)
)
private void setCurrentUser(ItemStack item, World world, LivingEntity user, int charge, CallbackInfo ci) {
REQUIEM__CURRENT_USER.set(((RequiemPlayer) user).asPossessor().getPossessedEntity());
MobEntity possessed = ((RequiemPlayer) user).asPossessor().getPossessedEntity();
REQUIEM__CURRENT_USER.set(possessed);
if (possessed != null) { // counterpart to setAttackingMode
possessed.setAttacking(false);
}
}

@ModifyVariable(method = "onStoppedUsing", ordinal = 0, at = @At("STORE"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void setPossessor(@CheckForNull PlayerEntity possessor) {
return;
}
// we need a cast here to trick the compiler
if (this.possessor != null && ((RequiemPlayer) this.possessor).asPossessor().getPossessedEntity() == (Entity)this) {
if (((this.possessor != null) && (((RequiemPlayer) this.possessor).asPossessor().getPossessedEntity() == (Entity) this)) && !this.world.isClient) {
throw new IllegalStateException("Players must stop possessing an entity before it can change possessor!");
}
this.possessor = possessor;
Expand Down
Loading

0 comments on commit dcdd5c0

Please sign in to comment.