-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optional config value to force PolyMc to take over the int id of blocks
- Loading branch information
1 parent
a78fb14
commit c882014
Showing
7 changed files
with
80 additions
and
9 deletions.
There are no files selected for viewing
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
36 changes: 36 additions & 0 deletions
36
...lymc/mixins/block/implementations/dontforceintcontrol/ChunkDeltaUpdateImplementation.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,36 @@ | ||
/* | ||
* PolyMc | ||
* Copyright (C) 2020-2021 TheEpicBlock_TEB | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser 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 | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; If not, see <https://www.gnu.org/licenses>. | ||
*/ | ||
package io.github.theepicblock.polymc.mixins.block.implementations.dontforceintcontrol; | ||
|
||
import io.github.theepicblock.polymc.impl.Util; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.network.packet.s2c.play.ChunkDeltaUpdateS2CPacket; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
import xyz.nucleoid.packettweaker.PacketContext; | ||
|
||
@Mixin(ChunkDeltaUpdateS2CPacket.class) | ||
public class ChunkDeltaUpdateImplementation { | ||
@ModifyArg(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getRawIdFromState(Lnet/minecraft/block/BlockState;)I")) | ||
public BlockState getRawIdFromStateRedirect(BlockState state) { | ||
var player = PacketContext.get().getTarget(); | ||
var polymap = Util.tryGetPolyMap(player); | ||
return polymap.getClientState(state, player); | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
...polymc/mixins/block/implementations/forceintcontrol/WriteRegistryValueImplementation.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,24 @@ | ||
package io.github.theepicblock.polymc.mixins.block.implementations.forceintcontrol; | ||
|
||
import io.github.theepicblock.polymc.impl.Util; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.network.PacketByteBuf; | ||
import net.minecraft.util.collection.IndexedIterable; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import xyz.nucleoid.packettweaker.PacketContext; | ||
|
||
@Mixin(PacketByteBuf.class) | ||
public class WriteRegistryValueImplementation { | ||
@Redirect(method = "writeRegistryValue", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/collection/IndexedIterable;getRawId(Ljava/lang/Object;)I")) | ||
private <T> int redirectBlock(IndexedIterable<T> instance, T t) { | ||
if (instance == Block.STATE_IDS) { | ||
var player = PacketContext.get().getTarget(); | ||
var polymap = Util.tryGetPolyMap(player); | ||
return polymap.getClientStateRawId((BlockState)t, player); | ||
} | ||
return instance.getRawId(t); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -46,5 +46,10 @@ | |
"add": { | ||
"maxPacketsPerSecond": 600 | ||
} | ||
}, | ||
"10": { | ||
"add": { | ||
"forceBlockIdIntControl": 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