Skip to content

Commit

Permalink
Merge pull request #43 from sleepy-evelyn/1.20
Browse files Browse the repository at this point in the history
Add common protection api support & small fixes
  • Loading branch information
Pyrofab authored Oct 23, 2023
2 parents cca726e + 81a87b2 commit b10bcc9
Show file tree
Hide file tree
Showing 37 changed files with 437 additions and 258 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,14 @@ The Cold Digger is an upgrade to the Stripminer that keeps the functionality of
##### Dry Ice

Dry Ice is a kind of ice that does not melt or create water upon breaking. It emits particles and can be mined using silk touch.

### Claim / Protection Support

Blast version 1.12 and above has support for Patbox's [Common Protection API](https://github.com/Patbox/common-protection-api). This means BLAST items and blocks are un-able to bypass claim protections for any mod that implements this common API. This currently includes but is not limited to:

- [Cadmus](https://github.com/Patbox/get-off-my-lawn-reserved)
- [Flan's Landclaiming Mod](https://modrinth.com/mod/flan)
- [GOML Reserved](https://modrinth.com/mod/goml-reserved)
- [FTB Chunks](https://github.com/FTBTeam/FTB-Chunks)

`List last updated: 22/10/23`
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ plugins {
id 'io.github.ladysnake.chenille' version '0.11.3'
}

repositories {
// For Common Protection API
maven { url "https://maven.nucleoid.xyz/" }
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

Expand Down Expand Up @@ -31,6 +36,7 @@ dependencies {

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
modImplementation include("eu.pb4:common-protection-api:${project.common_protection_api_version}")
}

java {
Expand Down
7 changes: 5 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
org.gradle.jvmargs=-Xmx4G

# Mod Properties
mod_version = 1.11
mod_version = 1.12
maven_group = io.github.ladysnake
archives_base_name = blast

Expand All @@ -12,9 +12,12 @@ minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.22

#Fabric api
# Fabric API
fabric_version=0.85.0+1.20.1

# Mod Dependencies
common_protection_api_version=1.0.0

#Publishing
owners = Ladysnake
license_header = ARR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.registry.tag.FluidTags;
import net.minecraft.util.math.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import org.joml.Quaternionf;
import org.joml.Vector3f;

Expand Down
12 changes: 2 additions & 10 deletions src/main/java/ladysnake/blast/common/block/BonesburrierBlock.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,27 @@
package ladysnake.blast.common.block;

import ladysnake.blast.common.entity.BonesburrierEntity;
import ladysnake.blast.common.entity.StripminerEntity;
import ladysnake.blast.common.init.BlastEntities;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager;
import net.minecraft.util.ActionResult;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;

import java.util.concurrent.ThreadLocalRandom;

public class BonesburrierBlock extends Block implements DetonatableBlock {
public BonesburrierBlock(Settings settings) {
super(settings);
Expand All @@ -43,9 +34,11 @@ public static void prime(World world, BlockPos pos) {
private static void prime(World world, BlockPos pos, LivingEntity igniter) {
if (!world.isClient && world.getBlockState(pos).getBlock() instanceof BonesburrierBlock) {
BonesburrierEntity entity = BlastEntities.BONESBURRIER.create(world);
entity.setOwner(igniter);
entity.setPos(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
world.spawnEntity(entity);
world.playSound(null, entity.getX(), entity.getY(), entity.getZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);

}
}

Expand Down Expand Up @@ -124,7 +117,6 @@ public void onProjectileHit(World world, BlockState state, BlockHitResult hit, P
world.removeBlock(blockPos, false);
}
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import ladysnake.blast.client.BlastClient;
import ladysnake.blast.common.init.BlastBlocks;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.util.ParticleUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import ladysnake.blast.common.entity.BombEntity;
import ladysnake.blast.common.init.BlastEntities;
import net.fabricmc.fabric.impl.content.registry.FireBlockHooks;
import net.minecraft.block.*;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
Expand Down Expand Up @@ -39,6 +38,7 @@ private static void explode(World world, BlockPos pos, LivingEntity igniter) {

if (!world.isClient) {
BombEntity entity = BlastEntities.GUNPOWDER_BLOCK.create(world);
entity.setOwner(igniter);
entity.setPos(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
world.spawnEntity(entity);
world.setBlockState(pos, Blocks.AIR.getDefaultState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public static void trigger(World world, BlockPos blockPos) {
if (block instanceof DetonatableBlock detonatableBlock) {
detonatableBlock.detonate(world, mutable);
}

if (block == Blocks.TNT) {
TntEntity tntEntity = new TntEntity(world, (double) mutable.getX() + 0.5, mutable.getY(), (double) mutable.getZ() + 0.5, null);
tntEntity.setFuse(1);
Expand Down
36 changes: 14 additions & 22 deletions src/main/java/ladysnake/blast/common/block/StripminerBlock.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package ladysnake.blast.common.block;

import ladysnake.blast.common.entity.StripminerEntity;
import net.minecraft.block.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
Expand Down Expand Up @@ -44,6 +47,7 @@ public static void primeStripminer(World world, BlockPos pos) {
private static void primeStripminer(World world, BlockPos pos, LivingEntity igniter) {
if (!world.isClient && world.getBlockState(pos).getBlock() instanceof StripminerBlock) {
StripminerEntity entity = ((StripminerBlock) world.getBlockState(pos).getBlock()).type.create(world);
entity.setOwner(igniter);
entity.setFacing(world.getBlockState(pos).get(FACING));
entity.setPos(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
world.spawnEntity(entity);
Expand Down Expand Up @@ -86,27 +90,15 @@ public void neighborUpdate(BlockState state, World world, BlockPos pos, Block bl
@Override
public void onDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) {
if (!world.isClient) {
Direction randomDirection = Direction.NORTH;
switch (ThreadLocalRandom.current().nextInt(0, 6)) {
case 0:
randomDirection = Direction.UP;
break;
case 1:
randomDirection = Direction.DOWN;
break;
case 2:
randomDirection = Direction.NORTH;
break;
case 3:
randomDirection = Direction.SOUTH;
break;
case 4:
randomDirection = Direction.EAST;
break;
case 5:
randomDirection = Direction.WEST;
break;
}
Direction randomDirection = switch (ThreadLocalRandom.current().nextInt(0, 6)) {
case 0 -> Direction.UP;
case 1 -> Direction.DOWN;
case 2 -> Direction.NORTH;
case 3 -> Direction.SOUTH;
case 4 -> Direction.EAST;
case 5 -> Direction.WEST;
default -> Direction.NORTH;
};

StripminerEntity entity = this.type.create(world);
entity.setFacing(randomDirection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;

public class AmethystBombEntity extends BombEntity {
public AmethystBombEntity(EntityType<? extends BombEntity> entityType, World world) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;

public class AmethystTriggerBombEntity extends TriggerBombEntity {
public AmethystTriggerBombEntity(EntityType<? extends BombEntity> entityType, World world) {
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/ladysnake/blast/common/entity/BombEntity.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package ladysnake.blast.common.entity;

import ladysnake.blast.common.init.BlastEntities;
import ladysnake.blast.common.init.BlastItems;
import ladysnake.blast.common.world.CustomExplosion;
import ladysnake.blast.common.world.EntityExplosion;
import ladysnake.blast.common.world.KnockbackExplosion;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LivingEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ladysnake.blast.common.entity;

import ladysnake.blast.common.init.BlastBlocks;
import ladysnake.blast.common.init.BlastItems;
import ladysnake.blast.common.world.BonesburrierExplosion;
import ladysnake.blast.common.world.CustomExplosion;
import net.minecraft.entity.EntityType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;

public class FrostBombEntity extends BombEntity {
public FrostBombEntity(EntityType<? extends BombEntity> entityType, World world) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;

public class FrostTriggerBombEntity extends TriggerBombEntity {
public FrostTriggerBombEntity(EntityType<? extends BombEntity> entityType, World world) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ladysnake.blast.common.entity;

import ladysnake.blast.common.init.BlastBlocks;
import ladysnake.blast.common.init.BlastItems;
import ladysnake.blast.common.world.CustomExplosion;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;

public class PipeBombEntity extends PersistentProjectileEntity implements FlyingItemEntity {
public final int MAX_FUSE = 20;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package ladysnake.blast.common.entity;

import ladysnake.blast.common.util.ProtectionsProvider;
import ladysnake.blast.mixin.FallingBlockEntityAccessor;
import net.minecraft.block.BlockState;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.MovementType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

public class ShrapnelBlockEntity extends FallingBlockEntity {

@Nullable
private PlayerEntity owner;

public ShrapnelBlockEntity(EntityType<? extends FallingBlockEntity> entityType, World world) {
super(entityType, world);
}

private ShrapnelBlockEntity(World world, double x, double y, double z, BlockState block, @Nullable PlayerEntity owner) {
this(EntityType.FALLING_BLOCK, world);

((FallingBlockEntityAccessor) this).setBlock(block);
this.intersectionChecked = true;
this.setPosition(x, y, z);
this.setVelocity(Vec3d.ZERO);
this.prevX = x;
this.prevY = y;
this.prevZ = z;
this.owner = owner;
this.setFallingBlockPos(this.getBlockPos());
}

public static ShrapnelBlockEntity spawnFromBlock(World world, BlockPos pos, BlockState state, @Nullable PlayerEntity owner) {
var explosionThrownBlockEntity = new ShrapnelBlockEntity(
world, (double)pos.getX() + 0.5, pos.getY(), (double)pos.getZ() + 0.5,
state.contains(Properties.WATERLOGGED) ? state.with(Properties.WATERLOGGED, false) : state, owner
);
world.setBlockState(pos, state.getFluidState().getBlockState(), 3);
world.spawnEntity(explosionThrownBlockEntity);
return explosionThrownBlockEntity;
}

@Nullable
public PlayerEntity getOwner() { return owner; }

@Override
protected void writeCustomDataToNbt(NbtCompound nbt) {
super.writeCustomDataToNbt(nbt);
if (!getWorld().isClient && owner != null) {
nbt.putUuid("Owner", owner.getUuid());
}
}

@Override
protected void readCustomDataFromNbt(NbtCompound nbt) {
super.readCustomDataFromNbt(nbt);
if (nbt.containsUuid("Owner") && getWorld() instanceof ServerWorld serverWorld) {
owner = serverWorld.getServer().getPlayerManager().getPlayer(nbt.getUuid("Owner"));
}
}

@Override
public void move(MovementType movementType, Vec3d movement) {
super.move(movementType, movement);
if (this.isOnGround() && !getWorld().isClient) {
if(!ProtectionsProvider.canPlaceBlock(getBlockPos(), getWorld(), owner)) {
setDestroyedOnLanding();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;

public class SlimeBombEntity extends BombEntity {
public SlimeBombEntity(EntityType<? extends BombEntity> entityType, World world) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;

public class SlimeTriggerBombEntity extends TriggerBombEntity {
public SlimeTriggerBombEntity(EntityType<? extends BombEntity> entityType, World world) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import ladysnake.blast.common.block.StripminerBlock;
import ladysnake.blast.common.init.BlastBlocks;
import ladysnake.blast.common.init.BlastEntities;
import ladysnake.blast.common.init.BlastItems;
import ladysnake.blast.common.world.CustomExplosion;
import net.minecraft.block.BlockState;
import net.minecraft.entity.EntityType;
Expand Down
Loading

0 comments on commit b10bcc9

Please sign in to comment.