Skip to content

Commit

Permalink
fix: compat between versions
Browse files Browse the repository at this point in the history
  • Loading branch information
wendavid552 committed Feb 17, 2023
1 parent 0e26f35 commit 0800cff
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package club.mcams.carpet.mixin.rule.optimizedDragonRespawn;

import com.google.common.cache.LoadingCache;
import net.minecraft.block.pattern.BlockPattern;
import net.minecraft.block.pattern.CachedBlockPosition;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.WorldView;

public class BlockPatternHelper {
public static BlockPattern.Result partialSearchAround(BlockPattern pattern, WorldView world, BlockPos pos) {
LoadingCache<BlockPos, CachedBlockPosition> loadingCache = BlockPattern.makeCache(world, false);
int i = Math.max(Math.max(pattern.getWidth(), pattern.getHeight()), pattern.getDepth());
for (BlockPos blockPos : BlockPos.iterate(pos, pos.add(i - 1, 0, i - 1))) {
for (Direction direction : Direction.values()) {
for (Direction direction2 : Direction.values()) {
BlockPattern.Result result;
if (direction2 == direction || direction2 == direction.getOpposite() || (result = ((BlockPatternTestTransformInvoker)pattern).invokeTestTransform(blockPos, direction, direction2, loadingCache)) == null) continue;
return result;
}
}
}
return null;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package club.mcams.carpet.mixin.rule.optimizedDragonRespawn;

import com.google.common.cache.LoadingCache;
import net.minecraft.block.pattern.BlockPattern;
import net.minecraft.block.pattern.CachedBlockPosition;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(BlockPattern.class)
public interface BlockPatternTestTransformInvoker {
@Invoker("testTransform")
BlockPattern.Result invokeTestTransform(BlockPos frontTopLeft, Direction forwards, Direction up, LoadingCache<BlockPos, CachedBlockPosition> cache);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ public abstract class EnderDragonFightMixin {
for(j = i; j >= 0; --j) {
BlockPattern.Result result2;
if(AmsServerSettings.optimizedDragonRespawn && notFirstSearch) {
// TextUtil.broadcastToAllPlayers("2Invoke partial searchAround "+ new BlockPos(EndPortalFeature.ORIGIN.getX(), j, EndPortalFeature.ORIGIN.getZ()).toString());
result2 = this.endPortalPattern.partialSearchAround(this.world, new BlockPos(EndPortalFeature.ORIGIN.getX(), j, EndPortalFeature.ORIGIN.getZ()));
}
else{
// TextUtil.broadcastToAllPlayers("2Invoke searchAround "+ new BlockPos(EndPortalFeature.ORIGIN.getX(), j, EndPortalFeature.ORIGIN.getZ()).toString());
result2 = BlockPatternHelper.partialSearchAround(this.endPortalPattern, this.world, new BlockPos(EndPortalFeature.ORIGIN.getX(), j, EndPortalFeature.ORIGIN.getZ()));
}
else{
result2 = this.endPortalPattern.searchAround(this.world, new BlockPos(EndPortalFeature.ORIGIN.getX(), j, EndPortalFeature.ORIGIN.getZ()));
}
if (result2 != null) {
Expand Down
9 changes: 4 additions & 5 deletions src/main/resources/amscarpet.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
"rule.blockChunkLoader.BellBlockMixin",
"rule.blockChunkLoader.NoteBlockMixin",
"rule.blockChunkLoader.PistonBlockMixin",
"rule.optimizedDragonRespawn.BlockPatternMixin",
"rule.optimizedDragonRespawn.BlockPatternTranslateInvoker",
"rule.optimizedDragonRespawn.EnderDragonFightMixin"
"rule.superBow.SuperBow",
"rule.optimizedDragonRespawn.BlockPatternTestTransformInvoker",
"rule.optimizedDragonRespawn.EnderDragonFightMixin",
"rule.scheduledRandomTick.AbstractPlantPartBlockMixin",
"rule.scheduledRandomTick.BambooBlockMixin",
"rule.scheduledRandomTick.CactusBlockMixin",
"rule.scheduledRandomTick.ChorusFlowerBlockMixin",
"rule.scheduledRandomTick.SugarCaneBlockMixin"
"rule.scheduledRandomTick.SugarCaneBlockMixin",
"rule.superBow.SuperBow"
],
"client": [
],
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
"carpet": "${carpet_dependency}"
},
"custom": {
"loom:injected_interfaces": {
"net/minecraft/class_2700": ["club/mcams/carpet/fake/BlockPatternPartialSearchAroundInvoker"]
},
"modmenu": {
"parent": "carpet"
},
Expand Down

0 comments on commit 0800cff

Please sign in to comment.