Mobs pathfinding issues fix

This commit is contained in:
paulevsGitch 2020-11-03 23:40:33 +03:00
parent 2105988554
commit 0301be97af
5 changed files with 38 additions and 3 deletions

View file

@ -0,0 +1,29 @@
package ru.betterend.mixin.common;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.block.BlockState;
import net.minecraft.entity.ai.pathing.LandPathNodeMaker;
import net.minecraft.entity.ai.pathing.PathNodeType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import ru.betterend.registry.EndBlocks;
@Mixin(LandPathNodeMaker.class)
public class LandPathNodeMakerMixin {
@Inject(method = "getCommonNodeType", at = @At(value = "HEAD"), cancellable = true)
private static void beModifyPathNodes(BlockView blockView, BlockPos blockPos, CallbackInfoReturnable<PathNodeType> info) {
BlockState blockState = blockView.getBlockState(blockPos);
if (blockState.isOf(EndBlocks.NEEDLEGRASS) || blockState.isOf(EndBlocks.MURKWEED)) {
beCactusDamage(info);
}
}
private static void beCactusDamage(CallbackInfoReturnable<PathNodeType> info) {
info.setReturnValue(PathNodeType.DAMAGE_CACTUS);
info.cancel();
}
}

View file

@ -49,6 +49,7 @@ public class EndFeatures {
public static final EndFeature SHADOW_PLANT = new EndFeature("shadow_plant", new SinglePlantFeature(EndBlocks.SHADOW_PLANT, 6), 9); public static final EndFeature SHADOW_PLANT = new EndFeature("shadow_plant", new SinglePlantFeature(EndBlocks.SHADOW_PLANT, 6), 9);
public static final EndFeature MURKWEED = new EndFeature("murkweed", new SinglePlantFeature(EndBlocks.MURKWEED, 3), 2); public static final EndFeature MURKWEED = new EndFeature("murkweed", new SinglePlantFeature(EndBlocks.MURKWEED, 3), 2);
public static final EndFeature NEEDLEGRASS = new EndFeature("needlegrass", new SinglePlantFeature(EndBlocks.NEEDLEGRASS, 3), 2); public static final EndFeature NEEDLEGRASS = new EndFeature("needlegrass", new SinglePlantFeature(EndBlocks.NEEDLEGRASS, 3), 2);
public static final EndFeature SHADOW_BERRY = new EndFeature("shadow_berry", new SinglePlantFeature(EndBlocks.SHADOW_BERRY, 2), 1);
// Vines // // Vines //
public static final EndFeature DENSE_VINE = new EndFeature("dense_vine", new VineFeature(EndBlocks.DENSE_VINE, 24), 3); public static final EndFeature DENSE_VINE = new EndFeature("dense_vine", new VineFeature(EndBlocks.DENSE_VINE, 24), 3);
@ -73,9 +74,6 @@ public class EndFeatures {
public static final EndFeature VIOLECITE_LAYER = EndFeature.makeLayerFeature("violecite_layer", EndBlocks.VIOLECITE, 15, 4, 96, 8); public static final EndFeature VIOLECITE_LAYER = EndFeature.makeLayerFeature("violecite_layer", EndBlocks.VIOLECITE, 15, 4, 96, 8);
public static final EndFeature FLAVOLITE_LAYER = EndFeature.makeLayerFeature("flavolite_layer", EndBlocks.FLAVOLITE, 12, 4, 96, 6); public static final EndFeature FLAVOLITE_LAYER = EndFeature.makeLayerFeature("flavolite_layer", EndBlocks.FLAVOLITE, 12, 4, 96, 6);
// Other //
//public static final EndFeature ETERNAL_PORTAL = EndFeature.makeChansedFeature("eternal_portal", new EternalPortalFeature(), 500);
public static void registerBiomeFeatures(Identifier id, Biome biome, List<List<Supplier<ConfiguredFeature<?, ?>>>> features) { public static void registerBiomeFeatures(Identifier id, Biome biome, List<List<Supplier<ConfiguredFeature<?, ?>>>> features) {
if (id.getNamespace().equals("minecraft")) { if (id.getNamespace().equals("minecraft")) {
String path = id.getPath(); String path = id.getPath();

View file

@ -23,6 +23,7 @@ public class BiomeShadowForest extends EndBiome {
.addFeature(EndFeatures.SHADOW_PLANT) .addFeature(EndFeatures.SHADOW_PLANT)
.addFeature(EndFeatures.MURKWEED) .addFeature(EndFeatures.MURKWEED)
.addFeature(EndFeatures.NEEDLEGRASS) .addFeature(EndFeatures.NEEDLEGRASS)
.addFeature(EndFeatures.SHADOW_BERRY)
.addFeature(EndFeatures.TWISTED_VINE) .addFeature(EndFeatures.TWISTED_VINE)
.addStructureFeature(ConfiguredStructureFeatures.END_CITY) .addStructureFeature(ConfiguredStructureFeatures.END_CITY)
.addMobSpawn(EntityType.ENDERMAN, 80, 1, 4) .addMobSpawn(EntityType.ENDERMAN, 80, 1, 4)

View file

@ -7,6 +7,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.basis.BlockDoublePlant; import ru.betterend.blocks.basis.BlockDoublePlant;
import ru.betterend.blocks.basis.BlockPlantWithAge;
import ru.betterend.util.BlocksHelper; import ru.betterend.util.BlocksHelper;
public class SinglePlantFeature extends ScatterFeature { public class SinglePlantFeature extends ScatterFeature {
@ -41,6 +42,11 @@ public class SinglePlantFeature extends ScatterFeature {
BlocksHelper.setWithoutUpdate(world, blockPos, state); BlocksHelper.setWithoutUpdate(world, blockPos, state);
BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(BlockDoublePlant.TOP, true)); BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(BlockDoublePlant.TOP, true));
} }
else if (plant instanceof BlockPlantWithAge) {
int age = random.nextInt(4);
BlockState state = plant.getDefaultState().with(BlockPlantWithAge.AGE, age);
BlocksHelper.setWithoutUpdate(world, blockPos, state);
}
else { else {
BlocksHelper.setWithoutUpdate(world, blockPos, plant); BlocksHelper.setWithoutUpdate(world, blockPos, plant);
} }

View file

@ -12,6 +12,7 @@
"ServerPlayerEntityMixin", "ServerPlayerEntityMixin",
"ChorusPlantFeatureMixin", "ChorusPlantFeatureMixin",
"ChorusFlowerBlockMixin", "ChorusFlowerBlockMixin",
"LandPathNodeMakerMixin",
"ChorusPlantBlockMixin", "ChorusPlantBlockMixin",
"RecipeManagerAccessor", "RecipeManagerAccessor",
"MinecraftServerMixin", "MinecraftServerMixin",