-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start of a fix for BW's biome-related rituals #153
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6824e12
Implemented a fix for BW, part 1
Sunconure11 dc93f9e
Revert "Implemented a fix for BW, part 1"
Sunconure11 c126a4f
Begin on fixing up this mod to work with BW
Sunconure11 a6de07a
Start of a fix for BW
Sunconure11 6fb8d13
Update build.gradle
Sunconure11 26eebfa
Partial functionality.
Sunconure11 c85d676
Revert "Partial functionality."
Sunconure11 b52e428
Update MixinUtils.java
Sunconure11 23ea710
Update MixinUtils.java
Sunconure11 9ae4da5
Update MixinUtils.java
Sunconure11 5ab3233
Removed an unneeded line
Sunconure11 26caba1
The extra utils method works better, but I still need to relog to see…
Sunconure11 c7b222c
Using old code from BW solved this. Time to test it on servers.
Sunconure11 df365ac
No more death packets for an intensive rite.
Sunconure11 a9c8941
Update BW
Sunconure11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
47 changes: 47 additions & 0 deletions
47
src/main/java/org/dimdev/jeid/mixin/modsupport/bewitchment/MixinRitualBiomeShift.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,47 @@ | ||
package org.dimdev.jeid.mixin.modsupport.bewitchment; | ||
|
||
import com.bewitchment.common.item.tool.ItemBoline; | ||
import com.bewitchment.common.ritual.RitualBiomeShift; | ||
import com.bewitchment.common.world.BiomeChangingUtils; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.network.play.server.SPacketChunkData; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.biome.Biome; | ||
import net.minecraft.world.chunk.Chunk; | ||
import net.minecraftforge.items.ItemStackHandler; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Pseudo; | ||
|
||
@Pseudo | ||
@Mixin(RitualBiomeShift.class) | ||
public class MixinRitualBiomeShift { | ||
@Overwrite(remap = false) | ||
public void onFinished(World world, BlockPos altarPos, BlockPos effectivePos, EntityPlayer caster, ItemStackHandler inventory) { | ||
int id; | ||
Chunk chunk = world.getChunk(effectivePos); | ||
for (int i = 0; i < inventory.getSlots(); i++) { | ||
ItemStack stack = inventory.getStackInSlot(i); | ||
if (stack.getItem() instanceof ItemBoline) { | ||
id = stack.getTagCompound().getInteger("biome_id"); | ||
|
||
//might run thru that only server side, since all client change is done with packets afterwards | ||
int radius = 32; //maybe change that depending on some other stuff? | ||
for (double x = -radius; x < radius; x++) { | ||
for (double z = -radius; z < radius; z++) { | ||
if (Math.sqrt((x * x) + (z * z)) < radius) { | ||
BlockPos pos = effectivePos.add(x, 0, z); | ||
BiomeChangingUtils.setBiome(world, Biome.getBiomeForId(id), pos); | ||
chunk.getWorld().getMinecraftServer().getPlayerList().getPlayers().forEach(p -> p.connection.sendPacket(new SPacketChunkData(chunk, 65535))); | ||
for (i = 0; i < inventory.getSlots(); i++) { | ||
inventory.extractItem(i, 1, false); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/org/dimdev/jeid/mixin/modsupport/bewitchment/MixinUtils.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,32 @@ | ||
package org.dimdev.jeid.mixin.modsupport.bewitchment; | ||
|
||
import com.bewitchment.common.world.BiomeChangingUtils; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.biome.Biome; | ||
import net.minecraft.world.chunk.Chunk; | ||
import net.minecraftforge.fml.common.network.NetworkRegistry; | ||
import org.dimdev.jeid.INewChunk; | ||
import org.dimdev.jeid.network.BiomeChangeMessage; | ||
import org.dimdev.jeid.network.MessageManager; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Pseudo; | ||
|
||
@Pseudo | ||
@Mixin(BiomeChangingUtils.class) | ||
public class MixinUtils { | ||
@Overwrite | ||
public static void setBiome(World world, Biome biome, BlockPos pos) { | ||
Chunk chunk = world.getChunk(pos); | ||
((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF] = Biome.getIdForBiome(biome); | ||
chunk.markDirty(); | ||
|
||
if (!world.isRemote) { | ||
MessageManager.CHANNEL.sendToAllAround( | ||
new BiomeChangeMessage(pos.getX(), pos.getZ(), Biome.getIdForBiome(biome)), | ||
new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), 128.0D, pos.getZ(), 128.0D) | ||
); | ||
} | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure you want to overwrite here? There's definitely a better way.
you could inject at
INVOKE
, shift toShift.AFTER
and set the target to the descriptorsetBiome
, and just addThis will inject right after
setBiome
, which is the only place required to inject.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any examples of injection in the code of this mod itself? Fairly new to toying with mixins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
until now I've only seen overwrites(which is probably not a good sign) in jeid.
I do have a cheat sheet about mixins, which you can refer to.
https://github.com/BoogieMonster1O1/mixincs-updated/blob/master/README.md
You'd want to look at
@At
.