Fix Bug
This commit is contained in:
parent
99f085f3bc
commit
9fd946ae9a
@ -1,4 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
**1.0.1**
|
||||
* Fix Bug
|
||||
|
||||
**1.0**
|
||||
* Initial Release
|
@ -1,5 +1,6 @@
|
||||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/use
|
||||
minecraft_version = 20w11a
|
||||
@ -7,7 +8,8 @@ curseforge_id=367307
|
||||
simple_minecraft_version = 1.16-Snapshot
|
||||
yarn_mappings = 20w11a+build.6
|
||||
loader_version = 0.7.8+build.184
|
||||
|
||||
# Mod Properties
|
||||
mod_version=1.0.0
|
||||
mod_version = 1.0.1
|
||||
maven_group = com.thebrokenrail
|
||||
archives_base_name = obsidianspawn
|
||||
|
@ -2,7 +2,7 @@ package com.thebrokenrail.obsidianspawn;
|
||||
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
public interface DataHolder {
|
||||
public interface SpawnDataHolder {
|
||||
void setSpawnDimension(DimensionType dimension);
|
||||
|
||||
DimensionType getSpawnDimension();
|
@ -1,8 +1,10 @@
|
||||
package com.thebrokenrail.obsidianspawn.mixin;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.CryingObsidianBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
@ -10,12 +12,17 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@SuppressWarnings({"unused", "deprecation"})
|
||||
@Mixin(CryingObsidianBlock.class)
|
||||
public class MixinCryingObsidianBlock {
|
||||
public abstract class MixinCryingObsidianBlock extends Block {
|
||||
public MixinCryingObsidianBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
if (!world.isClient()) {
|
||||
player.setPlayerSpawn(pos, false, true);
|
||||
player.setPlayerSpawn(pos, false, false);
|
||||
player.sendMessage(new TranslatableText("block.minecraft.bed.set_spawn"));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.thebrokenrail.obsidianspawn.mixin;
|
||||
|
||||
import com.thebrokenrail.obsidianspawn.DataHolder;
|
||||
import com.thebrokenrail.obsidianspawn.ObsidianSpawn;
|
||||
import com.thebrokenrail.obsidianspawn.SpawnDataHolder;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.CryingObsidianBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@ -20,7 +20,7 @@ import java.util.Optional;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(PlayerEntity.class)
|
||||
public class MixinPlayerEntity implements DataHolder {
|
||||
public class MixinPlayerEntity implements SpawnDataHolder {
|
||||
private DimensionType spawnDimension = DimensionType.OVERWORLD;
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "readCustomDataFromTag")
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.thebrokenrail.obsidianspawn.mixin;
|
||||
|
||||
import com.thebrokenrail.obsidianspawn.DataHolder;
|
||||
import com.thebrokenrail.obsidianspawn.ObsidianSpawn;
|
||||
import com.thebrokenrail.obsidianspawn.SpawnDataHolder;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.CryingObsidianBlock;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
@ -18,7 +18,7 @@ public class MixinServerPlayNetworkHandler {
|
||||
@ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;respawnPlayer(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/world/dimension/DimensionType;Z)Lnet/minecraft/server/network/ServerPlayerEntity;"), method = "onClientStatus", index = 1)
|
||||
public DimensionType adjustRespawnDimension(ServerPlayerEntity player, DimensionType dimension, boolean alive) {
|
||||
if (player.getSpawnPosition() != null) {
|
||||
DimensionType type = ((DataHolder) player).getSpawnDimension();
|
||||
DimensionType type = ((SpawnDataHolder) player).getSpawnDimension();
|
||||
WorldView world = player.server.getWorld(type);
|
||||
Block block = world.getBlockState(player.getSpawnPosition()).getBlock();
|
||||
if (!(block instanceof CryingObsidianBlock)) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.thebrokenrail.obsidianspawn.mixin;
|
||||
|
||||
import com.thebrokenrail.obsidianspawn.DataHolder;
|
||||
import com.thebrokenrail.obsidianspawn.SpawnDataHolder;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -9,11 +9,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(ServerPlayerEntity.class)
|
||||
public abstract class MixinServerPlayerEntity implements DataHolder {
|
||||
public abstract class MixinServerPlayerEntity implements SpawnDataHolder {
|
||||
@Inject(at = @At("HEAD"), method = "copyFrom")
|
||||
public void copyFrom(ServerPlayerEntity oldPlayer, boolean alive, CallbackInfo info) {
|
||||
DataHolder oldData = (DataHolder) oldPlayer;
|
||||
DataHolder newData = this;
|
||||
SpawnDataHolder oldData = (SpawnDataHolder) oldPlayer;
|
||||
SpawnDataHolder newData = this;
|
||||
|
||||
newData.setSpawnDimension(oldData.getSpawnDimension());
|
||||
}
|
||||
|
Reference in New Issue
Block a user