mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
made dimension rails work again, yay
This commit is contained in:
parent
615fbe3f88
commit
e5db5d9fe6
3 changed files with 15 additions and 23 deletions
|
@ -92,7 +92,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft 'net.minecraftforge:forge:1.15.2-31.0.1'
|
minecraft 'net.minecraftforge:forge:1.15.2-31.0.4'
|
||||||
|
|
||||||
compileOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.2:api")
|
compileOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.2:api")
|
||||||
runtimeOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.2")
|
runtimeOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.2")
|
||||||
|
|
|
@ -13,7 +13,7 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -30,18 +30,14 @@ import net.minecraft.util.SoundEvents;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
|
||||||
import net.minecraft.util.text.Style;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import net.minecraft.world.gen.Heightmap;
|
import net.minecraft.world.gen.Heightmap;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
|
import net.minecraftforge.common.util.ITeleporter;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import java.util.function.Function;
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class BlockDimensionRail extends AbstractRailBlock implements IModItem, ICustomRenderType, ICustomBlockState, ICustomItemModel {
|
public class BlockDimensionRail extends AbstractRailBlock implements IModItem, ICustomRenderType, ICustomBlockState, ICustomItemModel {
|
||||||
|
@ -95,24 +91,19 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I
|
||||||
world.playSound(null, pos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 1F, 1F);
|
world.playSound(null, pos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 1F, 1F);
|
||||||
|
|
||||||
BlockPos goalCoords = this.getGoalCoords(world, pos);
|
BlockPos goalCoords = this.getGoalCoords(world, pos);
|
||||||
|
cart.changeDimension(DimensionType.getById(this.goalDim), new ITeleporter() {
|
||||||
// TODO wait for Forge to have re-implemented ITeleporter
|
@Override
|
||||||
if (true)
|
public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw, Function<Boolean, Entity> repositionEntity) {
|
||||||
return;
|
Entity result = repositionEntity.apply(false);
|
||||||
|
result.moveToBlockPosAndAngles(goalCoords, yaw, result.rotationPitch);
|
||||||
cart.changeDimension(DimensionType.getById(this.goalDim));
|
return result;
|
||||||
cart.moveToBlockPosAndAngles(goalCoords, cart.rotationYaw, cart.rotationPitch);
|
}
|
||||||
|
});
|
||||||
|
|
||||||
BlockPos spot = IAuraChunk.getHighestSpot(world, pos, 35, pos);
|
BlockPos spot = IAuraChunk.getHighestSpot(world, pos, 35, pos);
|
||||||
IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 50000);
|
IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 50000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
|
|
||||||
super.addInformation(stack, worldIn, tooltip, flagIn);
|
|
||||||
tooltip.add(new StringTextComponent("CURRENTLY UNIMPLEMENTED - Waiting for a Forge change").setStyle(new Style().setColor(TextFormatting.RED)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private BlockPos getGoalCoords(World world, BlockPos pos) {
|
private BlockPos getGoalCoords(World world, BlockPos pos) {
|
||||||
MinecraftServer server = world.getServer();
|
MinecraftServer server = world.getServer();
|
||||||
DimensionType goalDimType = DimensionType.getById(this.goalDim);
|
DimensionType goalDimType = DimensionType.getById(this.goalDim);
|
||||||
|
|
|
@ -24,6 +24,7 @@ import net.minecraft.world.GameRules;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import net.minecraftforge.common.util.Constants;
|
import net.minecraftforge.common.util.Constants;
|
||||||
|
import net.minecraftforge.common.util.ITeleporter;
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -134,8 +135,8 @@ public class EntityMoverMinecart extends AbstractMinecartEntity {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Entity changeDimension(DimensionType destination) {
|
public Entity changeDimension(DimensionType destination, ITeleporter teleporter) {
|
||||||
Entity entity = super.changeDimension(destination);
|
Entity entity = super.changeDimension(destination, teleporter);
|
||||||
if (entity instanceof EntityMoverMinecart) {
|
if (entity instanceof EntityMoverMinecart) {
|
||||||
BlockPos pos = entity.getPosition();
|
BlockPos pos = entity.getPosition();
|
||||||
this.moveAura(this.world, this.lastPosition, entity.world, pos);
|
this.moveAura(this.world, this.lastPosition, entity.world, pos);
|
||||||
|
|
Loading…
Reference in a new issue