mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Fix respawning on cloud blocks
This commit is contained in:
parent
dcaaca149b
commit
68025e4642
8 changed files with 28 additions and 6 deletions
|
@ -31,7 +31,7 @@ public interface EquineContext {
|
|||
|
||||
static EquineContext of(ShapeContext context) {
|
||||
if (context == ShapeContext.absent()) {
|
||||
return InteractionManager.getInstance().getClientPony().map(EquineContext.class::cast).orElse(ABSENT);
|
||||
return InteractionManager.getInstance().getEquineContext();
|
||||
}
|
||||
EquineContext result = context instanceof Container c ? c.get() : ABSENT;
|
||||
return result == null ? ABSENT : result;
|
||||
|
|
|
@ -37,6 +37,8 @@ public class InteractionManager {
|
|||
@Nullable
|
||||
private SyncedConfig config;
|
||||
|
||||
private EquineContext equineContext = EquineContext.ABSENT;
|
||||
|
||||
public static InteractionManager getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
@ -106,6 +108,14 @@ public class InteractionManager {
|
|||
|
||||
}
|
||||
|
||||
public void setEquineContext(EquineContext context) {
|
||||
equineContext = context;
|
||||
}
|
||||
|
||||
public EquineContext getEquineContext() {
|
||||
return getClientPony().map(EquineContext.class::cast).orElse(equineContext);
|
||||
}
|
||||
|
||||
public Optional<Pony> getClientPony() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class CloudBedBlock extends FancyBedBlock implements CloudLike {
|
|||
private final CloudBlock baseBlock;
|
||||
|
||||
public CloudBedBlock(String base, BlockState baseState, Settings settings) {
|
||||
super(base, settings);
|
||||
super(base, settings.dynamicBounds());
|
||||
this.baseState = baseState;
|
||||
this.baseBlock = (CloudBlock)baseState.getBlock();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class CloudBlock extends Block implements CloudLike {
|
|||
protected final boolean meltable;
|
||||
|
||||
public CloudBlock(Settings settings, boolean meltable) {
|
||||
super((meltable ? settings.ticksRandomly() : settings).nonOpaque());
|
||||
super((meltable ? settings.ticksRandomly() : settings).nonOpaque().dynamicBounds());
|
||||
this.meltable = meltable;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class CloudChestBlock extends ChestBlock implements CloudLike {
|
|||
};
|
||||
|
||||
public CloudChestBlock(Settings settings, BlockState baseState) {
|
||||
super(settings, () -> UBlockEntities.CLOUD_CHEST);
|
||||
super(settings.dynamicBounds(), () -> UBlockEntities.CLOUD_CHEST);
|
||||
this.baseState = baseState;
|
||||
this.baseBlock = (CloudBlock)baseState.getBlock();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class CloudDoorBlock extends DoorBlock implements CloudLike {
|
|||
private final CloudBlock baseBlock;
|
||||
|
||||
public CloudDoorBlock(Settings settings, BlockState baseState, BlockSetType blockSet) {
|
||||
super(settings, blockSet);
|
||||
super(settings.dynamicBounds(), blockSet);
|
||||
this.baseState = baseState;
|
||||
this.baseBlock = (CloudBlock)baseState.getBlock();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class CloudStairsBlock extends StairsBlock implements CloudLike {
|
|||
private final CloudBlock baseBlock;
|
||||
|
||||
public CloudStairsBlock(BlockState baseState, Settings settings) {
|
||||
super(baseState, settings);
|
||||
super(baseState, settings.dynamicBounds());
|
||||
this.baseBlock = (CloudBlock)baseState.getBlock();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,10 @@ 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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.minelittlepony.unicopia.EquineContext;
|
||||
import com.minelittlepony.unicopia.InteractionManager;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -34,4 +37,13 @@ abstract class MixinPlayerManager {
|
|||
}
|
||||
}
|
||||
|
||||
@Inject(method = "respawnPlayer", at = @At("HEAD"))
|
||||
private void beforeRespawnPlayer(ServerPlayerEntity player, boolean alive, CallbackInfoReturnable<ServerPlayerEntity> info) {
|
||||
InteractionManager.getInstance().setEquineContext(EquineContext.of(player));
|
||||
}
|
||||
|
||||
@Inject(method = "respawnPlayer", at = @At("RETURN"))
|
||||
private void afterRespawnPlayer(ServerPlayerEntity player, boolean alive, CallbackInfoReturnable<ServerPlayerEntity> info) {
|
||||
InteractionManager.getInstance().setEquineContext(EquineContext.ABSENT);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue