Skip to content

Commit d7d448b

Browse files
committed
Pushing changes for cubic chunks version. Disabled eternal fluid due to crash with CC.
1 parent 30c7a5c commit d7d448b

File tree

4 files changed

+50
-153
lines changed

4 files changed

+50
-153
lines changed

build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ apply plugin: 'net.minecraftforge.gradle.forge'
1919

2020
repositories {
2121
maven { url = "https://jitpack.io" }
22+
mavenCentral()
2223
maven { url = 'http://oss.sonatype.org/content/repositories/public/' }
24+
maven {
25+
name = 'sponge-repo'
26+
url = 'https://repo.spongepowered.org/maven'
27+
}
2328
}
2429

2530
configurations {
@@ -32,7 +37,7 @@ dependencies {
3237
embed 'org.jgrapht:jgrapht-core:1.1.0'
3338
embed 'com.github.DimensionalDevelopment:poly2tri.java:master-SNAPSHOT'
3439
compileOnly 'com.github.DimensionalDevelopment:AnnotatedNBT:-SNAPSHOT'
35-
compileOnly 'io.github.opencubicchunks:cubicchunks:1.12.2-0.0.819.0-SNAPSHOT'
40+
compileOnly 'io.github.opencubicchunks:cubicchunks:1.12.2-0.0-SNAPSHOT'
3641
}
3742

3843
// Minecraft, MCP, Forge, and Java versions

src/main/java/org/dimdev/ddutils/TeleportUtils.java

Lines changed: 11 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
import net.minecraft.util.math.BlockPos;
1616
import net.minecraft.util.math.MathHelper;
1717
import net.minecraft.util.math.Vec3d;
18+
import net.minecraft.world.World;
1819
import net.minecraft.world.WorldProviderEnd;
1920
import net.minecraft.world.WorldServer;
2021
import net.minecraft.world.end.DragonFightManager;
2122
import net.minecraftforge.common.ForgeHooks;
2223
import net.minecraftforge.common.util.FakePlayer;
24+
import net.minecraftforge.common.util.ITeleporter;
2325
import net.minecraftforge.fml.common.FMLCommonHandler;
2426

2527
import java.lang.reflect.Field;
@@ -134,9 +136,8 @@ public static Entity teleport(Entity entity, int newDimension, double x, double
134136
if (entity instanceof FakePlayer) return entity;
135137
if (entity.world.isRemote || entity.isDead) return null; // dead means inactive, not a dead player
136138

137-
yaw = MathHelper.wrapDegrees(yaw);
138-
pitch = MathHelper.wrapDegrees(pitch);
139-
139+
float adjustedYaw = MathHelper.wrapDegrees(yaw);
140+
float adjustedPitch = MathHelper.wrapDegrees(pitch);
140141
entity.dismountRidingEntity(); // TODO: would be nice to teleport them too
141142
entity.removePassengers();
142143

@@ -147,139 +148,25 @@ public static Entity teleport(Entity entity, int newDimension, double x, double
147148
// Workaround for https://bugs.mojang.com/browse/MC-123364. Disables player-in-block checking, but doesn't seem
148149
// to make the player actually noclip.
149150
entity.noClip = true;
150-
151-
// Prevent Minecraft from cancelling the position change being too big if the player is not in creative
152-
// This has to be done when the teleport is done from the player moved function (so any block collision event too)
153-
// Not doing this will cause the player to be invisible for others.
154151
setInvulnerableDimensionChange((EntityPlayerMP) entity, true);
155152
}
156153

157154
if (oldDimension == newDimension) { // Based on CommandTeleport.doTeleport
158155
if (entity instanceof EntityPlayerMP) {
159156
EntityPlayerMP player = (EntityPlayerMP) entity;
160-
player.connection.setPlayerLocation(x, y, z, yaw, pitch, EnumSet.noneOf(SPacketPlayerPosLook.EnumFlags.class));
157+
player.connection.setPlayerLocation(x, y, z, adjustedYaw, adjustedPitch, EnumSet.noneOf(SPacketPlayerPosLook.EnumFlags.class));
161158
// Fix for https://bugs.mojang.com/browse/MC-98153. See this comment: https://bugs.mojang.com/browse/MC-98153#comment-411524
162159
captureCurrentPosition(player.connection);
163160
} else {
164-
entity.setLocationAndAngles(x, y, z, yaw, pitch);
161+
entity.setLocationAndAngles(x, y, z, adjustedYaw, adjustedPitch);
165162
}
166-
entity.setRotationYawHead(yaw);
167-
168-
return entity;
169-
} else { // Based on Entity.changeDimension
170-
MinecraftServer server = entity.getServer();
171-
WorldServer oldWorld = server.getWorld(oldDimension);
172-
WorldServer newWorld = server.getWorld(newDimension);
173-
174-
// Allow other mods to cancel the event
175-
if (!ForgeHooks.onTravelToDimension(entity, newDimension)) return entity;
176-
177-
if (entity instanceof EntityPlayerMP) {
178-
EntityPlayerMP player = (EntityPlayerMP) entity;
179-
180-
// Setting this field seems to be useful for advancments. Adjusted dimension checks for non-vanilla
181-
// dimension support (entering the nether from any dimension should trigger it now).
182-
if (newDimension == -1) {
183-
setEnteredNetherPosition(player, new Vec3d(player.posX, player.posY, player.posZ));
184-
} else if (oldDimension != -1 && newDimension != 0) {
185-
setEnteredNetherPosition(player, null);
186-
}
187-
188-
// Send respawn packets to the player
189-
player.dimension = newDimension;
190-
player.connection.sendPacket(new SPacketRespawn(player.dimension, newWorld.getDifficulty(), newWorld.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
191-
player.server.getPlayerList().updatePermissionLevel(player); // Sends an SPacketEntityStatus
192-
193-
// Remove player entity from the old world
194-
oldWorld.removeEntityDangerously(player);
195-
196-
// Move the player entity to new world
197-
// We can't use PlayerList.transferEntityToWorld since for newDimension = 1, that would first teleport the
198-
// player to the dimension's spawn before quickly teleporting the player to the correct position. Unlike the vanilla
199-
// code, we don't use the world provider's moveFactor (ex. 8 blocks in the nether) and don't clip to the
200-
// world border.
201-
player.isDead = false;
202-
oldWorld.profiler.startSection("moving");
203-
player.setLocationAndAngles(x, y, z, yaw, pitch);
204-
// PlayerList.transferEntityToWorld does this for some reason when teleporting to the end, but it doesn't
205-
// make any sense (without it, there seems to be some flickering between two positions):
206-
if (entity.isEntityAlive()) oldWorld.updateEntityWithOptionalForce(entity, false);
207-
oldWorld.profiler.endSection();
208-
209-
oldWorld.profiler.startSection("placing");
210-
newWorld.spawnEntity(player);
211-
newWorld.updateEntityWithOptionalForce(player, false);
212-
oldWorld.profiler.endSection();
213-
player.setWorld(newWorld);
214-
215-
// Sync the player
216-
player.server.getPlayerList().preparePlayer(player, oldWorld);
217-
player.connection.setPlayerLocation(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
218-
// Fix for https://bugs.mojang.com/browse/MC-98153. See this comment: https://bugs.mojang.com/browse/MC-98153#comment-411524
219-
captureCurrentPosition(player.connection);
220-
player.interactionManager.setWorld(newWorld);
221-
player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities));
222-
player.server.getPlayerList().updateTimeAndWeatherForPlayer(player, newWorld);
223-
player.server.getPlayerList().syncPlayerInventory(player);
224-
for (PotionEffect potioneffect : player.getActivePotionEffects()) {
225-
player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect));
226-
}
227163

228-
// Force WorldProviderEnd to check if end dragon bars should be removed. Duplicate end dragon bars even
229-
// happen when leaving the end using an end portal while the dragon is alive, so this might be a vanilla
230-
// or Forge bug (maybe the world is unloaded before checking players?). In vanilla, updateplayers is normally
231-
// called every second.
232-
if (oldWorld.provider instanceof WorldProviderEnd) {
233-
DragonFightManager dragonFightManager = ((WorldProviderEnd) oldWorld.provider).getDragonFightManager();
234-
updateplayers(dragonFightManager);
235-
}
164+
entity.setRotationYawHead(adjustedYaw);
236165

237-
// Vanilla also plays SoundEvents.BLOCK_PORTAL_TRAVEL, we won't do this.
238-
239-
FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, oldDimension, newDimension);
240-
241-
//player.prevBlockpos = null; // For frost walk. Is this needed? What about other fields?
242-
/*player.lastExperience = -1;
243-
player.lastHealth = -1.0F;
244-
player.lastFoodLevel = -1;*/
245-
246-
return entity;
247-
} else {
248-
if (entity instanceof EntityMinecartContainer) ((EntityMinecartContainer) entity).dropContentsWhenDead = false;
249-
if (entity instanceof EntityEnderPearl) setThrower((EntityThrowable) entity, null); // Otherwise the player will be teleported to the hit position but in the same dimension
250-
251-
entity.world.profiler.startSection("changeDimension");
252-
entity.dimension = newDimension;
253-
entity.world.removeEntity(entity);
254-
entity.isDead = false;
255-
256-
entity.world.profiler.startSection("reposition");
257-
oldWorld.updateEntityWithOptionalForce(entity, false);
258-
259-
entity.world.profiler.endStartSection("reloading");
260-
Entity newEntity = EntityList.newEntity(entity.getClass(), newWorld);
261-
262-
if (newEntity != null) {
263-
copyDataFromOld(newEntity, entity);
264-
newEntity.setPositionAndRotation(x, y, z, yaw, pitch);
265-
boolean oldForceSpawn = newEntity.forceSpawn;
266-
newEntity.forceSpawn = true;
267-
newWorld.spawnEntity(newEntity);
268-
newEntity.forceSpawn = oldForceSpawn;
269-
newWorld.updateEntityWithOptionalForce(newEntity, false);
270-
}
271-
272-
entity.isDead = true;
273-
entity.world.profiler.endSection();
274-
275-
oldWorld.resetUpdateEntityTick();
276-
newWorld.resetUpdateEntityTick();
277-
entity.world.profiler.endSection();
278-
279-
if (newEntity instanceof EntityItem) searchForOtherItemsNearby((EntityItem) newEntity); // TODO: This isn't in same-dimension teleportation in vanilla, but why?
280-
281-
return newEntity;
282-
}
166+
return entity;
167+
} else {
168+
entity.changeDimension(newDimension, (w, e, newYaw) -> e.moveToBlockPosAndAngles(new BlockPos(x, y, z), adjustedYaw, adjustedPitch));
169+
return entity;
283170
}
284171
}
285172
}

