Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #3 for 1.19.2 #6

Open
wants to merge 2 commits into
base: 1.19
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/main/java/com/darkere/moredragoneggs/MoreDragonEggs.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.darkere.moredragoneggs;

import com.darkere.moredragoneggs.mixin.EndDragonFightAccess;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.TickTask;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.WallSkullBlock;
import net.minecraft.world.level.dimension.end.EndDragonFight;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.EndPodiumFeature;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
Expand Down Expand Up @@ -59,4 +63,15 @@ public static void PlaceDragonHead(BlockPos pos, ServerLevel level) {
}


public static void placeAdditionalEggAndMaybeHead(EndDragonFight dragonFight) {
ServerLevel level = ((EndDragonFightAccess)dragonFight).moredragoneggs_getLevel();
BlockPos pos = level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.END_PODIUM_LOCATION);
while (level.getBlockState(pos).getBlock() != Blocks.AIR){
pos = pos.above();
}
if (dragonFight.hasPreviouslyKilledDragon()) {
level.setBlockAndUpdate(pos, Blocks.DRAGON_EGG.defaultBlockState());
}
PlaceDragonHead( pos, level);
}
}
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
package com.darkere.moredragoneggs.mixin;

import com.darkere.moredragoneggs.MoreDragonEggs;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.dimension.end.EndDragonFight;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.EndPodiumFeature;
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.CallbackInfo;

@Mixin(EndDragonFight.class)
public class DragonEggMixin {

@Shadow
private
boolean previouslyKilled;
@Shadow
@Final
private
ServerLevel level;


@Inject(at = @At("HEAD"),method = "setDragonKilled(Lnet/minecraft/world/entity/boss/enderdragon/EnderDragon;)V")
private void setDragonKilled(EnderDragon p_64086_, CallbackInfo cb) {
BlockPos pos = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.END_PODIUM_LOCATION);
if (this.previouslyKilled) {
this.level.setBlockAndUpdate(pos, Blocks.DRAGON_EGG.defaultBlockState());
}
MoreDragonEggs.PlaceDragonHead( pos, this.level);
MoreDragonEggs.placeAdditionalEggAndMaybeHead((EndDragonFight)(Object)this);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.darkere.moredragoneggs.mixin;

import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.dimension.end.EndDragonFight;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(EndDragonFight.class)
public interface EndDragonFightAccess {

@Accessor("level")
ServerLevel moredragoneggs_getLevel();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.darkere.moredragoneggs.mixin;

import com.darkere.moredragoneggs.MoreDragonEggs;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
import net.minecraft.world.level.dimension.end.EndDragonFight;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Pseudo
@Mixin(targets = "com.teamabnormals.endergetic.common.world.EndergeticDragonFightManager")
public class EndergeticDragonEggMixin extends EndDragonFight {

public EndergeticDragonEggMixin(ServerLevel level, long seed, CompoundTag fightData) {
super(level, seed, fightData);
}

@Inject(at = @At("HEAD"),method = "setDragonKilled(Lnet/minecraft/world/entity/boss/enderdragon/EnderDragon;)V")
private void setDragonKilled(EnderDragon p_64086_, CallbackInfo cb) {
MoreDragonEggs.placeAdditionalEggAndMaybeHead(this);
}
}
6 changes: 5 additions & 1 deletion src/main/resources/mixins.moredragoneggs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"package": "com.darkere.moredragoneggs.mixin",
"compatibilityLevel": "JAVA_17",
"refmap": "mixins.moredragoneggs.refmap.json",
"mixins": ["DragonEggMixin"],
"mixins": [
"DragonEggMixin",
"EndDragonFightAccess",
"EndergeticDragonEggMixin"
],
"minVersion": "0.8"
}