Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gradle/
build/
.idea/
resources/
run/
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ org.gradle.parallel=true
# check these on https://fabricmc.net/develop
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
loader_version=0.16.14
loader_version=0.16.10
loom_version=1.10-SNAPSHOT

# Mod Properties
mod_version=0.1.3-1.19.2
mod_version=0.1.7-1.19.2
maven_group=net.capozi.demise
archives_base_name=demise

Expand Down
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Binary file removed resources/assets/demise/icon.png
Binary file not shown.
12 changes: 0 additions & 12 deletions resources/demise.mixins.json

This file was deleted.

37 changes: 0 additions & 37 deletions resources/fabric.mod.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
import net.minecraft.nbt.NbtCompound;
import net.minecraft.screen.GenericContainerScreenHandler;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Arm;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

public class PlayerRemainsEntity extends LivingEntity implements VehicleInventory {

Expand Down Expand Up @@ -59,11 +63,27 @@ public void writeCustomDataToNbt(NbtCompound nbt) {

@Override
public boolean damage(DamageSource source, float amount) {
if(source.getAttacker() instanceof PlayerEntity player) {
if (source.getAttacker() instanceof PlayerEntity player) {
if(player.isSneaking()) {
if(world.isClient) return true;

if(getEntityWorld().isClient) return true;
this.dropInventory();
this.clearInventory();
Vec3d center = this.getPos();
double radius = 10.0;
Box box = new Box(
center.x - radius, center.y - (radius/2), center.z - radius,
center.x + radius, center.y + (radius/2), center.z + radius
);
List<LivingEntity> entities = this.getWorld().getEntitiesByClass(
LivingEntity.class,
box,
e -> e.squaredDistanceTo(center) <= radius * radius
);
for (LivingEntity entity : entities) {
if (entity instanceof ServerPlayerEntity playerEntity) {
playerEntity.closeHandledScreen();
}
}
this.discard();
return true;
}
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/net/capozi/demise/mixin/LivingEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.capozi.demise.common.TwoHanded;

Expand All @@ -24,32 +25,30 @@ public abstract class LivingEntityMixin {
@Shadow protected abstract void consumeItem();

@Inject(method = "getOffHandStack", at = @At("HEAD"), cancellable = true)
public void grimoire$getOffHandStack(CallbackInfoReturnable<ItemStack> cir) {
public void demise$getOffHandStack(CallbackInfoReturnable<ItemStack> cir) {
if((LivingEntity)(Object)this instanceof PlayerEntity player) {
if(player.getMainHandStack().getItem() instanceof TwoHanded) cir.setReturnValue(new ItemStack(Items.AIR));
}
}
@Inject(method = "damage", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;onDeath(Lnet/minecraft/entity/damage/DamageSource;)V"))
private void grimoire$onDeath(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
@Inject(method = "onDeath", at = @At("HEAD"))
private void demise$onDeath(DamageSource damageSource, CallbackInfo ci) {
if(((LivingEntity)(Object)this).getWorld().getGameRules().getBoolean(GameruleRegistry.CREATE_GRAVE) && (Object)this instanceof PlayerEntity player) {
if(player.getWorld().getGameRules().getBoolean(GameRules.KEEP_INVENTORY)) return;

if (!(((Object)this) instanceof PlayerEntity)) {
return;
}
PlayerRemainsEntity playerRemainsEntity = new PlayerRemainsEntity(EntityTypeRegistry.PLAYER_REMAINS_TYPE, player.world);
playerRemainsEntity.setPosition(player.getPos());

playerRemainsEntity.resetInventory();

for(int i = 0;i<player.getInventory().main.size();i++) {
playerRemainsEntity.addInventoryStack(player.getInventory().main.get(i).copy());
}
for(int i = 0;i<player.getInventory().offHand.size();i++) {
playerRemainsEntity.addInventoryStack(player.getInventory().offHand.get(i).copy());
}

for(int i = 0;i<player.getInventory().armor.size();i++) {
playerRemainsEntity.addInventoryStack(player.getInventory().armor.get(i).copy());
}

if(((LivingEntity)(Object)this).getWorld().getGameRules().getBoolean(GameruleRegistry.SAVE_TRINKETS)) {
if(FabricLoader.getInstance().isModLoaded("trinkets")) {
try{
Expand All @@ -62,7 +61,7 @@ public abstract class LivingEntityMixin {
playerRemainsEntity.setCustomName(player.getDisplayName());
playerRemainsEntity.setCustomNameVisible(true);

player.world.spawnEntity(playerRemainsEntity);
player.getWorld().spawnEntity(playerRemainsEntity);
player.getInventory().clear();
}
}
Expand Down
Binary file removed src/main/resources/assets/demise/icon.png
Binary file not shown.
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"id": "demise",
"version": "${version}",
"name": "Demise",
"description": "This is an example description! Tell everyone what your mod is about!",
"description": "Death is inconvenient? Not Anymore!",
"authors": [
"Me!"
"Capozi"
],
"contact": {
"homepage": "https://fabricmc.net/",
Expand Down