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
resources
run
.idea
32 changes: 14 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@ base {
}

repositories {
repositories {
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/"
}
maven {
name = "Ladysnake Libs"
url = 'https://maven.ladysnake.org/releases'
}
maven {
url "https://cursemaven.com"
}
maven {
url = "https://api.modrinth.com/maven"
}
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/"
}
maven {
name = "Ladysnake Libs"
url = 'https://maven.ladysnake.org/releases'
}
maven {
url "https://cursemaven.com"
}
maven {
url = "https://api.modrinth.com/maven"
}
}

Expand All @@ -43,10 +41,8 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
include modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca_version}")
include modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cca_version}")
include modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-world:${project.cca_version}")
include modImplementation("dev.emi:trinkets:${project.trinkets_version}")

}

processResources {
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
loader_version=0.16.14
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.16.10
loom_version=1.10-SNAPSHOT

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

# Dependencies
fabric_version=0.77.0+1.19.2
trinkets_version=3.4.1
fabric_version=0.92.5+1.20.1
trinkets_version=3.7.2

# Cardinal Components
cca_version = 5.0.2
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
6 changes: 3 additions & 3 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions qodana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"

#Specify inspection profile for code analysis
profile:
name: qodana.starter

#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>

#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>

projectJDK: "17" #(Applied in CI/CD pipeline)

#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh

#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)

#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-jvm-community:2025.1
5 changes: 4 additions & 1 deletion src/main/java/net/capozi/demise/Demise.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package net.capozi.demise;

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.capozi.demise.common.GameruleRegistry;
import net.capozi.demise.common.entity.EntityTypeRegistry;
import net.fabricmc.api.ModInitializer;
import net.minecraft.util.Identifier;
Expand All @@ -9,10 +12,10 @@
public class Demise implements ModInitializer {
public static final String MOD_ID = "demise";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

@Override
public void onInitialize() {
EntityTypeRegistry.register();
GameruleRegistry.register();
}
public static Identifier id(String name) {
return Identifier.of(MOD_ID, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@

public class EntityTypeRegistry {
//public static final EntityModelLayer PLAYER_REMAINS_MODEL_LAYER = new EntityModelLayer(Grimoire.id("player_remains"), "main");
public static final EntityType<PlayerRemainsEntity> PLAYER_REMAINS_TYPE = Registry.register(Registries.ENTITY_TYPE,
Demise.id("player_remains"),
FabricEntityTypeBuilder.create(SpawnGroup.MISC, PlayerRemainsEntity::new).dimensions(EntityDimensions.changing(0.8f, 0.8f)).build());

public static final EntityType<PlayerRemainsEntity> PLAYER_REMAINS_TYPE = Registry.register(Registries.ENTITY_TYPE, Demise.id("player_remains"), FabricEntityTypeBuilder.create(SpawnGroup.MISC, PlayerRemainsEntity::new).dimensions(EntityDimensions.changing(0.8f, 0.8f)).build());
public static void register() {
FabricDefaultAttributeRegistry.register(PLAYER_REMAINS_TYPE, PlayerRemainsEntity.createAttributes());
}
Expand Down
104 changes: 77 additions & 27 deletions src/main/java/net/capozi/demise/common/entity/PlayerRemainsEntity.java
Original file line number Diff line number Diff line change
@@ -1,42 +1,68 @@
package net.capozi.demise.common.entity;

import com.mojang.authlib.GameProfile;
import net.capozi.demise.common.GameruleRegistry;
import net.minecraft.entity.*;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.entity.vehicle.VehicleInventory;
import net.minecraft.inventory.Inventories;
import net.minecraft.item.*;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtHelper;
import net.minecraft.screen.GenericContainerScreenHandler;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
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 net.minecraft.world.event.GameEvent;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;

public class PlayerRemainsEntity extends LivingEntity implements VehicleInventory {
public PlayerEntity playerFor;
private static final int MAX_SIZE = 27*2; // Maximum inventory size
private DefaultedList<ItemStack> inventory;

public PlayerRemainsEntity(EntityType<? extends LivingEntity> entityType, World world) {
protected PlayerRemainsEntity(EntityType<? extends LivingEntity> entityType, World world) {
super(entityType, world);
this.setInvulnerable(true);
this.inventory = DefaultedList.ofSize(MAX_SIZE, ItemStack.EMPTY);
}
private PlayerRemainsEntity(EntityType<? extends LivingEntity> entityType, World world, PlayerEntity player) {
super(entityType, world);
this.setInvulnerable(true);
this.playerFor = player;
this.inventory = DefaultedList.ofSize(MAX_SIZE, ItemStack.EMPTY);
}
public static PlayerRemainsEntity create(EntityType<? extends LivingEntity> type, World world, PlayerEntity player) {
return new PlayerRemainsEntity(type, world, player);
}
public static DefaultAttributeContainer.Builder createAttributes() {
return LivingEntity.createLivingAttributes()
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0f)
.add(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, 100f)
.add(EntityAttributes.GENERIC_FOLLOW_RANGE, 0f);
}

@Override
public boolean isGlowing() {
return true;
}

@Override
public void readCustomDataFromNbt(NbtCompound nbt) {
super.readCustomDataFromNbt(nbt);
Expand All @@ -49,10 +75,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(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 Expand Up @@ -93,6 +136,30 @@ public void addInventoryStack(ItemStack stack) {
}
}
@Override
public void onPlayerCollision(PlayerEntity player) {
if (this.getWorld().isClient) return;
if (!player.getGameProfile().getName().equals(playerFor.getEntityName())) return;

for (int i = 0; i < inventory.size(); i++) {
if (!player.getInventory().insertStack(inventory.get(i))) {
player.dropItem(inventory.get(i), false);
} else {
this.getWorld().playSound(
null,
player.getX(),
player.getY(),
player.getZ(),
SoundEvents.ENTITY_ITEM_PICKUP,
SoundCategory.PLAYERS,
0.2F,
(player.getSoundPitch() - player.getSoundPitch()) * 0.7F + 1.0F * 2.0F
);
}
}

discard();
}
@Override
public DefaultedList<ItemStack> getInventory() {
return inventory;
}
Expand Down Expand Up @@ -154,45 +221,28 @@ public ItemStack getEquippedStack(EquipmentSlot slot) {
return new ItemStack(Items.AIR);
}
@Override
public void equipStack(EquipmentSlot slot, ItemStack stack) {

}
public void equipStack(EquipmentSlot slot, ItemStack stack) {}
@Override
public Arm getMainArm() {
return Arm.RIGHT;
}
@Override
public boolean isPushable() {
return false;
return true;
}
@Override
public boolean isPushedByFluids() {
return false;
}
@Override
protected void initDataTracker() {
super.initDataTracker();
return true;
}
//region// No clue //
@Override
public @Nullable Identifier getLootTableId() {
return null;
}
@Override
public void setLootTableId(@Nullable Identifier lootTableId) {

}
@Override
public long getLootTableSeed() {
return 0;
}
public void setLootTableId(@Nullable Identifier lootTableId) {}
@Override
public void setLootTableSeed(long lootTableSeed) {

}
public void setLootTableSeed(long lootTableSeed) {}
@Override
public void markDirty() {

}
//endregion
public void markDirty() {}
}
Loading