Skip to content

Commit

Permalink
Updated to Minecraft 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuuta0217 committed Oct 15, 2023
1 parent f85d2a4 commit 321aeae
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ repositories {
}

dependencies {
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.20.1-R0.1-SNAPSHOT")
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.20.2-R0.1-SNAPSHOT")
implementation "net.sf.jopt-simple:jopt-simple:5.0.4"
implementation 'org.ow2.asm:asm:9.3'
implementation 'org.ow2.asm:asm-commons:9.3'
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/net/unknown/launchwrapper/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@
import java.util.concurrent.TimeUnit;

public class Main {
public static boolean FORCE_ALLOW_BUNDLE_FEATURES = System.getProperty("UnknownNetworkMagic") != null && System.getProperty("UnknownNetworkMagic").equals("bundle");
public static boolean FORCE_ALLOW_BUNDLE_FEATURES = System.getProperty("UnknownNetworkMagic") != null && System.getProperty("UnknownNetworkMagic").contains("bundle");
public static boolean FORCE_ALLOW_TRADE_REBALANCE_FEATURES = System.getProperty("UnknownNetworkMagic") != null && System.getProperty("UnknownNetworkMagic").contains("trade-rebalance");
private static final String FILE_SEPARATOR = System.getProperty("file.separator");

public static void main(String[] args) throws IOException, InterruptedException {
if (FORCE_ALLOW_BUNDLE_FEATURES) {
System.out.println("""
Unknown Network Bootstrap
Hey! You're activated "bundle" feature, but this is contains bugs or crashes. Be careful!
Server will start after 3 seconds...
""");
if (FORCE_ALLOW_BUNDLE_FEATURES || FORCE_ALLOW_TRADE_REBALANCE_FEATURES) {
String activatedFeatureFlags = String.join(",", (FORCE_ALLOW_BUNDLE_FEATURES ? "bundle" : ""), (FORCE_ALLOW_TRADE_REBALANCE_FEATURES ? "trade_rebalance" : ""));
System.out.println("\n" +
"\n" +
" Unknown Network Bootstrap\n" +
"Hey! You're activated \"" + activatedFeatureFlags + "\" feature, but this is contains bugs or crashes. Be careful!\n" +
"Server will start after 3 seconds...\n" +
"\n" +
"\n");
Thread.sleep(TimeUnit.SECONDS.toMillis(3));
}
Agent.addJar(new File("./versions/1.20.1/paper-1.20.1.jar"));
Agent.addJar(new File("./versions/1.20.2/paper-1.20.2.jar"));

Map<String, File> toLoadLibraries = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

package net.unknown.launchwrapper.event;

import net.minecraft.core.BlockSource;
import net.minecraft.core.dispenser.BlockSource;
import net.minecraft.world.item.ItemStack;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_20_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_20_R2.block.CraftBlock;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
Expand All @@ -56,7 +56,7 @@ public BlockSource getBlockSource() {
}

public Block getBukkitBlock() {
return CraftBlock.at(this.src.getLevel(), this.src.getPos());
return CraftBlock.at(this.src.level(), this.src.pos());
}

public ItemStack getItem() {
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/net/unknown/launchwrapper/hopper/TransportType.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
/*
* Copyright (c) 2023 Unknown Network Developers and contributors.
*
* All rights reserved.
*
* NOTICE: This license is subject to change without prior notice.
*
* Redistribution and use in source and binary forms, *without modification*,
* are permitted provided that the following conditions are met:
*
* I. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* II. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* III. Neither the name of Unknown Network nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific prior written permission.
*
* IV. This source code and binaries is provided by the copyright holders and contributors "AS-IS" and
* any express or implied warranties, including, but not limited to, the implied warranties of
* merchantability and fitness for a particular purpose are disclaimed.
* In not event shall the copyright owner or contributors be liable for
* any direct, indirect, incidental, special, exemplary, or consequential damages
* (including but not limited to procurement of substitute goods or services;
* loss of use data or profits; or business interruption) however caused and on any theory of liability,
* whether in contract, strict liability, or tort (including negligence or otherwise)
* arising in any way out of the use of this source code, event if advised of the possibility of such damage.
*/

package net.unknown.launchwrapper.hopper;

public enum TransportType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

package net.unknown.launchwrapper.mixins;

import org.bukkit.craftbukkit.v1_20_R1.CraftServer;
import org.bukkit.craftbukkit.v1_20_R2.CraftServer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

package net.unknown.launchwrapper.mixins;

import net.minecraft.core.BlockSource;
import net.minecraft.core.Direction;
import net.minecraft.core.dispenser.BlockSource;
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
import net.minecraft.core.dispenser.DispenseItemBehavior;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -61,11 +61,12 @@ public abstract class MixinDefaultDispenseItemBehavior implements DispenseItemBe
* Add BlockDispenseBeforeEvent
*
* @author ryuuta0217
* @reason Add BlockDispenseBeforeEvent
*/
@Overwrite
@Override
public final ItemStack dispense(BlockSource pointer, ItemStack stack) {
this.enumdirection = pointer.getBlockState().getValue(DispenserBlock.FACING); // Paper - cache facing direction
this.enumdirection = pointer.state().getValue(DispenserBlock.FACING); // Paper - cache facing direction
// Unknown Network Start - Add BlockDispenseBeforeEvent
BlockDispenseBeforeEvent event = new BlockDispenseBeforeEvent(pointer, stack);
Bukkit.getPluginManager().callEvent(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ public class MixinEnderChestBlock {
@Shadow @Final private static Component CONTAINER_TITLE;

/**
* Overwrite reason: Inject de yaruno kuso mendo-kusai
*
* @author ryuuta0217
* @see net.unknown.launchwrapper.mixins.MixinSimpleContainer
* @reason Inject de yaruno kuso mendo-kusai
*/
@Overwrite
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.*;

import java.util.ArrayList;
import java.util.List;

@Mixin(FeatureFlags.class)
public class MixinFeatureFlags {
@Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/flag/FeatureFlagSet;of(Lnet/minecraft/world/flag/FeatureFlag;)Lnet/minecraft/world/flag/FeatureFlagSet;"))
private static FeatureFlagSet onClInit(FeatureFlag feature) {
if (Main.FORCE_ALLOW_BUNDLE_FEATURES) {
return FeatureFlagSet.of(feature, FeatureFlags.BUNDLE);
} else {
return FeatureFlagSet.of(feature);
}
List<FeatureFlag> additionalFlags = new ArrayList<>() {{
if (Main.FORCE_ALLOW_BUNDLE_FEATURES) add(FeatureFlags.BUNDLE);
if (Main.FORCE_ALLOW_TRADE_REBALANCE_FEATURES) add(FeatureFlags.TRADE_REBALANCE);
}};

return !additionalFlags.isEmpty() ? FeatureFlagSet.of(feature, additionalFlags.toArray(FeatureFlag[]::new)) : FeatureFlagSet.of(feature);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import net.unknown.launchwrapper.event.ObserverBlockRemoveEvent;
import net.unknown.launchwrapper.event.ObserverBlockTickEvent;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_20_R1.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

@Mixin(SignBlockEntity.class)
public class MixinSignBlockEntity {
// TODO: Add "UUID owner;" field, and add to saveAdditional()
@Shadow @Nullable public UUID playerWhoMayEdit;

@Overwrite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import net.minecraft.world.SimpleContainer;
import net.minecraft.world.inventory.PlayerEnderChestContainer;
import net.minecraft.world.item.ItemStack;
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
import org.bukkit.inventory.InventoryHolder;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand Down

0 comments on commit 321aeae

Please sign in to comment.