Skip to content

Commit

Permalink
Merge pull request #801 from devs-immortal/2.2.1/1.19.2/bugfix
Browse files Browse the repository at this point in the history
2.2.1/1.19.2/bugfix
  • Loading branch information
MBatt1 authored May 7, 2024
2 parents 627aa1d + 04342d8 commit c7d8c9a
Show file tree
Hide file tree
Showing 36 changed files with 420 additions and 87 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# suppress inspection "UnusedProperty" for whole file
org.gradle.jvmargs=-Xmx2G

paradiseLostVersion=2.2.0-beta+1.19.2
paradiseLostVersion=2.2.1-beta+1.19.2

minecraftVersion=1.19.2
yarnVersion=1.19.2+build.28
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public interface FloatingBlockHelper {
World world = entity.world;
BlockPos pos = entity.getBlockPos();
int distFromTop = world.getTopY() - pos.getY();
return !entity.isFastFloater() && distFromTop <= 50;
return !entity.isInTag(ParadiseLostBlockTags.DECAYING_FLOATERS) && distFromTop <= 50;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected static Action<Block> coarseTillable() {
return (id, block) -> TillableBlockRegistry.register(block, HoeItem::canTillFarmland, ParadiseLostBlocks.DIRT.getDefaultState());
}

protected static Action<Block> flattenable() {
return (id, block) -> FlattenableBlockRegistry.register(block, ParadiseLostBlocks.DIRT_PATH.getDefaultState());
protected static Action<Block> flattenable(Block turnInto) {
return (id, block) -> FlattenableBlockRegistry.register(block, turnInto.getDefaultState());
}
}
16 changes: 10 additions & 6 deletions src/main/java/net/id/paradiselost/blocks/ParadiseLostBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,20 @@ protected static Settings unbreakable(AbstractBlock.Settings settings) {
private static Settings grassBlock() {
return copy(Blocks.GRASS_BLOCK).mapColor(MapColor.LICHEN_GREEN).strength(0.4f);
}
private static Settings permafrost() {
return copy(Blocks.DIRT).strength(2f).sounds(BlockSoundGroup.GILDED_BLACKSTONE);
}

public static final ParadiseLostGrassBlock HIGHLANDS_GRASS = add("highlands_grass", new ParadiseLostGrassBlock(grassBlock()), cutoutMippedRenderLayer, tillable(), flattenable());
public static final ParadiseLostSnowyBlock FROZEN_GRASS = add("frozen_grass", new ParadiseLostSnowyBlock(grassBlock().mapColor(MapColor.WHITE).strength(2F).sounds(BlockSoundGroup.GILDED_BLACKSTONE)), flattenable());
public static final ParadiseLostDirtPathBlock DIRT_PATH = add("grass_path", new ParadiseLostDirtPathBlock(copy(Blocks.DIRT_PATH), () -> ParadiseLostBlocks.DIRT));
public static final ParadiseLostDirtPathBlock PERMAFROST_PATH = add("frozen_path", new ParadiseLostDirtPathBlock(permafrost(), () -> ParadiseLostBlocks.PERMAFROST));
public static final ParadiseLostGrassBlock HIGHLANDS_GRASS = add("highlands_grass", new ParadiseLostGrassBlock(grassBlock()), cutoutMippedRenderLayer, tillable(), flattenable(ParadiseLostBlocks.DIRT_PATH));
public static final ParadiseLostSnowyBlock FROZEN_GRASS = add("frozen_grass", new ParadiseLostSnowyBlock(grassBlock().mapColor(MapColor.WHITE).strength(2F).sounds(BlockSoundGroup.GILDED_BLACKSTONE)), flattenable(ParadiseLostBlocks.PERMAFROST_PATH));
// Soil Blocks
public static final Block DIRT = add("dirt", new Block(copy(Blocks.DIRT).strength(0.3f)), tillable(), flattenable());
public static final Block COARSE_DIRT = add("coarse_dirt", new Block(copy(Blocks.DIRT).strength(0.3f)), coarseTillable(), flattenable());
public static final Block DIRT = add("dirt", new Block(copy(Blocks.DIRT).strength(0.3f)), tillable(), flattenable(ParadiseLostBlocks.DIRT_PATH));
public static final Block COARSE_DIRT = add("coarse_dirt", new Block(copy(Blocks.DIRT).strength(0.3f)), coarseTillable(), flattenable(ParadiseLostBlocks.DIRT_PATH));
public static final FloatingBlock LEVITA = add("levita", new FloatingBlock(false, copy(Blocks.GRAVEL).strength(0.3f)));
public static final Block PERMAFROST = add("permafrost", new Block(copy(Blocks.DIRT).strength(2f).sounds(BlockSoundGroup.GILDED_BLACKSTONE)), flattenable());
public static final Block PERMAFROST = add("permafrost", new Block(permafrost()), flattenable(ParadiseLostBlocks.PERMAFROST_PATH));
public static final FarmlandBlock FARMLAND = add("farmland", new ParadiseLostFarmlandBlock(copy(Blocks.FARMLAND)));
public static final ParadiseLostDirtPathBlock DIRT_PATH = add("grass_path", new ParadiseLostDirtPathBlock(copy(Blocks.DIRT_PATH)));
public static final Block PACKED_SWEDROOT = add("packed_swedroot", new Block(of(Material.WOOD).strength(2f).sounds(BlockSoundGroup.SHROOMLIGHT)));

// Glass Blocks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package net.id.paradiselost.blocks.blockentity;

import net.id.paradiselost.blocks.mechanical.TreeTapBlock;
import net.id.paradiselost.recipe.ParadiseLostRecipeTypes;
import net.id.paradiselost.recipe.TreeTapRecipe;
import net.minecraft.block.BeehiveBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.HopperBlockEntity;
import net.minecraft.block.entity.LootableContainerBlockEntity;
Expand All @@ -28,7 +32,6 @@
import net.minecraft.util.math.Direction;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Optional;

public class TreeTapBlockEntity extends LootableContainerBlockEntity implements SidedInventory {
Expand Down Expand Up @@ -134,12 +137,29 @@ public void tryCraft() {
Optional<TreeTapRecipe> recipe = this.world.getRecipeManager().getFirstMatch(ParadiseLostRecipeTypes.TREE_TAP_RECIPE_TYPE, this, this.world);
if (recipe.isPresent() && world.random.nextInt(recipe.get().getChance()) == 0) {
ItemStack output = recipe.get().craft(this);
stack.decrement(1);
Block convertBlock = recipe.get().getOutputBlock();
BlockPos attachedPos = this.pos.offset(world.getBlockState(this.pos).get(TreeTapBlock.FACING).getOpposite());
BlockState attachedBlock = world.getBlockState(attachedPos);
if (convertBlock != Blocks.BEE_NEST) {
stack.decrement(1);

if (!world.isClient) world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.BLOCKS, 0.5f, world.getRandom().nextFloat() * 0.4f + 0.8f);
if (convertBlock != world.getBlockState(this.pos).getBlock()) {
world.setBlockState(attachedPos, convertBlock.getDefaultState(), 0);
}
if (!world.isClient) world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.BLOCKS, 0.5f, world.getRandom().nextFloat() * 0.4f + 0.8f);

this.inventory.set(0, output);
inventoryChanged();
this.inventory.set(0, output);
inventoryChanged();
} else if (attachedBlock.get(BeehiveBlock.HONEY_LEVEL) == 5) {
stack.decrement(1);

world.setBlockState(attachedPos, attachedBlock.with(BeehiveBlock.HONEY_LEVEL, 0));

if (!world.isClient) world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.BLOCKS, 0.5f, world.getRandom().nextFloat() * 0.4f + 0.8f);

this.inventory.set(0, output);
inventoryChanged();
}
}
tryTansferItemsOut();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
package net.id.paradiselost.blocks.decorative;

import net.id.paradiselost.blocks.ParadiseLostBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.DirtPathBlock;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;

import java.util.function.Function;
import java.util.function.Supplier;

public class ParadiseLostDirtPathBlock extends DirtPathBlock {
public ParadiseLostDirtPathBlock(Settings settings) {

private Supplier<Block> returnTo;

public ParadiseLostDirtPathBlock(Settings settings, Supplier<Block> returnTo) {
super(settings);
this.returnTo = returnTo;
}

@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
world.setBlockState(pos, pushEntitiesUpBeforeBlockChange(state, ParadiseLostBlocks.DIRT.getDefaultState(), world, pos));
world.setBlockState(pos, pushEntitiesUpBeforeBlockChange(state, this.returnTo.get().getDefaultState(), world, pos));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.SandBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.FallingBlockEntity;
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.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.stat.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
import net.minecraft.world.event.GameEvent;
import net.minecraft.world.explosion.Explosion;
Expand All @@ -31,35 +37,40 @@ public NitraBlock(Settings settings) {
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) {
if (!oldState.isOf(state.getBlock())) {
if (world.isReceivingRedstonePower(pos)) {
ignite(world, pos, 2F);
world.removeBlock(pos, false);
world.createAndScheduleBlockTick(pos, this, 1);
}

}
}

public void neighborUpdate(BlockState state, World world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
if (world.isReceivingRedstonePower(pos)) {
ignite(world, pos, 2F);
world.removeBlock(pos, false);
world.createAndScheduleBlockTick(pos, this, 1);
}

}

public void onDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) {
float sourcePower = ((ExplosionExtensions) explosion).getPower();
if (!world.isClient && sourcePower > 0.5F) {
System.out.println(sourcePower);
ignite(world, pos, sourcePower - 0.5F);
}
}

public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
ignite(world, pos, 2F, null);
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 11);
world.spawnParticles(ParticleTypes.EXPLOSION_EMITTER, pos.getX(), pos.getY(), pos.getZ(), 1, 0.0, 0.0, 0.0, 0.0);
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (world.random.nextFloat() - world.random.nextFloat()) * 0.2F) * 0.7F);
}

