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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "maven.modrinth:valkyrien-skies:1.20.1-fabric-2.3.0-beta.5"
modImplementation "maven.modrinth:eureka:1.20.1-fabric-1.5.1-beta.3"
modImplementation "maven.modrinth:valkyrien-sails:1.20.1-0.1.6-fabric"

modImplementation "maven.modrinth:vlib:1.20.1-0.0.11-alpha+fabric"
modImplementation "maven.modrinth:valkyrien-sails:1.20.1-0.1.7-fabric"
modImplementation "maven.modrinth:musket-mod:1.5.4"

modImplementation "maven.modrinth:architectury-api:9.2.14+fabric"

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fabric_kotlin_version=1.10.19+kotlin.1.9.23
# Mod Properties
mod_version=1.8.2
maven_group=ace.actually.pirates
archives_base_name=ValkyrienPirates
archives_base_name=DinBrosValkyrienPirates

# Dependencies
fabric_version=0.92.1+1.20.1
33 changes: 32 additions & 1 deletion src/main/java/ace/actually/pirates/ClientPirates.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,37 @@ public void onInitializeClient() {

//EntityModelLayerRegistry.registerModelLayer(SKELETON_PIRATE, SkeletonPirateModel::getTexturedModelData);

}

net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking.registerGlobalReceiver(
Pirates.CANNON_SMOKE_PACKET_ID,
(client, handler, buf, sender) -> {
double x = buf.readDouble();
double y = buf.readDouble();
double z = buf.readDouble();
int dirId = buf.readInt();

client.execute(() -> {
var world = client.world;
if (world == null) return;

var direction = net.minecraft.util.math.Direction.byId(dirId);
for (int i = 0; i < 40; ++i) {
world.addParticle(net.minecraft.particle.ParticleTypes.FLAME,
x + direction.getOffsetX() * (0.5 + world.random.nextDouble() * 1.5),
y + direction.getOffsetY() + (world.random.nextDouble() * 1.0) - 0.5,
z + direction.getOffsetZ() * (0.5 + world.random.nextDouble() * 1.5),
(world.random.nextDouble() * 0.3) - 0.15,
(world.random.nextDouble() * 0.1) - 0.05,
(world.random.nextDouble() * 0.3) - 0.15);

world.addParticle(net.minecraft.particle.ParticleTypes.CLOUD,
x + direction.getOffsetX() * (3.5 + world.random.nextDouble() * 2) + (4 * world.random.nextDouble()) - 2,
y + (world.random.nextDouble() * 3.0) - 1.0,
z + direction.getOffsetZ() * (3.5 + world.random.nextDouble() * 2) + (4 * world.random.nextDouble()) - 2,
0.0, 0.0, 0.0);
}
});
}
);
}
}
19 changes: 18 additions & 1 deletion src/main/java/ace/actually/pirates/Pirates.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class Pirates implements ModInitializer {
// That way, it's clear which mod wrote info, warnings, and errors.
public static final String MOD_ID = "pirates";
public static final Logger LOGGER = LoggerFactory.getLogger("pirates");

public static final Identifier CANNON_SMOKE_PACKET_ID = new Identifier(MOD_ID, "cannon_smoke");
public static final GameRules.Key<GameRules.BooleanRule> PIRATES_IS_LIVE_WORLD =
GameRuleRegistry.register("piratesIsLive", GameRules.Category.MISC, GameRuleFactory.createBooleanRule(true));

Expand Down Expand Up @@ -192,6 +192,18 @@ private void registerEntityThings()
public static final StableBlock STABLE_BLOCK = new StableBlock(AbstractBlock.Settings.create());
public static final ShipIdBlock SHIP_ID_BLOCK = new ShipIdBlock(AbstractBlock.Settings.create());
public static final Block HEAVY_BLOCK = new Block(AbstractBlock.Settings.copy(Blocks.OBSIDIAN));
public static final DamagedHullBlock DAMAGED_HULL_BLOCK = new DamagedHullBlock(
AbstractBlock.Settings.copy(Blocks.NETHERITE_BLOCK)
.strength(0.5f, 1200.0f)
.noBlockBreakParticles()
.noCollision()
.dropsNothing()
);
public static final BlockEntityType<DamagedHullBlockEntity> DAMAGED_HULL_BLOCK_ENTITY = Registry.register(
Registries.BLOCK_ENTITY_TYPE,
new Identifier("pirates", "damaged_hull_block_entity"),
FabricBlockEntityTypeBuilder.create(DamagedHullBlockEntity::new, DAMAGED_HULL_BLOCK).build()
);
private void registerBlocks()
{
Registry.register(Registries.BLOCK,new Identifier("pirates","cannon_priming_block"),CANNON_PRIMING_BLOCK);
Expand All @@ -202,6 +214,8 @@ private void registerBlocks()
Registry.register(Registries.BLOCK,new Identifier("pirates","ship_id_block"),SHIP_ID_BLOCK);
Registry.register(Registries.BLOCK,new Identifier("pirates","heavy_block"),HEAVY_BLOCK);

// my custom blocks
Registry.register(Registries.BLOCK, new Identifier("pirates", "damaged_hull_block"), DAMAGED_HULL_BLOCK);
}


Expand Down Expand Up @@ -232,6 +246,9 @@ private void registerItems()
Registry.register(Registries.ITEM,new Identifier("pirates","crew_spawner_block"),new BlockItem(CREW_SPAWNER_BLOCK,new Item.Settings()));
Registry.register(Registries.ITEM,new Identifier("pirates","ship_id_block"),new BlockItem(SHIP_ID_BLOCK,new Item.Settings()));

// my custom blocks
Registry.register(Registries.ITEM, new Identifier("pirates", "damaged_hull_block"),
new BlockItem(DAMAGED_HULL_BLOCK, new Item.Settings()));
}


