Skip to content

Commit

Permalink
Fixed 20221113 - Finalizes Alpha Development
Browse files Browse the repository at this point in the history
+ Added Loot table for Ballista
+ Added Loot table for Cannon Turret
+ Added Loot table for MG Turret
* Updated version support from 1.19 to 1.19.2
* Updated mod to be on its beta phase
* Updated MG Turret to now drop its item instead of using the Ballista's
* Updated tag id for wooden slabs on Ballista's crafting recipe
* Updated tag id for wooden slabs on Cannon Turret's crafting recipe
* Updated item id for nether bricks on MG Turret's crafting recipe
  • Loading branch information
Virus5600 committed Nov 12, 2022
1 parent 052f3f4 commit 8337398
Show file tree
Hide file tree
Showing 19 changed files with 429 additions and 80 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repositories {
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.

// GeckoLib
maven { url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/' }
}
Expand All @@ -30,12 +30,12 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Uncomment the following line to enable the deprecated Fabric API modules.
// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.

// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
//GeckoLib

// GeckoLib
modImplementation 'software.bernie.geckolib:geckolib-fabric-1.19:3.1.6'
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19
yarn_mappings=1.19+build.4
loader_version=0.14.8
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
loader_version=0.14.10

# Mod Properties
mod_version = 1.0.0-1.19
mod_version = 1.0.0-beta-1.19.2
maven_group = com.virus5600
archives_base_name = defensive-measures

# Dependencies
fabric_version=0.57.0+1.19
fabric_version=0.66.0+1.19.2
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class ModEntities {
.dimensions(EntityDimensions.changing(0.875f, 0.875f))
.build()
);

/// PROJECTILES
// v1.0.0
public static final EntityType<CannonballEntity> CANNONBALL = Registry.register(
Expand All @@ -76,10 +76,10 @@ public class ModEntities {
.dimensions(EntityDimensions.fixed(0.125f, 0.125f))
.build()
);

public static void registerModEntities() {
DefensiveMeasures.LOGGER.debug("REGISTERING ENTITIES FOR " + DefensiveMeasures.MOD_NAME);

/// TURRETS
// v1.0.0
EntityRendererRegistry.register(ModEntities.CANNON_TURRET, CannonTurretRenderer::new);
Expand All @@ -88,7 +88,7 @@ public static void registerModEntities() {
FabricDefaultAttributeRegistry.register(ModEntities.BALLISTA, BallistaTurretEntity.setAttributes());
EntityRendererRegistry.register(ModEntities.MG_TURRET, MGTurretRenderer::new);
FabricDefaultAttributeRegistry.register(ModEntities.MG_TURRET, MGTurretEntity.setAttributes());

/// PROJECTILES
// v1.0.0
EntityRendererRegistry.register(ModEntities.CANNONBALL, CannonballRenderer::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,27 @@ public class BallistaTurretEntity extends TurretEntity implements IAnimatable, R
@Nullable
private LivingEntity currentTarget = null;
private double attCooldown = totalAttCooldown;

// CONSTRUCTORS //
public BallistaTurretEntity(EntityType<? extends MobEntity> entityType, World world) {
super(entityType, world, TurretMaterial.WOOD, BallistaArrowEntity.class);
this.setShootSound(ModSoundEvents.TURRET_BALLISTA_SHOOT);
this.addHealables(healables);
this.addEffectSource(effectSource);
}

// METHODS //
// PRIVATE
private <E extends IAnimatable> PlayState idlePredicate(AnimationEvent<E> event) {
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.ballista.setup", true));
return PlayState.CONTINUE;
}

private <E extends IAnimatable> PlayState lookAtTargetPredicate(AnimationEvent<E> event) {
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.ballista.look_at_target", true));
return PlayState.CONTINUE;
}

private boolean animPlayed = false;
private <E extends IAnimatable> PlayState deathPredicate(AnimationEvent<E> event) {
if (!this.isAlive() && !animPlayed) {
Expand All @@ -87,25 +87,25 @@ private <E extends IAnimatable> PlayState deathPredicate(AnimationEvent<E> event
}
return PlayState.CONTINUE;
}

private <E extends IAnimatable> PlayState firingSequencePredicate(AnimationEvent<E> event) {
if (this.hasTarget() && this.isShooting()) {
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.ballista.shoot"));
event.getController().markNeedsReload();
this.setShooting(false);
}

return PlayState.CONTINUE;
}

// PROTECTED
@Override
protected void initGoals() {
// Goals
this.goalSelector.add(1, new ProjectileAttackGoal(this, 0, totalAttCooldown, 16.8125F));
this.goalSelector.add(2, new LookAtEntityGoal(this, MobEntity.class, 8.0F, 0.02F, true));
this.goalSelector.add(8, new LookAroundGoal(this));

// Targets
this.targetSelector.add(1, new ActiveTargetGoal<MobEntity>(this, MobEntity.class, 10, true, false, (entity) -> {
return entity instanceof Monster;
Expand All @@ -123,7 +123,7 @@ protected void initDataTracker() {
protected SoundEvent getHurtSound(DamageSource source) {
return ModSoundEvents.TURRET_BALLISTA_HURT;
}

@Nullable
@Override
protected SoundEvent getDeathSound() {
Expand All @@ -138,7 +138,7 @@ public static DefaultAttributeContainer.Builder setAttributes() {
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0f)
.add(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, 999999f);
}

@Override
public void registerControllers(AnimationData data) {
data.addAnimationController(new AnimationController<IAnimatable>(this, "idle", 20, this::idlePredicate));
Expand All @@ -151,61 +151,61 @@ public void registerControllers(AnimationData data) {
public AnimationFactory getFactory() {
return this.factory;
}

public ItemStack getEntityItem() {
ItemStack stack = new ItemStack(ModItems.BALLISTA, 1);
return stack;
}

@Override
public void attack(LivingEntity target, float pullProgress) {
this.setShooting(true);

if (target == null) {
this.setShooting(false);
return;
}

try {
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 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, vz, 1.5f, divergence);
projectile.setPos(this.getX(), this.getY() + 0.8125, this.getZ());

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();
}
}

@Override
public void tick() {
super.tick();

this.setYaw(0);
this.setBodyYaw(0);

if (!this.world.isClient()) {
// FIRING ANIMATING RELATED
this.setTrackedYaw(this.getHeadYaw());
this.setTrackedPitch(this.getPitch());
this.setPos(X, this.getX());
this.setPos(Y, this.getY() + 0.5);
this.setPos(Z, this.getZ());

if (this.hasTarget()) {
this.setPos(TARGET_POS_X, this.getTarget().getX());
this.setPos(TARGET_POS_Y, this.getTarget().getBodyY(1/2));
this.setPos(TARGET_POS_Z, this.getTarget().getZ());

--this.attCooldown;

if (this.attCooldown <= 0)
this.attCooldown = 20 * 2.5;
else if (this.attCooldown <= 45)
Expand All @@ -218,12 +218,12 @@ else if (this.attCooldown <= 45)
}
}
}

@Override
public ActionResult interactMob(PlayerEntity player, Hand hand) {
return Itemable.tryItem(player, hand, this, ModItems.TURRET_REMOVER, ModItems.BALLISTA).orElse(super.interactMob(player, hand));
}

static {
healables = new HashMap<Item, Float>() {
private static final long serialVersionUID = 1L;
Expand All @@ -236,7 +236,7 @@ public ActionResult interactMob(PlayerEntity player, Hand hand) {
put(item, 25f);
}
};

effectSource = new HashMap<Item, List<Object[]>>() {
private static final long serialVersionUID = 1L;
{
Expand Down
Loading

0 comments on commit 8337398

Please sign in to comment.