public static void ignite(World world, BlockPos pos, float power) {
ignite(world, pos, power, null);
}

private static void ignite(World world, BlockPos pos, float power, @Nullable LivingEntity igniter) {
Explosion explosion = new Explosion(world, igniter, null, null, pos.getX(), pos.getY() + 0.5D, pos.getZ(), power, false, Explosion.DestructionType.BREAK);
System.out.println(world.isClient);
if (!world.isClient) {
explosion.collectBlocksAndDamageEntities();
world.emitGameEvent(igniter, GameEvent.PRIME_FUSE, pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import net.id.paradiselost.client.rendering.entity.passive.MoaEntityRenderer;
import net.id.paradiselost.entities.ParadiseLostEntityTypes;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.EntityRenderers;
import net.minecraft.client.render.entity.FlyingItemEntityRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;

Expand All @@ -25,6 +27,8 @@ public static void initClient() {
register(ParadiseLostEntityTypes.MOA, MoaEntityRenderer::new);
// register(ParadiseLostEntityTypes.AMBYST, AmbystRenderer::new);

// projectile
register(ParadiseLostEntityTypes.THROWN_NITRA, FlyingItemEntityRenderer::new);
}

@SafeVarargs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.id.paradiselost.entities.passive.ParadiseLostAnimalEntity;
import net.id.paradiselost.entities.passive.ambyst.FindLogSensor;
import net.id.paradiselost.entities.passive.moa.MoaEntity;
import net.id.paradiselost.entities.projectile.ThrownNitraEntity;
import net.id.paradiselost.mixin.brain.ActivityInvoker;
import net.id.paradiselost.mixin.brain.MemoryModuleTypeInvoker;
import net.id.paradiselost.mixin.brain.SensorTypeInvoker;
Expand Down Expand Up @@ -47,7 +48,7 @@ public class ParadiseLostEntityTypes {
ParadiseLostEntityTypes.<SliderEntity>of(SliderEntity::new, MISC, changing(0.98F, 0.98F), 10).trackedUpdateRate(20));

// Hostile
public static final EntityType<EnvoyEntity> ENVOY = add("envoy", of(EnvoyEntity::new, MONSTER, changing(1f, 2f), 7),
public static final EntityType<EnvoyEntity> ENVOY = add("envoy", of(EnvoyEntity::new, MONSTER, changing(0.6F, 1.95F), 10),
attributes(EnvoyEntity::createEnvoyAttributes), spawnRestrictions(EnvoyEntity::canMobSpawn));

// passive
Expand All @@ -56,6 +57,9 @@ public class ParadiseLostEntityTypes {
// public static final EntityType<AmbystEntity> AMBYST = add("ambyst", of(AmbystEntity::new, CREATURE, changing(0.6F, 0.42F), 5),
// attributes(AmbystEntity::createAmbystAttributes), spawnRestrictions(ParadiseLostAnimalEntity::isValidNaturalParadiseLostSpawn));

// projectile
public static final EntityType<ThrownNitraEntity> THROWN_NITRA = add("thrown_nitra", of(ThrownNitraEntity::new, MISC, changing(0.5F, 0.5F), 5));

//Brain
public static final Activity HIDEINLOG = ActivityInvoker.invokeRegister(ParadiseLost.locate("hideinlog").toString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import net.id.paradiselost.entities.ParadiseLostEntityTypes;
import net.id.paradiselost.tag.ParadiseLostBlockTags;
import net.id.incubus_core.blocklikeentities.api.BlockLikeEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FallingBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.MovementType;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.tag.TagKey;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
Expand Down Expand Up @@ -65,7 +67,7 @@ public void postTickMovement() {

if (!this.hasNoGravity()) {
if (!isDropping() && !shouldBeginDropping()) {
if (isFastFloater()) {
if (isInTag(ParadiseLostBlockTags.FAST_FLOATERS)) {
this.setVelocity(this.getVelocity().add(0.0D, 0.05D, 0.0D));
} else {
this.setVelocity(this.getVelocity().add(0.0D, 0.03D, 0.0D));
Expand Down Expand Up @@ -140,9 +142,9 @@ public void breakApart() {
super.breakApart();
this.getOnEndFloating().accept(Math.abs(this.lastYVelocity), false);
}
public boolean isFastFloater() {
return this.getBlockState().isIn(ParadiseLostBlockTags.FAST_FLOATERS) && !this.partOfSet;

public boolean isInTag(TagKey<Block> tag) {
return this.getBlockState().isIn(tag) && !this.partOfSet;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package net.id.paradiselost.entities.projectile;

import net.id.paradiselost.ParadiseLost;
import net.id.paradiselost.entities.ParadiseLostEntityTypes;
import net.id.paradiselost.items.ParadiseLostItems;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.mob.BlazeEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.thrown.SnowballEntity;
import net.minecraft.entity.projectile.thrown.ThrownEntity;
import net.minecraft.entity.projectile.thrown.ThrownItemEntity;
import net.minecraft.item.Item;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;

public class ThrownNitraEntity extends ThrownItemEntity {

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

public ThrownNitraEntity(World world, LivingEntity owner) {
super(ParadiseLostEntityTypes.THROWN_NITRA, owner, world);
}

protected void onEntityHit(EntityHitResult entityHitResult) {
super.onEntityHit(entityHitResult);
doDamage();
}

protected void onCollision(HitResult hitResult) {
super.onCollision(hitResult);
doDamage();
if (!this.world.isClient) {
this.world.sendEntityStatus(this, (byte)3);
this.discard();
}
}

public void handleStatus(byte status) {
if (status == 3) {
for (int i = 0; i < 4; i++) {
this.world.addParticle(ParticleTypes.EXPLOSION,
this.getX() + this.random.nextDouble() - 0.5, this.getY() + this.random.nextDouble() - 0.5, this.getZ() + this.random.nextDouble() - 0.5,
0.0, 0.0, 0.0
);
}
this.world.playSound(this.getX(), this.getY(), this.getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.NEUTRAL, 1.0F, 1.1F + this.random.nextFloat() * 0.4F, false);
}

}

private void doDamage() {
var hit = this.world.getOtherEntities(this, new Box(this.getX()-1.5, this.getY()-1.5, this.getZ()-1.5, this.getX()+1.5, this.getY()+1.5, this.getZ()+1.5));
for (Entity e : hit) {
Vec3d diff = this.getPos().subtract(e.getPos()).negate().normalize();
e.addVelocity(diff.x, diff.y, diff.z);
e.damage(DamageSource.explosion((LivingEntity) null), 2);
}
}

@Override
protected Item getDefaultItem() {
return ParadiseLostItems.NITRA_BULB;
}
}
Loading

0 comments on commit c7d8c9a

Please sign in to comment.