-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f445ecd
commit dc21828
Showing
6 changed files
with
221 additions
and
3 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
src/main/java/de/florianmichael/viafabricplus/definition/RecipesPre1_12.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,67 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus | ||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.florianmichael.viafabricplus.definition; | ||
|
||
import net.minecraft.block.ConcretePowderBlock; | ||
import net.minecraft.block.GlazedTerracottaBlock; | ||
import net.minecraft.block.ShulkerBoxBlock; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.item.BlockItem; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.recipe.*; | ||
import net.raphimc.vialoader.util.VersionEnum; | ||
|
||
import java.util.List; | ||
|
||
public class RecipesPre1_12 { | ||
|
||
public static void editRecipes(final List<Recipe<?>> recipes, final VersionEnum version) { | ||
final var registryManager = MinecraftClient.getInstance().world.getRegistryManager(); | ||
|
||
recipes.removeIf(recipe -> { | ||
if (recipe.getResult(registryManager).getItem() instanceof BlockItem block) { | ||
return block.getBlock() instanceof ConcretePowderBlock || block.getBlock() instanceof GlazedTerracottaBlock; | ||
} | ||
return false; | ||
}); | ||
|
||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_11)) { | ||
recipes.removeIf(recipe -> recipe.getResult(registryManager).getItem() == Items.IRON_NUGGET); | ||
|
||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_10)) { | ||
recipes.removeIf(recipe -> { | ||
Item item = recipe.getResult(registryManager).getItem(); | ||
if (item instanceof BlockItem blockItem) { | ||
return blockItem.getBlock() instanceof ShulkerBoxBlock; | ||
} else if (item == Items.OBSERVER || item == Items.IRON_NUGGET) { | ||
return true; | ||
} else if (item == Items.GOLD_NUGGET) { | ||
return recipe.getSerializer() == RecipeSerializer.SMELTING; | ||
} else { | ||
return false; | ||
} | ||
}); | ||
} | ||
|
||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4)) { | ||
recipes.removeIf(recipe -> recipe.getResult(registryManager).getItem() == Items.BONE_BLOCK); | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/de/florianmichael/viafabricplus/injection/access/IProtocol1_13To1_12_2.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,25 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus | ||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.florianmichael.viafabricplus.injection.access; | ||
|
||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; | ||
|
||
public interface IProtocol1_13To1_12_2 { | ||
|
||
void viafabricplus_writeDeclareRecipes(final PacketWrapper recipesPacket); | ||
} |
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
63 changes: 63 additions & 0 deletions
63
...plus/injection/mixin/fixes/viaversion/protocol1_12to1_11_1/MixinProtocol1_12To1_11_1.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,63 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus | ||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion.protocol1_12to1_11_1; | ||
|
||
import com.viaversion.viaversion.api.Via; | ||
import com.viaversion.viaversion.api.minecraft.ClientWorld; | ||
import com.viaversion.viaversion.api.protocol.AbstractProtocol; | ||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; | ||
import com.viaversion.viaversion.api.type.Type; | ||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12; | ||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1; | ||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12; | ||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; | ||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; | ||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; | ||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; | ||
import de.florianmichael.viafabricplus.injection.access.IProtocol1_13To1_12_2; | ||
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.CallbackInfo; | ||
|
||
@Mixin(value = Protocol1_12To1_11_1.class, remap = false) | ||
public class MixinProtocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9_3, ClientboundPackets1_12, ServerboundPackets1_9_3, ServerboundPackets1_12> { | ||
|
||
@Inject(method = "registerPackets", at = @At("RETURN")) | ||
public void enforceRecipeWriting(CallbackInfo ci) { | ||
registerClientbound(ClientboundPackets1_9_3.JOIN_GAME, new PacketHandlers() { | ||
@Override | ||
public void register() { | ||
map(Type.INT); | ||
map(Type.UNSIGNED_BYTE); | ||
map(Type.INT); | ||
handler(wrapper -> { | ||
wrapper.user().get(ClientWorld.class).setEnvironment(wrapper.get(Type.INT, 1)); | ||
|
||
final IProtocol1_13To1_12_2 protocol = (IProtocol1_13To1_12_2) wrapper.user().getProtocolInfo().getPipeline().getProtocol(Protocol1_13To1_12_2.class); | ||
if (protocol == null) { | ||
Via.getPlatform().getLogger().warning("Protocol1_13To1_12_2 not found!"); | ||
return; | ||
} | ||
|
||
wrapper.create(ClientboundPackets1_13.DECLARE_RECIPES, protocol::viafabricplus_writeDeclareRecipes).scheduleSend(Protocol1_13To1_12_2.class); | ||
}); | ||
} | ||
}); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...plus/injection/mixin/fixes/viaversion/protocol1_13to1_12_2/MixinProtocol1_13To1_12_2.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,35 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus | ||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion.protocol1_13to1_12_2; | ||
|
||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; | ||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; | ||
import de.florianmichael.viafabricplus.injection.access.IProtocol1_13To1_12_2; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@Mixin(value = Protocol1_13To1_12_2.class, remap = false) | ||
public abstract class MixinProtocol1_13To1_12_2 implements IProtocol1_13To1_12_2 { | ||
|
||
@Shadow protected abstract void writeDeclareRecipes(PacketWrapper recipesPacket); | ||
|
||
@Override | ||
public void viafabricplus_writeDeclareRecipes(PacketWrapper recipesPacket) { | ||
writeDeclareRecipes(recipesPacket); | ||
} | ||
} |
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