src/main/java/org/dimdev/ddutils/schem/Schematic.java

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package org.dimdev.ddutils.schem;
22

3-
import cubicchunks.world.ICubicWorld;
4-
import cubicchunks.world.cube.Cube;
3+
import io.github.opencubicchunks.cubicchunks.api.world.ICube;
4+
import io.github.opencubicchunks.cubicchunks.api.world.ICubicWorld;
5+
import io.github.opencubicchunks.cubicchunks.core.world.cube.Cube;
56
import net.minecraft.block.Block;
67
import net.minecraft.block.properties.IProperty;
78
import net.minecraft.block.state.BlockStateContainer;
@@ -401,34 +402,38 @@ private void setBlocks(World world, int xBase, int yBase, int zBase) {
401402
for (int cubeZ = 0; cubeZ <= (length >> 4) + 1; cubeZ++) {
402403
long setStart = System.nanoTime();
403404
// Get the cube only once for efficiency
404-
Cube cube = cubicWorld.getCubeFromCubeCoords((xBase >> 4) + cubeX, (yBase >> 4) + cubeY, (zBase >> 4) + cubeZ);
405-
ExtendedBlockStorage storage = cube.getStorage();
406-
boolean setAir = storage != null;
407-
for (int x = 0; x < 16; x++) {
408-
for (int y = 0; y < 16; y++) {
409-
for (int z = 0; z < 16; z++) {
410-
int sx = (cubeX << 4) + x - (xBase & 0x0F);
411-
int sy = (cubeY << 4) + y - (yBase & 0x0F);
412-
int sz = (cubeZ << 4) + z - (zBase & 0x0F);
413-
if (sx >= 0 && sy >= 0 && sz >= 0 && sx < width && sy < height && sz < length) {
414-
IBlockState state = palette.get(blockData[sx][sy][sz]);
415-
if (!state.getBlock().equals(Blocks.AIR)) {
416-
if (storage == null) {
417-
cube.setStorage(storage = new ExtendedBlockStorage(cube.getY() << 4, world.provider.hasSkyLight()));
405+
ICube c = cubicWorld.getCubeFromCubeCoords((xBase >> 4) + cubeX, (yBase >> 4) + cubeY, (zBase >> 4) + cubeZ);
406+
407+
if (c instanceof Cube) {
408+
Cube cube = (Cube) c;
409+
ExtendedBlockStorage storage = cube.getStorage();
410+
boolean setAir = storage != null;
411+
for (int x = 0; x < 16; x++) {
412+
for (int y = 0; y < 16; y++) {
413+
for (int z = 0; z < 16; z++) {
414+
int sx = (cubeX << 4) + x - (xBase & 0x0F);
415+
int sy = (cubeY << 4) + y - (yBase & 0x0F);
416+
int sz = (cubeZ << 4) + z - (zBase & 0x0F);
417+
if (sx >= 0 && sy >= 0 && sz >= 0 && sx < width && sy < height && sz < length) {
418+
IBlockState state = palette.get(blockData[sx][sy][sz]);
419+
if (!state.getBlock().equals(Blocks.AIR)) {
420+
if (storage == null) {
421+
cube.setStorage(storage = new ExtendedBlockStorage((yBase >> 4) + cube.getY() << 4, world.provider.hasSkyLight()));
422+
}
423+
storage.set(x, y, z, state);
424+
} else if (setAir) {
425+
storage.set(x, y, z, state);
418426
}
419-
storage.set(x, y, z, state);
420-
} else if (setAir) {
421-
storage.set(x, y, z, state);
422427
}
423428
}
424429
}
425430
}
431+
setTime += System.nanoTime() - setStart;
432+
long relightStart = System.nanoTime();
433+
cube.setInitialLightingDone(false);
434+
relightTime += System.nanoTime() - relightStart;
435+
cube.markDirty();
426436
}
427-
setTime += System.nanoTime() - setStart;
428-
long relightStart = System.nanoTime();
429-
cube.setInitialLightingDone(false);
430-
relightTime += System.nanoTime() - relightStart;
431-
cube.markDirty();
432437
}
433438
}
434439
}
@@ -454,8 +459,7 @@ private void setBlocks(World world, int xBase, int yBase, int zBase) {
454459
IBlockState state = palette.get(blockData[sx][sy][sz]);
455460
if (!state.getBlock().equals(Blocks.AIR)) {
456461
if (storage == null) {
457-
storage = new ExtendedBlockStorage((yBase >> 4) + storageY << 4, world.provider.hasSkyLight());
458-
storageArray[(yBase >> 4) + storageY] = storage;
462+
storageArray[(yBase >> 4) + storageY] = storage = new ExtendedBlockStorage((yBase >> 4) + storageY << 4, world.provider.hasSkyLight());
459463
}
460464
storage.set(x, y, z, state);
461465
} else if (setAir) {

src/main/java/org/dimdev/dimdoors/shared/blocks/BlockFabricEternal.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ public BlockFabricEternal() {
3232
setSoundType(SoundType.STONE);
3333
}
3434

35-
@Override
35+
//This is meant to be a fix for a cubic chunks version. Currently crashes for some reason and don't want to try and fix right now.
36+
/*@Override
3637
public void onEntityWalk(World world, BlockPos pos, Entity entity) {
3738
if (world.isRemote) return;
3839
exitLimbo.receiveEntity(entity, entity.rotationYaw / 90 * 90, 0);
39-
}
40+
}*/
4041
}

0 commit comments

Comments
 (0)