Skip to content

Conversation

@Virus5600
Copy link
Owner

Partial AAA implementation and healing fix.

Began adding unit tests to the source code, along with some additional changes.

[CHANGELOG]
🟢 Added Mod Sound Events class test.
🟢 Added Block Utility class test.
🟢 Added a new Idea run configuration.
🟢 Added a new method for adding a mod block to a block category.
🟢 Added support to Mod Menu mod.
🟢 Added "Issues" link to the contact list.
🟡 Updated formatting of the "Bug Report" issue template.
🟡 Updated formatting of the "Feature Request" issue template.
🟡 Updated Mod Blocks to match changes in the Block registration under Registry Util class.
🟡 Renamed the repair sound subtitles to match their sound IDs.
Updated some miscellaneous files such as CI/CD actions and unit tests.

[CHANGELOG]
🟢 Added "Run Unit Tests" composite action to the GitHub's workflow.
🟢 Re-Added Java 21 to the java matrix for compatibility checks to the said version.
🟢 Added Item Utility class unit test.
🔴 Removed the debug logger in the Sound Event unit test file.
Began the (re)implementation of the AA Turret. Its temporary model will use the MG Turret until its base features are implemented.

[CHANGELOG]
🟢 Added the AA Turret to the list of registered entities.
🟢 Added AA Turret entity class.
🟢 Added AA Turret todo items.
🟡 Updated the repair effects of block items to the turrets, adding Absorption II for a minute on top of the Resistance 2 for a minute.
🟡 Refactored the Turret Entity base class to now support the use of minimum look pitch, allowing for turrets to have a minimum look pitch and a maximum look pitch.
Partial Implementation of the AA Turret, which only targets flying entities.

[CHANGELOG]
🟢 Added the AA Turret's model and renderer, along with its necessary files.
🟢 Added the AA Turret's spawn item.
🟢 Added AA Turret's lang entries (English - US).
🟡 Fixed an issue with the minimum pitch wherein it was still limited due to an unchanged variable in the model class.
🟡 Updated some Javadoc to match its current target file.
🟡 Refactored the custom Projectile Attack goal class to allow a start and stop callbacks, providing a more dynamic control on an entity that uses it.
🟡 Changed the AA Turret's name and identifiers from "Anti-Air" to just "AA".
🟡 Updated the base Turret Entity class to now handle the changes made in custom attack goal.
🟡 Updated AA Turret's sounds to have a lower volume.
🟡 Updated AA Turret's TODO entries.
Implemented the AAA turret but needs reworking on its PFX when attacking.

Furthermore, refactored and moved around some files for a more organized project directory.

[CHANGELOG]
🟢 Created the client-side mod packet registry class.
🟢 Created a base class for S2C Packet Handler.
🟢 Created a base class for C2S Packet Handler.
🟢 Created a Registry utility class for the client-side.
🟢 Added a pre and post shoot callback to AA Turret's attack goal.
🟢 Added a new sound for the AA Turret so that it will now have a looping sound when attacking but not shooting (yet).
🟡 Moved all base classes into the utility package where all super classes and interface are now located.
🟡 Refactored the Projectile Attack Goal to now have a pre and post shoot callbacks, letting the entity to run codes before and after shooting.
🟡 Updated the start callback of AA Turret's attack goal.
🟡 Refactored the AA Turret to now try trigger an animation when shooting by overriding the `shoot()` method and `tick()` method.
🟡 Updated the AA Turret's animation in an attempt to fix PFX to no avail.
Fixed the old healing issue where items used for healing would not get "used up."
@Virus5600 Virus5600 requested a review from Copilot July 4, 2025 01:11
@Virus5600 Virus5600 self-assigned this Jul 4, 2025
@Virus5600 Virus5600 added the bug Something isn't working label Jul 4, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds initial support for the new Anti-Air (AA) turret and refactors shared utilities into base superclasses while fixing healing logic and updating package imports.

  • Introduces AA Turret item, entity, sounds, language entries, models, renderers, and animations.
  • Refactors networking and registry utilities (RegistryUtil, packet handler classes) for C2S/S2C payloads.
  • Adds addBlockToCategory helper and updates BlockUtil to allow mod blocks to be categorized automatically.

Reviewed Changes

Copilot reviewed 67 out of 72 changed files in this pull request and generated 3 comments.

File Description
BlockUtil.java Implements addBlockToCategory, but the contains-check logic is inverted.
sounds.json AA turret hurt subtitle key mismatches language file.
AATurretItem.java Flawed getTurretMaxHealth type check uses instanceof on Type object.

