Skip to content

Commit

Permalink
more amber stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Uraneptus committed Apr 22, 2024
1 parent a9c52a1 commit 83e2cce
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.uraneptus.sullysmod.common.blockentities;

import com.uraneptus.sullysmod.core.registry.SMBlockEntityTypes;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package com.uraneptus.sullysmod.common.blocks;

import com.uraneptus.sullysmod.common.blockentities.AmberBE;
import com.uraneptus.sullysmod.common.blockentities.FlingerTotemBE;
import com.uraneptus.sullysmod.core.other.tags.SMBlockTags;
import com.uraneptus.sullysmod.core.registry.SMBlockEntityTypes;
import com.uraneptus.sullysmod.core.registry.SMBlocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
Expand All @@ -21,7 +17,6 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
Expand All @@ -34,10 +29,6 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AmberBlock extends BaseEntityBlock {

private static final VoxelShape MELTING_COLLISION_SHAPE = Shapes.box(0.0D, 0.0D, 0.0D, 1.0D, (double)0.0F, 1.0D);
Expand All @@ -52,7 +43,6 @@ public RenderShape getRenderShape(BlockState pState) {
return RenderShape.MODEL;
}


public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
BlockEntity blockEntity = pLevel.getBlockEntity(pPos);

Expand All @@ -62,27 +52,29 @@ public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, Block
Level level = blockEntity.getLevel();
if (!amber.hasStuckEntity()) {
if (entity != null) {
boolean flag = false;
boolean shouldMeltFlag = false;

for (BlockPos pos : BlockPos.betweenClosed(pPos.offset(-1, -1, -1), pPos.offset(1, 1, 1))) {
BlockState state = pLevel.getBlockState(pos);
BlockEntity be = pLevel.getBlockEntity(pos);
if (state.is(SMBlockTags.MELTS_AMBER)) {
flag = true;
shouldMeltFlag = true;
}
if (state.getBlock() instanceof AmberBlock && be instanceof AmberBE amberBE) {
if (amberBE.isBlockMelted() && level != null && level.getBrightness(LightLayer.BLOCK, pPos.above()) >= 9) {
flag = true;
shouldMeltFlag = true;
}

}
}
if (flag) {
if (shouldMeltFlag) {
if (entity instanceof Player player) {
//return MELTING_COLLISION_SHAPE;


if (player.jumping) {
amber.setBlockMelted(false);
return Shapes.block();
}
}

amber.setBlockMelted(true);
amber.update();
return MELTING_COLLISION_SHAPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
import net.minecraft.world.entity.ai.goal.target.ResetUniversalAngerTargetGoal;
import net.minecraft.world.entity.animal.*;
import net.minecraft.world.entity.animal.AbstractFish;
import net.minecraft.world.entity.animal.AbstractSchoolingFish;
import net.minecraft.world.entity.animal.Bucketable;
import net.minecraft.world.entity.animal.WaterAnimal;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.vehicle.Boat;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.pathfinder.Path;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ public boolean isPickable() {
return !this.isRemoved();
}


private void hurtEntity(List<Entity> pEntities) {
for (Entity entity : pEntities) {
if (entity instanceof LivingEntity livingEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,5 @@ public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
}

}

}
}

0 comments on commit 83e2cce

Please sign in to comment.