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

Start moving some simpler things to new tracker package [API-8]. #2499

Merged
merged 1 commit into from
Feb 11, 2020
Merged
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

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,13 +74,13 @@ 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
i509VCB marked this conversation as resolved.
Show resolved Hide resolved
expect = 0
)
private static void onGrowableVanilla(IGrowable iGrowable, World worldIn, Random rand, BlockPos pos, BlockState blockState, ItemStack stack, World sameWorld, BlockPos target) {
private static void tracker$wrapGrowWithPhaseEntry(IGrowable iGrowable, World worldIn, Random rand, BlockPos pos, BlockState blockState, ItemStack stack, World sameWorld, BlockPos target) {
if (((WorldBridge) worldIn).bridge$isFake() || !ShouldFire.CHANGE_BLOCK_EVENT_GROW) {
iGrowable.grow(worldIn, rand, pos, blockState);
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* This file is part of Sponge, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.mixin.tracker.world.end;
i509VCB marked this conversation as resolved.
Show resolved Hide resolved

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 tracker$wrapSpawnStateWithPhaseEntry(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