Comment on lines +388 to +418
if (DIRT.contains(block)) {
DIRT.add(block);
}
}
case GLASS -> {
if (GLASS.contains(block)) {
GLASS.add(block);
}
}
case GRAINY -> {
if (GRAINY.contains(block)) {
GRAINY.add(block);
}
}
case GREENERY -> {
if (GREENERY.contains(block)) {
GREENERY.add(block);
}
}
case METAL -> {
if (METAL.contains(block)) {
METAL.add(block);
}
}
case STONE -> {
if (STONE.contains(block)) {
STONE.add(block);
}
}
case WOOD -> {
if (WOOD.contains(block)) {
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is inverted: you only add the block when the category already contains it. It should check !DIRT.contains(block) before adding.

Suggested change
if (DIRT.contains(block)) {
DIRT.add(block);
}
}
case GLASS -> {
if (GLASS.contains(block)) {
GLASS.add(block);
}
}
case GRAINY -> {
if (GRAINY.contains(block)) {
GRAINY.add(block);
}
}
case GREENERY -> {
if (GREENERY.contains(block)) {
GREENERY.add(block);
}
}
case METAL -> {
if (METAL.contains(block)) {
METAL.add(block);
}
}
case STONE -> {
if (STONE.contains(block)) {
STONE.add(block);
}
}
case WOOD -> {
if (WOOD.contains(block)) {
if (!DIRT.contains(block)) {
DIRT.add(block);
}
}
case GLASS -> {
if (!GLASS.contains(block)) {
GLASS.add(block);
}
}
case GRAINY -> {
if (!GRAINY.contains(block)) {
GRAINY.add(block);
}
}
case GREENERY -> {
if (!GREENERY.contains(block)) {
GREENERY.add(block);
}
}
case METAL -> {
if (!METAL.contains(block)) {
METAL.add(block);
}
}
case STONE -> {
if (!STONE.contains(block)) {
STONE.add(block);
}
}
case WOOD -> {
if (!WOOD.contains(block)) {

Copilot uses AI. Check for mistakes.
Comment on lines 48 to 50
Type superClass = this.type.getClass().getGenericSuperclass();
if (superClass instanceof TurretEntity) {
maxHealth = ((AATurretEntity) superClass).getMaxHealth();
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

superClass is a Type, not an instance of TurretEntity. This check will always fail. You likely meant to inspect the runtime class or cast the item instance, not the generic superclass object.

Suggested change
Type superClass = this.type.getClass().getGenericSuperclass();
if (superClass instanceof TurretEntity) {
maxHealth = ((AATurretEntity) superClass).getMaxHealth();
Class<?> superClass = this.type.getClass().getSuperclass();
if (TurretEntity.class.isAssignableFrom(superClass)) {
maxHealth = ((AATurretEntity) this.type).getMaxHealth();

Copilot uses AI. Check for mistakes.
Refactored the entire code base to only show game-ready assets, removing AA Turret in all except the sounds (/playsound).

[CHANGELOG]
🟡 Commented out all AA Turret related entries in the existing code base.
🔴 Removed all AA Turret related classes, retaining its asset files.
@Virus5600 Virus5600 requested a review from Copilot July 4, 2025 01:41
@Virus5600 Virus5600 linked an issue Jul 4, 2025 that may be closed by this pull request

This comment was marked as outdated.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces partial Anti-Air turret support, refactors core classes into reusable superclasses, enhances utility registries, and adds extensive unit tests and resource updates:

  • Add AA turret assets (geometry, animations), sound/language entries, and placeholder registration code.
  • Refactor turret/item/entity classes into util.base.superclasses, updating imports across multiple modules.
  • Extend RegistryUtil for packet handler registration; enhance BlockUtil with category management; add unit tests for ItemUtil, BlockUtil, and ModSoundEvents.
Comments suppressed due to low confidence (3)

TODO.todo:12

  • [nitpick] Consider removing profanity from the TODO comment. A more professional tone will benefit project maintainability.
		- Properly calculate the parabolic trajectory (low priority) - Apparently, it was because of the "acceleration" modifier in the "ExplosiveProjectileEntity" class. Fuck.

src/main/java/com/virus5600/defensive_measures/util/ItemUtil.java:35

  • The method getObjectInstance can fall through without returning a value when isTypeMatch is false. You should return null at the end of the method to match the @Nullable annotation.
	@Nullable

src/client/java/com/virus5600/defensive_measures/model/entity/BaseTurretModel.java:152

  • Java's Math class doesn't provide a clamp method. Consider using MathHelper.clamp or the appropriate utility function.
		targetXRot = Math.clamp(targetXRot, minPitchChange, maxPitchChange);

@Virus5600 Virus5600 merged commit 3bec8f0 into main Jul 4, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update to 1.21.4

2 participants