Skip to content

Commit

Permalink
Hotfix 20230130 - Turret attack revert
Browse files Browse the repository at this point in the history
* Reverted all turret's attack calculations to its former
- Removed Sound Event packets
  • Loading branch information
Virus5600 committed Jan 30, 2023
1 parent c0c35af commit 1a40ade
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.fabricmc.api.ModInitializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
import software.bernie.example.GeckoLibMod;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -23,8 +22,6 @@ public class DefensiveMeasures implements ModInitializer {

@Override
public void onInitialize() {
GeckoLibMod.DISABLE_IN_DEV = true;

// Client & Server Side Initialization
ModItems.registerModItems();
ModSoundEvents.registerSoundEvents();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.virus5600.DefensiveMeasures.entity.custom;

import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -171,17 +170,15 @@ public void attack(LivingEntity target, float pullProgress) {
double vx = (target.getX() - this.getX()) * 1.0625;
double vy = target.getBodyY(2/3) - this.getY() + 0.25;
double vz = (target.getZ() - this.getZ()) * 1.0625;
double distance = Point2D.distance(target.getX(), target.getBodyY(2/3), this.getX(), this.getY());
double variance = Math.sqrt(vx * vx + vz * vz);
float divergence = 0 + this.world.getDifficulty().getId() * 2;
ProjectileEntity projectile = (ProjectileEntity) new BallistaArrowEntity(world, this);

projectile.setVelocity(vx, vy + (variance * 0.2f) - (distance * 0.5), vz, 1.5f, divergence);
projectile.setVelocity(vx, vy + variance * 0.2f, vz, 1.5f, divergence);
projectile.setPos(this.getX(), this.getY() + 0.8125, this.getZ());

this.world.spawnEntity(projectile);

this.playSound(this.getShootSound(), 1.0f, 1.0f / (this.getRandom().nextFloat() * 0.4f + 0.8f));
this.world.spawnEntity(projectile);
} catch (IllegalArgumentException | SecurityException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,8 @@ public void attack(LivingEntity target, float pullProgress) {
projectile.setVelocity(vx, vy + variance * 0.1f, vz, 1.5f, divergence);
projectile.setPos(this.getX(), this.getY() + 0.5, this.getZ());

this.world.spawnEntity(projectile);

this.playSound(this.getShootSound(), 1.0f, 1.0f / (this.getRandom().nextFloat() * 0.4f + 0.8f));
this.world.spawnEntity(projectile);
} catch ( IllegalArgumentException | SecurityException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,12 @@ public void tick() {

double variance = Math.sqrt(vx * vx + vz * vz);
float divergence = 0 + this.world.getDifficulty().getId() * 2;
ProjectileEntity projectile = (ProjectileEntity) new MGBulletEntity(world, this);

// Calculates the Y velocity (VY) of the projectile..
vy = (vy + variance * 0.2f);

ProjectileEntity projectile = (ProjectileEntity) new MGBulletEntity(world, this);
this.barrelPos = getRelativePos(0, -5, 0.46875);

projectile.setVelocity(vx, vy, vz, 1.5f, divergence + 0.25f);
projectile.setVelocity(vx, vy + variance * 0.2f, vz, 1.5f, divergence + 0.25f);
projectile.setPos(barrelPos.x + this.getPos(X), barrelPos.y + this.getPos(Y), barrelPos.z + this.getPos(Z));

this.playSound(this.getShootSound(), 1.0f, 1.0f / (this.getRandom().nextFloat() * 0.4f + 0.8f));

this.world.spawnEntity(projectile);
Expand All @@ -259,11 +255,9 @@ public void tick() {
}
else {
this.projectileShootCooldown--;

if (this.projectileShootCooldown == 0)
this.setShouldSkipAtt(false);
}

}
else {
this.getProjectilesFired = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.virus5600.DefensiveMeasures.networking;

import com.virus5600.DefensiveMeasures.DefensiveMeasures;
import com.virus5600.DefensiveMeasures.networking.packets.SoundEvent.*;
import com.virus5600.DefensiveMeasures.networking.packets.SpawnEvent.*;

import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
Expand All @@ -17,14 +16,12 @@ public class ModPackets {
*/
public static void registerC2SPackets() {
ServerPlayNetworking.registerGlobalReceiver(SPAWN_ENTITY_ID, SpawnEventC2SPacket::receive);
ServerPlayNetworking.registerGlobalReceiver(SOUND_EVENT_ID, SoundEventC2SPacket::receive);
}

/**
*A packet registry for <b>Server-to-Client</b>
*/
public static void registerS2CPackets() {
ClientPlayNetworking.registerGlobalReceiver(SPAWN_ENTITY_ID, SpawnEventS2CPacket::receive);
ClientPlayNetworking.registerGlobalReceiver(SPAWN_ENTITY_ID, SoundEventS2CPacket::receive);
}
}

This file was deleted.

This file was deleted.

0 comments on commit 1a40ade

Please sign in to comment.