This repository has been archived by the owner on May 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[new] disablePlacedOnNetherPortalSides+
# New + disablePlacedOnNetherPortalSides
- Loading branch information
1 parent
c8c4f11
commit a85f675
Showing
6 changed files
with
148 additions
and
17 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/java/org/taichiserver/taichitweaks/PackMigrator/PackMigrator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.taichiserver.taichitweaks.PackMigrator; | ||
|
||
import java.nio.file.Path; | ||
|
||
public class PackMigrator { | ||
private static PackMigrator Process; | ||
private Path newInstancePath; | ||
private boolean processing; | ||
public PackMigrator(Path path){ | ||
this.newInstancePath = path; | ||
this.processing = false; | ||
} | ||
public boolean execute(){ | ||
if(Process.isProcessing()) return false; | ||
this.processing = true; | ||
Process = this; | ||
|
||
//unzip.init("",""); | ||
|
||
return true; | ||
} | ||
|
||
public boolean isProcessing() { | ||
return processing; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/org/taichiserver/taichitweaks/PackMigrator/unzip.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.taichiserver.taichitweaks.PackMigrator; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.nio.charset.Charset; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.zip.ZipEntry; | ||
import java.util.zip.ZipInputStream; | ||
|
||
public class unzip { | ||
public static boolean init(File zipfile, File target) { | ||
target.mkdirs(); | ||
|
||
return unzipper(StandardCharsets.UTF_8, target, zipfile) || | ||
unzipper(Charset.forName("MS932"), target, zipfile); | ||
} | ||
|
||
private static Boolean unzipper(Charset charset, File target, File zipfile) { | ||
try { | ||
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipfile), charset); | ||
ZipEntry e; | ||
while ((e = zis.getNextEntry()) != null) { | ||
var dst = Paths.get(target.toString(), e.getName()); | ||
if (e.isDirectory()) { | ||
Files.createDirectories(dst); | ||
} else { | ||
Files.createDirectories(dst.getParent()); | ||
Files.write(dst, zis.readAllBytes()); | ||
} | ||
//System.out.printf("inflating: %s%n", dst); | ||
} | ||
|
||
zis.closeEntry(); | ||
zis.close(); | ||
} catch (IllegalArgumentException | IOException e) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...ver/taichitweaks/mixins/restrictionPlacementOnNetherPortalSides/PlacementTweaksMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.taichiserver.taichitweaks.mixins.restrictionPlacementOnNetherPortalSides; | ||
|
||
import fi.dy.masa.malilib.util.PositionUtils; | ||
import fi.dy.masa.tweakeroo.tweaks.PlacementTweaks; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.block.NetherPortalBlock; | ||
import net.minecraft.client.network.ClientPlayerEntity; | ||
import net.minecraft.client.network.ClientPlayerInteractionManager; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import org.taichiserver.taichitweaks.config.Configs; | ||
|
||
@Mixin(PlacementTweaks.class) | ||
public class PlacementTweaksMixin { | ||
@Inject(method = "tryPlaceBlock", at = @At("HEAD"), cancellable = true) | ||
private static void tryPlaceBlock(ClientPlayerInteractionManager controller, ClientPlayerEntity player, ClientWorld world, BlockPos posIn, Direction sideIn, Direction sideRotatedIn, float playerYaw, Vec3d hitVec, Hand hand, PositionUtils.HitPart hitPart, boolean isFirstClick, CallbackInfoReturnable<ActionResult> cir){ | ||
if(!Configs.Generic.DISABLE_PLACED_ON_PORTAL_SIDES.getBooleanValue()) return; | ||
|
||
// if (!Configs.disablePlacedOnNetherPortalSides.getBool()) { | ||
// return; | ||
// } | ||
if (checkNeighbors(world, posIn.north(), Direction.Axis.Z, cir)) { | ||
return; | ||
} | ||
if (checkNeighbors(world, posIn.south(), Direction.Axis.Z, cir)) { | ||
return; | ||
} | ||
if (checkNeighbors(world, posIn.east(), Direction.Axis.X, cir)) { | ||
return; | ||
} | ||
if (checkNeighbors(world, posIn.west(), Direction.Axis.X, cir)) { | ||
return; | ||
} | ||
if (checkNeighbors(world, posIn.up(), Direction.Axis.Y, cir)) { | ||
return; | ||
} | ||
if (checkNeighbors(world, posIn.down(), Direction.Axis.Y, cir)) { | ||
return; | ||
} | ||
} | ||
private static boolean checkNeighbors(World world, BlockPos blockPos, Direction.Axis axis, CallbackInfoReturnable<ActionResult> cir) { | ||
BlockState blockState = world.getBlockState(blockPos); | ||
if (blockState.isOf(Blocks.NETHER_PORTAL)) { | ||
if (Direction.Axis.Y == axis || blockState.get(NetherPortalBlock.AXIS) == axis) { | ||
cir.setReturnValue(ActionResult.CONSUME); | ||
cir.cancel(); | ||
//sendRestrictionMessage("placed on Nether Portal sides"); | ||
System.out.println("placed on Nether Portal sides"); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters