More dragon respawn fixes

This commit is contained in:
paulevsGitch 2021-05-03 23:27:22 +03:00
parent 28cd23f378
commit 20176730f9
7 changed files with 90 additions and 15 deletions

View file

@ -1,7 +1,5 @@
package ru.betterend.item; package ru.betterend.item;
import net.fabricmc.fabric.api.item.v1.EquipmentSlotProvider;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry; import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.EquipmentSlot;
@ -11,8 +9,6 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity; import net.minecraft.world.item.Rarity;
import ru.betterend.BetterEnd; import ru.betterend.BetterEnd;
import ru.betterend.interfaces.BreakableItem; import ru.betterend.interfaces.BreakableItem;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
public class ArmoredElytra extends ElytraItem implements BreakableItem { public class ArmoredElytra extends ElytraItem implements BreakableItem {

View file

@ -52,25 +52,25 @@ public class EndDragonFightMixin {
@Inject(method = "tryRespawn", at = @At("HEAD"), cancellable = true) @Inject(method = "tryRespawn", at = @At("HEAD"), cancellable = true)
private void be_tryRespawnDragon(CallbackInfo info) { private void be_tryRespawnDragon(CallbackInfo info) {
if (GeneratorOptions.replacePortal() && GeneratorOptions.hasDragonFights() && this.dragonKilled && this.respawnStage == null) { if (GeneratorOptions.replacePortal() && GeneratorOptions.hasDragonFights() && this.dragonKilled && this.respawnStage == null) {
BlockPos blockPos = this.portalLocation; BlockPos blockPos = portalLocation;
if (blockPos == null) { if (blockPos == null) {
LOGGER.debug("Tried to respawn, but need to find the portal first."); LOGGER.debug("Tried to respawn, but need to find the portal first.");
BlockPattern.BlockPatternMatch blockPatternMatch = this.findExitPortal(); BlockPattern.BlockPatternMatch blockPatternMatch = this.findExitPortal();
if (blockPatternMatch == null) { if (blockPatternMatch == null) {
LOGGER.debug("Couldn't find a portal, so we made one."); LOGGER.debug("Couldn't find a portal, so we made one.");
this.spawnExitPortal(true); spawnExitPortal(true);
} }
else { else {
LOGGER.debug("Found the exit portal & temporarily using it."); LOGGER.debug("Found the exit portal & temporarily using it.");
} }
blockPos = this.portalLocation; blockPos = portalLocation;
} }
List<EndCrystal> crystals = Lists.newArrayList(); List<EndCrystal> crystals = Lists.newArrayList();
BlockPos center = blockPos.above(2); BlockPos center = GeneratorOptions.getPortalPos().above(5);
for (Direction dir : BlocksHelper.HORIZONTAL) { for (Direction dir : BlocksHelper.HORIZONTAL) {
List<EndCrystal> crystalList = this.level.getEntitiesOfClass(EndCrystal.class, new AABB(center.relative(dir, 3))); List<EndCrystal> crystalList = level.getEntitiesOfClass(EndCrystal.class, new AABB(center.relative(dir, 4)));
if (crystalList.isEmpty()) { if (crystalList.isEmpty()) {
info.cancel(); info.cancel();
return; return;
@ -80,7 +80,7 @@ public class EndDragonFightMixin {
} }
LOGGER.debug("Found all crystals, respawning dragon."); LOGGER.debug("Found all crystals, respawning dragon.");
this.respawnDragon(crystals); respawnDragon(crystals);
info.cancel(); info.cancel();
} }
} }

View file

@ -0,0 +1,43 @@
package ru.betterend.mixin.common;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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.nbt.CompoundTag;
import net.minecraft.world.level.levelgen.feature.SpikeFeature.EndSpike;
import ru.betterend.util.WorldDataUtil;
import ru.betterend.world.generator.GeneratorOptions;
@Mixin(EndSpike.class)
public class EndSpikeMixin {
@Final
@Shadow
private int height;
@Inject(method = "getHeight", at = @At("HEAD"), cancellable = true)
private void be_getSpikeHeight(CallbackInfoReturnable<Integer> info) {
if (!GeneratorOptions.isDirectSpikeHeight()) {
int x = getCenterX();
int z = getCenterZ();
String pillarID = String.format("%d_%d", x, z);
CompoundTag pillar = WorldDataUtil.getCompoundTag("pillars");
int minY = pillar.contains(pillarID) ? pillar.getInt(pillarID) : 65;
int maxY = minY + height - 54;
info.setReturnValue(maxY);
}
}
@Shadow
public int getCenterX() {
return 0;
}
@Shadow
public int getCenterZ() {
return 0;
}
}

View file

@ -63,6 +63,7 @@ public class SpikeFeatureMixin {
minY = world.getChunk(x >> 4, z >> 4).getHeight(Types.WORLD_SURFACE, x & 15, z); minY = world.getChunk(x >> 4, z >> 4).getHeight(Types.WORLD_SURFACE, x & 15, z);
} }
GeneratorOptions.setDirectSpikeHeight();
int maxY = minY + spike.getHeight() - 64; int maxY = minY + spike.getHeight() - 64;
if (GeneratorOptions.replacePillars() && be_radiusInRange(radius)) { if (GeneratorOptions.replacePillars() && be_radiusInRange(radius)) {

View file

@ -1,6 +1,9 @@
package ru.betterend.registry; package ru.betterend.registry;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockSource; import net.minecraft.core.BlockSource;
@ -17,20 +20,40 @@ import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.food.FoodProperties; import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.food.Foods; import net.minecraft.world.food.Foods;
import net.minecraft.world.item.*; import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.ShovelItem;
import net.minecraft.world.item.SpawnEggItem;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.TieredItem;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.level.block.DispenserBlock; import net.minecraft.world.level.block.DispenserBlock;
import ru.betterend.BetterEnd; import ru.betterend.BetterEnd;
import ru.betterend.config.Configs; import ru.betterend.config.Configs;
import ru.betterend.interfaces.BreakableItem; import ru.betterend.interfaces.BreakableItem;
import ru.betterend.item.*; import ru.betterend.item.ArmoredElytra;
import ru.betterend.item.DrinkItem;
import ru.betterend.item.EnchantedPetalItem;
import ru.betterend.item.EndArmorItem;
import ru.betterend.item.EndBucketItem;
import ru.betterend.item.EndSpawnEggItem;
import ru.betterend.item.EternalCrystalItem;
import ru.betterend.item.PatternedDiscItem;
import ru.betterend.item.PatternedItem;
import ru.betterend.item.material.EndArmorMaterial; import ru.betterend.item.material.EndArmorMaterial;
import ru.betterend.item.material.EndToolMaterial; import ru.betterend.item.material.EndToolMaterial;
import ru.betterend.item.tool.*; import ru.betterend.item.tool.EndAxeItem;
import ru.betterend.item.tool.EndHammerItem;
import ru.betterend.item.tool.EndHoeItem;
import ru.betterend.item.tool.EndPickaxeItem;
import ru.betterend.item.tool.EndShovelItem;
import ru.betterend.item.tool.EndSwordItem;
import ru.betterend.tab.CreativeTabs; import ru.betterend.tab.CreativeTabs;
import ru.betterend.util.TagHelper; import ru.betterend.util.TagHelper;
import java.util.List;
public class EndItems { public class EndItems {
private static final List<Item> MOD_BLOCKS = Lists.newArrayList(); private static final List<Item> MOD_BLOCKS = Lists.newArrayList();
private static final List<Item> MOD_ITEMS = Lists.newArrayList(); private static final List<Item> MOD_ITEMS = Lists.newArrayList();

View file

@ -28,6 +28,7 @@ public class GeneratorOptions {
private static boolean replacePillars; private static boolean replacePillars;
private static long islandDistBlock; private static long islandDistBlock;
private static int islandDistChunk; private static int islandDistChunk;
private static boolean directSpikeHeight;
public static void init() { public static void init() {
biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256); biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256);
@ -142,4 +143,14 @@ public class GeneratorOptions {
public static int getIslandDistChunk() { public static int getIslandDistChunk() {
return islandDistChunk; return islandDistChunk;
} }
public static void setDirectSpikeHeight() {
directSpikeHeight = true;
}
public static boolean isDirectSpikeHeight() {
boolean height = directSpikeHeight;
directSpikeHeight = false;
return height;
}
} }

View file

@ -34,6 +34,7 @@
"AnvilMenuMixin", "AnvilMenuMixin",
"TagLoaderMixin", "TagLoaderMixin",
"EnderManMixin", "EnderManMixin",
"EndSpikeMixin",
"MonsterMixin", "MonsterMixin",
"EntityMixin", "EntityMixin",
"PlayerMixin", "PlayerMixin",