Skip to content

Commit

Permalink
Start moving some simpler things to new tracker package.
Browse files Browse the repository at this point in the history
  • Loading branch information
i509VCB committed Feb 7, 2020
1 parent ee6d61e commit 98e8d33
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 175 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.mixin.core.item;
package org.spongepowered.common.mixin.tracker.item;

import net.minecraft.block.BlockState;
import net.minecraft.block.IGrowable;
import net.minecraft.item.DyeItem;
import net.minecraft.item.BoneMealItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -44,8 +44,8 @@

import java.util.Random;

@Mixin(DyeItem.class)
public abstract class DyeItemMixin extends ItemMixin {
@Mixin(BoneMealItem.class)
public abstract class BoneMealItemMixin_Tracker {

/**
* @author gabizou - March 20th, 2019 - 1.12.2
Expand Down Expand Up @@ -74,7 +74,7 @@ public abstract class DyeItemMixin extends ItemMixin {
method = "applyBonemeal",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/block/IGrowable;grow(Lnet/minecraft/world/World;Ljava/util/Random;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;)V"
target = "Lnet/minecraft/block/IGrowable;grow(Lnet/minecraft/world/World;Ljava/util/Random;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V"
),
require = 0, // Will be removed once the above github issue is resolved with a proper solution
// Even though we're in a group, expecting this to succeed in forge environments will not work since there is a different mixin
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.spongepowered.common.mixin.tracker.world.end;

import net.minecraft.entity.item.EnderCrystalEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.end.DragonFightManager;
import net.minecraft.world.end.DragonSpawnState;
import net.minecraft.world.server.ServerWorld;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.common.event.tracking.PhaseTracker;
import org.spongepowered.common.event.tracking.context.GeneralizedContext;
import org.spongepowered.common.event.tracking.phase.world.dragon.DragonPhase;

import java.util.List;

@Mixin(DragonFightManager.class)
public abstract class DragonFightManagerMixin_Tracker {

/**
* @author i509vcb - February 6th 2020
* @reason Add sponge necessary phase state switches
*
* @param dragonSpawnState The dragon spawn state.
* @param worldIn The world this respawnState is occuring in.
* @param manager The current DragonFightManager.
* @param crystals List of all currently present end crystals.
* @param respawnStateTicks The amount of this this respawn state has been running for.
* @param exitPortalLocation The position of the exit portal.
*/
@Redirect(method = "tick()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/end/DragonSpawnState;process(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraft/world/end/DragonFightManager;Ljava/util/List;ILnet/minecraft/util/math/BlockPos;)V"))
private void trackDragonRespawn(DragonSpawnState dragonSpawnState, ServerWorld worldIn, DragonFightManager manager, List<EnderCrystalEntity> crystals, int respawnStateTicks, BlockPos exitPortalLocation) {
try (final GeneralizedContext context = DragonPhase.State.RESPAWN_DRAGON.createPhaseContext(PhaseTracker.SERVER)) {
context.buildAndSwitch();
++respawnStateTicks;
dragonSpawnState.process(worldIn, manager, crystals, respawnStateTicks, exitPortalLocation);
}
}
}
2 changes: 0 additions & 2 deletions src/main/resources/mixins.common.core.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
"entity.projectile.SnowballEntityMixin",
"entity.projectile.ThrowableEntityMixin",
"entity.projectile.WitherSkullEntityMixin",
"item.DyeItemMixin",
"item.EnderEyeItemMixin",
"item.FilledMapItemMixin",
"item.FishingRodItemMixin",
Expand Down Expand Up @@ -225,7 +224,6 @@
"world.dimension.DimensionMixin",
"world.dimension.DimensionTypeMixin",
"world.dimension.NetherDimensionMixin",
"world.end.DragonFightManagerMixin",
"world.raid.RaidMixin",
"world.server.ChunkManager_EntityTrackerMixin",
"world.server.ChunkManagerMixin",
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/mixins.common.tracker.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
"plugin": "org.spongepowered.common.mixin.plugin.TrackerPlugin",
"mixinPriority" : 1111,
"mixins": [
"block.BlockMixin_Tracker",
"block.DispenserBlockMixin_Tracker",
"block.LeavesBlockMixin_Tracker",
"item.BoneMealItemMixin_Tracker",
"world.chunk.ChunkMixin_OwnershipTracked",
"world.WorldMixin_OwnershipTracked",
"world.end.DragonFightManagerMixin_Tracker",
"world.WorldMixin_OwnershipTracked",
"OwnershipTrackedMixin_Tracker"
],
"server": [
Expand Down

0 comments on commit 98e8d33

Please sign in to comment.