Expand Down
34 changes: 34 additions & 0 deletions src/main/java/ace/actually/pirates/blocks/DamagedHullBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package ace.actually.pirates.blocks;
import ace.actually.pirates.Pirates;
import ace.actually.pirates.blocks.entity.DamagedHullBlockEntity;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockWithEntity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class DamagedHullBlock extends BlockWithEntity {

public DamagedHullBlock(Settings settings) {
super(settings);
}

@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new DamagedHullBlockEntity(pos, state);
}

@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.INVISIBLE;
}

@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return checkType(type, Pirates.DAMAGED_HULL_BLOCK_ENTITY, DamagedHullBlockEntity::tick);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
import net.minecraft.state.property.Properties;
import net.minecraft.text.Text;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Position;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.*;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
Expand Down Expand Up @@ -86,5 +83,4 @@ public void neighborUpdate(BlockState state, World world, BlockPos pos, Block so
public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
return new ItemStack(Items.DISPENSER);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ private static boolean checkShouldFire(World world, BlockPos pos, BlockState sta
return false;
}

// original is (2;32)
RaycastContext context = new RaycastContext(
VSGameUtilsKt.toWorldCoordinates(world, Vec3d.ofCenter(pos.add(raycastStart.multiply(2)))),
VSGameUtilsKt.toWorldCoordinates(world, Vec3d.ofCenter(pos.add(raycastStart.multiply(32)))),
VSGameUtilsKt.toWorldCoordinates(world, Vec3d.ofCenter(pos.add(raycastStart.multiply(30)))),
VSGameUtilsKt.toWorldCoordinates(world, Vec3d.ofCenter(pos.add(raycastStart.multiply(80)))),
RaycastContext.ShapeType.COLLIDER,
RaycastContext.FluidHandling.NONE,
null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
package ace.actually.pirates.blocks.entity;

import ace.actually.pirates.Pirates;
import ace.actually.pirates.blocks.CannonPrimingBlock;
import ace.actually.pirates.entities.pirate_abstract.AbstractPirateEntity;
import ace.actually.pirates.entities.pirate_default.PirateEntity;
import ace.actually.pirates.entities.pirate_skeleton.SkeletonPirateEntity;
import ace.actually.pirates.events.IPirateSpawns;
import ace.actually.pirates.entities.CrewSpawnType;
import ace.actually.pirates.entities.CrewTypes;
import ace.actually.pirates.util.ConfigUtils;
import ewewukek.musketmod.Items;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
//import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.network.EntityTrackerEntry;
import net.minecraft.server.world.ServerWorld;
Expand All @@ -31,6 +34,7 @@
import net.minecraft.world.EntityList;

import java.util.Optional;
import java.util.Random;

public class CrewSpawnerBlockEntity extends BlockEntity {

Expand Down Expand Up @@ -112,19 +116,20 @@ private static BlockPos checkForBlocksToCrew (World world, BlockPos origin) {

private static Entity getEntityFromState(World world, BlockEntity be) {
Entity crew = null;
Item randomGun = AbstractPirateEntity.guns[new Random().nextInt(AbstractPirateEntity.guns.length)];
switch (be.getCachedState().get(CrewTypes.CREW_SPAWN_TYPE))
{
case PIRATE ->
{
crew = new PirateEntity(world, checkForBlocksToCrew(world, be.getPos()));
crew.equipStack(EquipmentSlot.MAINHAND, new ItemStack(Items.BOW));
crew.equipStack(EquipmentSlot.MAINHAND, new ItemStack(randomGun));
}
case VILLAGER -> crew = new VillagerEntity(EntityType.VILLAGER, world, VillagerType.forBiome(world.getBiome(be.getPos())));
case SKELETON_PIRATE ->
{
BlockPos blockToCrew = checkForBlocksToCrew(world, be.getPos());
crew = new PirateEntity(world, blockToCrew);
ItemStack itemStack = new ItemStack(Items.BOW);
ItemStack itemStack = new ItemStack(randomGun);
if (world.getBlockState(blockToCrew).isOf(Pirates.MOTION_INVOKING_BLOCK)) {
itemStack.addEnchantment(Enchantments.POWER, 2);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ace.actually.pirates.blocks.entity;

import ace.actually.pirates.Pirates;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.valkyrienskies.core.api.ships.Ship;
import org.valkyrienskies.mod.common.VSGameUtilsKt;

public class DamagedHullBlockEntity extends BlockEntity {

private double currentMass = 1000.0; // Starts light → increases over time

public DamagedHullBlockEntity(BlockPos pos, BlockState state) {
super(Pirates.DAMAGED_HULL_BLOCK_ENTITY, pos, state);
}

public static void tick(World world, BlockPos pos, BlockState state, DamagedHullBlockEntity blockEntity) {
if (world.isClient) return;

// Simulate water flooding
blockEntity.currentMass += 100.0; // Increase mass per tick (tune this!)
if (blockEntity.currentMass > 10000.0) {
blockEntity.currentMass = 10000.0; // Cap at max mass (e.g. Netherite mass)
}
}

public double getCurrentMass() {
return currentMass;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
import ace.actually.pirates.Pirates;
import ace.actually.pirates.entities.pirate_abstract.AbstractPirateEntity;
import ace.actually.pirates.entities.pirate_abstract.PirateBowAttackGoal;
import ace.actually.pirates.entities.pirate_abstract.PirateGunAttackGoal;
import ace.actually.pirates.entities.pirate_abstract.PirateWanderArroundFarGoal;
import ace.actually.pirates.entities.pirate_default.PirateEntity;
import ace.actually.pirates.util.DisarmUtils;
import ewewukek.musketmod.GunItem;
import ewewukek.musketmod.MusketItem;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.RangedAttackMob;
import net.minecraft.entity.ai.goal.ActiveTargetGoal;
import net.minecraft.entity.ai.goal.LookAroundGoal;
import net.minecraft.entity.ai.goal.LookAtEntityGoal;
import net.minecraft.entity.ai.goal.RevengeGoal;
Expand All @@ -18,11 +23,13 @@
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.entity.mob.PillagerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.PersistentProjectileEntity;
import net.minecraft.entity.projectile.ProjectileUtil;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import ewewukek.musketmod.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -90,9 +97,11 @@ public void genCustomName(World world)
@Override
protected void initGoals() {
super.initGoals();
this.goalSelector.add(3, new PirateBowAttackGoal<>(this, 1.0D, 20, 20.0F));
this.targetSelector.add(1, new RevengeGoal(this));

// this.goalSelector.add(3, new PirateBowAttackGoal<>(this, 1.0D, 20, 20.0F));
this.goalSelector.add(3, new PirateGunAttackGoal<>(this, 1.0D, 20, 20.0F));
this.targetSelector.add(3, new ActiveTargetGoal(this, PirateEntity.class, true));
this.targetSelector.add(3, new ActiveTargetGoal(this, PillagerEntity.class, true));
// this.targetSelector.add(1, new RevengeGoal(this));
}

@Override
Expand All @@ -119,22 +128,24 @@ public static DefaultAttributeContainer.Builder attributes() {
@Override
protected void initEquipment(Random random, LocalDifficulty localDifficulty) {
super.initEquipment(random, localDifficulty);
this.equipStack(EquipmentSlot.MAINHAND, new ItemStack(Items.BOW));
Item rand = guns[random.nextInt(guns.length)];
this.equipStack(EquipmentSlot.MAINHAND, new ItemStack(rand));
if (rand == Items.PISTOL)
this.equipStack(EquipmentSlot.OFFHAND, new ItemStack(Items.PISTOL));
}

@Override
public void attack(LivingEntity target, float pullProgress) {

ItemStack itemStack = this.getStackInHand(ProjectileUtil.getHandPossiblyHolding(this, Items.BOW));
PersistentProjectileEntity persistentProjectileEntity = this.createArrowProjectile(itemStack, pullProgress);
double d = target.getX() - this.getX();
double e = target.getBodyY(0.3333333333333333) - persistentProjectileEntity.getY();
double f = target.getZ() - this.getZ();
double g = Math.sqrt(d * d + f * f);
persistentProjectileEntity.setVelocity(d, e + g * 0.20000000298023224, f, 1.6F, (float) (14 - this.getEntityWorld().getDifficulty().getId() * 4));
this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
this.getEntityWorld().spawnEntity(persistentProjectileEntity);

// ItemStack itemStack = this.getStackInHand(ProjectileUtil.getHandPossiblyHolding(this, Items.BLUNDERBUSS));
// PersistentProjectileEntity persistentProjectileEntity = this.createArrowProjectile(itemStack, pullProgress);
// double d = target.getX() - this.getX();
// double e = target.getBodyY(0.3333333333333333) - persistentProjectileEntity.getY();
// double f = target.getZ() - this.getZ();
// double g = Math.sqrt(d * d + f * f);
// persistentProjectileEntity.setVelocity(d, e + g * 0.20000000298023224, f, 1.6F, (float) (14 - this.getEntityWorld().getDifficulty().getId() * 4));
// this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
// this.getEntityWorld().spawnEntity(persistentProjectileEntity);
}

protected PersistentProjectileEntity createArrowProjectile(ItemStack arrow, float damageModifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

import ace.actually.pirates.entities.pirate_default.PirateEntity;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.IllagerEntityRenderer;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.client.render.entity.feature.HeldItemFeatureRenderer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.EntityModelLayers;
import net.minecraft.client.render.entity.model.IllagerEntityModel;
import net.minecraft.util.Identifier;

public class FriendlyPirateRenderer extends MobEntityRenderer<FriendlyPirateEntity, EntityModel<FriendlyPirateEntity>> {
public class FriendlyPirateRenderer extends IllagerEntityRenderer<FriendlyPirateEntity> {
public FriendlyPirateRenderer(EntityRendererFactory.Context context) {
super(context, new FriendlyPirateModel(context.getPart(EntityModelLayers.PILLAGER)), 0.5F);
super(context, new IllagerEntityModel<>(context.getPart(EntityModelLayers.PILLAGER)), 0.5F);
this.addFeature(new HeldItemFeatureRenderer(this, context.getHeldItemRenderer()));
}

Expand Down
Loading