-
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.
- Loading branch information
1 parent
b03c8a7
commit 84217ce
Showing
5 changed files
with
142 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,12 @@ out | |
# gradle | ||
build | ||
.gradle | ||
logs | ||
|
||
# other | ||
eclipse | ||
run | ||
.vscode | ||
|
||
# Files from Forge MDK | ||
forge*changelog.txt |
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
131 changes: 125 additions & 6 deletions
131
...ain/java/com/sunekaer/mods/structureexpansion/mixin/CUpdateStructureBlockPacketMixin.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 |
---|---|---|
@@ -1,14 +1,133 @@ | ||
package com.sunekaer.mods.structureexpansion.mixin; | ||
|
||
import com.sunekaer.mods.structureexpansion.StructureExpansion; | ||
import net.minecraft.network.PacketBuffer; | ||
import net.minecraft.network.play.client.CUpdateStructureBlockPacket; | ||
import net.minecraft.state.properties.StructureMode; | ||
import net.minecraft.tileentity.StructureBlockTileEntity; | ||
import net.minecraft.util.Mirror; | ||
import net.minecraft.util.Rotation; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.MathHelper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
import java.io.IOException; | ||
|
||
@Mixin(CUpdateStructureBlockPacket.class) | ||
public abstract class CUpdateStructureBlockPacketMixin { | ||
@ModifyConstant(method = "readPacketData", constant = {@Constant(intValue = 48), @Constant(intValue = -48)}) | ||
private int getMaxSizePos(int value){ | ||
return value > 0 ? 255 : -256; | ||
} | ||
@Shadow | ||
private BlockPos pos; | ||
|
||
@Shadow | ||
private StructureBlockTileEntity.UpdateCommand updateCommand; | ||
|
||
@Shadow | ||
private StructureMode mode; | ||
|
||
@Shadow | ||
private String name; | ||
|
||
@Shadow | ||
private BlockPos position; | ||
|
||
@Shadow | ||
private BlockPos size; | ||
|
||
@Shadow | ||
private Mirror mirror; | ||
|
||
@Shadow | ||
private Rotation rotation; | ||
|
||
@Shadow | ||
private String metaData; | ||
|
||
@Shadow | ||
private boolean ignoreEntities; | ||
|
||
@Shadow | ||
private boolean showAir; | ||
|
||
@Shadow | ||
private boolean showBoundingBox; | ||
|
||
@Shadow | ||
private float integrity; | ||
|
||
@Shadow | ||
private long seed; | ||
|
||
/** | ||
* @author LatvianModder | ||
* @reason to fix 48 block limit | ||
*/ | ||
@Overwrite | ||
public void readPacketData(PacketBuffer buf) throws IOException { | ||
pos = buf.readBlockPos(); | ||
updateCommand = buf.readEnumValue(StructureBlockTileEntity.UpdateCommand.class); | ||
mode = buf.readEnumValue(StructureMode.class); | ||
name = buf.readString(32767); | ||
|
||
position = new BlockPos( | ||
MathHelper.clamp(buf.readVarInt(), StructureExpansion.NEW_LIMIT_NEG, StructureExpansion.NEW_LIMIT_POS), | ||
MathHelper.clamp(buf.readVarInt(), StructureExpansion.NEW_LIMIT_NEG, StructureExpansion.NEW_LIMIT_POS), | ||
MathHelper.clamp(buf.readVarInt(), StructureExpansion.NEW_LIMIT_NEG, StructureExpansion.NEW_LIMIT_POS) | ||
); | ||
|
||
size = new BlockPos( | ||
MathHelper.clamp(buf.readVarInt(), 0, StructureExpansion.NEW_LIMIT_POS), | ||
MathHelper.clamp(buf.readVarInt(), 0, StructureExpansion.NEW_LIMIT_POS), | ||
MathHelper.clamp(buf.readVarInt(), 0, StructureExpansion.NEW_LIMIT_POS) | ||
); | ||
|
||
mirror = buf.readEnumValue(Mirror.class); | ||
rotation = buf.readEnumValue(Rotation.class); | ||
metaData = buf.readString(12); | ||
integrity = MathHelper.clamp(buf.readFloat(), 0.0F, 1.0F); | ||
seed = buf.readVarLong(); | ||
int k = buf.readVarInt(); | ||
ignoreEntities = (k & 1) != 0; | ||
showAir = (k & 2) != 0; | ||
showBoundingBox = (k & 4) != 0; | ||
} | ||
|
||
/** | ||
* @author LatvianModder | ||
* @reason to fix 48 block limit | ||
*/ | ||
@Overwrite | ||
public void writePacketData(PacketBuffer buf) { | ||
buf.writeBlockPos(pos); | ||
buf.writeEnumValue(updateCommand); | ||
buf.writeEnumValue(mode); | ||
buf.writeString(name); | ||
buf.writeVarInt(position.getX()); | ||
buf.writeVarInt(position.getY()); | ||
buf.writeVarInt(position.getZ()); | ||
buf.writeVarInt(size.getX()); | ||
buf.writeVarInt(size.getY()); | ||
buf.writeVarInt(size.getZ()); | ||
buf.writeEnumValue(mirror); | ||
buf.writeEnumValue(rotation); | ||
buf.writeString(metaData); | ||
buf.writeFloat(integrity); | ||
buf.writeVarLong(seed); | ||
|
||
int i = 0; | ||
if (ignoreEntities) { | ||
i |= 1; | ||
} | ||
|
||
if (showAir) { | ||
i |= 2; | ||
} | ||
|
||
if (showBoundingBox) { | ||
i |= 4; | ||
} | ||
|
||
buf.writeVarInt(i); | ||
} | ||
} |
9 changes: 5 additions & 4 deletions
9
src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockTileEntityMixin.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 |
---|---|---|
@@ -1,14 +1,15 @@ | ||
package com.sunekaer.mods.structureexpansion.mixin; | ||
|
||
import com.sunekaer.mods.structureexpansion.StructureExpansion; | ||
import net.minecraft.tileentity.StructureBlockTileEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
|
||
@Mixin(StructureBlockTileEntity.class) | ||
public abstract class StructureBlockTileEntityMixin { | ||
@ModifyConstant(method = "read", constant = {@Constant(intValue = 48), @Constant(intValue = -48)}) | ||
private int getMaxSizePos(int value){ | ||
return value > 0 ? 255 : -256; | ||
} | ||
@ModifyConstant(method = "read", constant = {@Constant(intValue = 48), @Constant(intValue = -48)}) | ||
private int getMaxSizePos(int value) { | ||
return value > 0 ? StructureExpansion.NEW_LIMIT_POS : StructureExpansion.NEW_LIMIT_NEG; | ||
} | ||
} |
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