Skip to content

Commit

Permalink
Fix improper casting causing issues with block pos's
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Jan 14, 2024
1 parent 31270e7 commit 41c43ed
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
package org.violetmoon.quark.content.mobs.entity;

import static org.violetmoon.quark.content.world.module.NewStoneTypesModule.jasperBlock;
import static org.violetmoon.quark.content.world.module.NewStoneTypesModule.limestoneBlock;
import static org.violetmoon.quark.content.world.module.NewStoneTypesModule.polishedBlocks;
import static org.violetmoon.quark.content.world.module.NewStoneTypesModule.shaleBlock;

import java.util.List;
import java.util.Set;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.handler.QuarkSounds;
import org.violetmoon.quark.base.util.IfFlagGoal;
import org.violetmoon.quark.content.mobs.ai.ActWaryGoal;
import org.violetmoon.quark.content.mobs.ai.FavorBlockGoal;
import org.violetmoon.quark.content.mobs.ai.RunAndPoofGoal;
import org.violetmoon.quark.content.mobs.module.StonelingsModule;
import org.violetmoon.quark.content.tools.entity.rang.Pickarang;
import org.violetmoon.quark.content.world.module.GlimmeringWealdModule;
import org.violetmoon.zeta.util.BlockUtils;
import org.violetmoon.zeta.util.MiscUtil;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.BlockParticleOption;
import net.minecraft.core.particles.ParticleTypes;
Expand All @@ -44,13 +21,7 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.SpawnGroupData;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.TemptGoal;
Expand All @@ -62,11 +33,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.*;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
Expand All @@ -79,6 +46,24 @@
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraftforge.common.Tags;
import net.minecraftforge.network.NetworkHooks;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.handler.QuarkSounds;
import org.violetmoon.quark.base.util.IfFlagGoal;
import org.violetmoon.quark.content.mobs.ai.ActWaryGoal;
import org.violetmoon.quark.content.mobs.ai.FavorBlockGoal;
import org.violetmoon.quark.content.mobs.ai.RunAndPoofGoal;
import org.violetmoon.quark.content.mobs.module.StonelingsModule;
import org.violetmoon.quark.content.tools.entity.rang.Pickarang;
import org.violetmoon.quark.content.world.module.GlimmeringWealdModule;
import org.violetmoon.zeta.util.BlockUtils;
import org.violetmoon.zeta.util.MiscUtil;

import java.util.List;
import java.util.Set;

import static org.violetmoon.quark.content.world.module.NewStoneTypesModule.*;

public class Stoneling extends PathfinderMob {

Expand Down Expand Up @@ -447,7 +432,7 @@ public static boolean spawnPredicate(EntityType<? extends Stoneling> type, Serve

@Override
public boolean checkSpawnRules(@NotNull LevelAccessor world, @NotNull MobSpawnType reason) {
BlockPos pos = new BlockPos((int) position().x(), (int) position().y(), (int) position().z()).below();
BlockPos pos = BlockPos.containing(position()).below();
BlockState state = world.getBlockState(pos);
if(!BlockUtils.isStoneBased(state, world, pos))
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
package org.violetmoon.quark.content.mobs.entity;

import java.util.List;

import org.jetbrains.annotations.NotNull;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.handler.QuarkSounds;
import org.violetmoon.quark.content.mobs.module.ToretoiseModule;
import org.violetmoon.zeta.util.BlockUtils;
import org.violetmoon.zeta.util.MiscUtil;

import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.registries.BuiltInRegistries;
Expand All @@ -27,21 +18,10 @@
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.SpawnGroupData;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.BreedGoal;
import net.minecraft.world.entity.ai.goal.FollowParentGoal;
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal;
import net.minecraft.world.entity.ai.goal.RandomStrollGoal;
import net.minecraft.world.entity.ai.goal.TemptGoal;
import net.minecraft.world.entity.ai.goal.*;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand All @@ -62,6 +42,14 @@
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.AABB;
import net.minecraftforge.common.ToolActions;
import org.jetbrains.annotations.NotNull;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.handler.QuarkSounds;
import org.violetmoon.quark.content.mobs.module.ToretoiseModule;
import org.violetmoon.zeta.util.BlockUtils;
import org.violetmoon.zeta.util.MiscUtil;

import java.util.List;

public class Toretoise extends Animal {

Expand Down Expand Up @@ -215,8 +203,8 @@ else if(angeryTicks == 0) {
if(ore != 0)
breakOre: {
AABB ourBoundingBox = getBoundingBox();
BlockPos min = new BlockPos((int) Math.round(ourBoundingBox.minX), (int) Math.round(ourBoundingBox.minY), (int) Math.round(ourBoundingBox.minZ));
BlockPos max = new BlockPos((int) Math.round(ourBoundingBox.maxX), (int) Math.round(ourBoundingBox.maxY), (int) Math.round(ourBoundingBox.maxZ));
BlockPos min = BlockPos.containing(Math.round(ourBoundingBox.minX), Math.round(ourBoundingBox.minY), Math.round(ourBoundingBox.minZ));
BlockPos max = BlockPos.containing(Math.round(ourBoundingBox.maxX), Math.round(ourBoundingBox.maxY), Math.round(ourBoundingBox.maxZ));

for(int ix = min.getX(); ix <= max.getX(); ix++)
for(int iy = min.getY(); iy <= max.getY(); iy++)
Expand Down

0 comments on commit 41c43ed

Please sign in to comment.