Skip to content

Commit

Permalink
Finishing touches.
Browse files Browse the repository at this point in the history
  • Loading branch information
darkevilmac committed Apr 15, 2016
1 parent 9d806f5 commit 0dc2ce5
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ group = "darkevilmac.movingworld"
archivesBaseName = "movingworld"

minecraft {
version = "1.9-12.16.0.1859-1.9"
version = "1.9-12.16.0.1863-1.9"
runDir = "run"
mappings = "snapshot_20160401"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package darkevilmac.movingworld.common.asm.mixin.core.entity;

import darkevilmac.movingworld.common.entity.IMixinEntity;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -20,7 +20,7 @@ public abstract class MixinEntity implements IMixinEntity {
protected abstract void resetPositionToBB();

@Shadow
protected abstract void updateFallState(double y, boolean onGroundIn, Block blockIn, BlockPos pos);
protected abstract void updateFallState(double y, boolean onGroundIn, IBlockState state, BlockPos pos);

@Shadow
protected abstract boolean canTriggerWalking();
Expand All @@ -36,8 +36,8 @@ public void resetPosToBB() {
}

@Override
public void updateFall(double y, boolean onGroundIn, Block blockIn, BlockPos pos) {
updateFallState(y, onGroundIn, blockIn, pos);
public void updateFall(double y, boolean onGroundIn, IBlockState state, BlockPos pos) {
updateFallState(y, onGroundIn, state, pos);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public static boolean onEntityMove(Entity entity, MobileChunk mobileChunk, doubl
}
}

mixinEntity.updateFall(y, entity.onGround, block, blockPos);
mixinEntity.updateFall(y, entity.onGround, blockState, blockPos);

if (d6 != x) {
entity.motionX = 0.0D;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/darkevilmac/movingworld/common/chunk/ChunkIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public static int writeAll(DataOutput out, MobileChunk chunk) throws IOException
for (int i = chunk.minX(); i < chunk.maxX(); i++) {
for (int j = chunk.minY(); j < chunk.maxY(); j++) {
for (int k = chunk.minZ(); k < chunk.maxZ(); k++) {
Block block = chunk.getBlockState(new BlockPos(i, j, k)).getBlock();
if (block != Blocks.air) {
IBlockState state = chunk.getBlockState(new BlockPos(i, j, k));
if (state != null && state.getBlock() != Blocks.air) {
count++;
}
}
Expand All @@ -42,8 +42,8 @@ public static int writeAll(DataOutput out, MobileChunk chunk) throws IOException
for (int i = chunk.minX(); i < chunk.maxX(); i++) {
for (int j = chunk.minY(); j < chunk.maxY(); j++) {
for (int k = chunk.minZ(); k < chunk.maxZ(); k++) {
Block block = chunk.getBlockState(new BlockPos(i, j, k)).getBlock();
if (block != Blocks.air) {
IBlockState state = chunk.getBlockState(new BlockPos(i, j, k));
if (state != null && state.getBlock() != Blocks.air) {
writeBlock(out, chunk.getBlockState(new BlockPos(i, j, k)), new BlockPos(i, j, k));
}
}
Expand Down Expand Up @@ -111,7 +111,7 @@ private static void postCompress(ByteBuf data, DataOutputStream out, int count)
MovingWorld.logger.debug(String.format(Locale.ENGLISH, "%d blocks written. Efficiency: %d/%d = %.2f", count, byteswritten, count * 9, f));

if (byteswritten > 32000) {
MovingWorld.logger.warn("Ship probably contains too many blocks");
MovingWorld.logger.warn("Ship probably contains too many blocks");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ public boolean addBlockWithState(BlockPos pos, IBlockState state) {
}
}


return true;
}

Expand Down Expand Up @@ -552,7 +551,11 @@ public int getHeight() {

@Override
public IBlockState getBlockState(BlockPos pos) {
return getBlockStorage(pos).get(pos.getX(), pos.getY(), pos.getZ());
ExtendedBlockStorage storage = getBlockStorage(pos);
IBlockState state = storage != null ? storage.get(pos.getX(), pos.getY(), pos.getZ()) : null;
if (state == null || storage == null)
return Blocks.air.getDefaultState();
return state;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private Block[] getDefaultBlockBlackList() {

public void loadAndSave() {
String[] defaultMaterialDensities = {"\"minecraft:air=0.0\"", "\"minecraft:wool=0.1\""};
String[] defaultBlockDensities = {"\"ArchimedesShips:floater=0.04\"", "\"ArchimedesShips:balloon=0.02\""};
String[] defaultBlockDensities = {"\"ArchimedesShipsPlus:floater=0.04\"", "\"ArchimedesShipsPlus:balloon=0.02\""};

Block[] defaultOverWritableBlocks = {Blocks.tallgrass, Blocks.waterlily, Blocks.snow_layer};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ public void onEntityUpdate() {
}
}

@Override
public EntityBoat.Type getBoatType() {
return Type.OAK;
}

public void setRotatedBoundingBox() {
if (mobileChunk == null) {
float hw = width / 2F;
Expand Down Expand Up @@ -346,6 +351,7 @@ public void onUpdate() {
} else {
handleServerUpdate(horvel);
}

}

@SideOnly(Side.CLIENT)
Expand Down Expand Up @@ -434,11 +440,12 @@ public void handleServerUpdatePreRotation() {

@Override
public void updatePassenger(Entity passenger) {
updatePassengerPosition(passenger, riderDestination, 1);
if (this.isPassenger(passenger))
updatePassengerPosition(passenger, riderDestination, 1);
}

public void updatePassengerPosition(Entity entity, BlockPos riderDestination, int flags) {
if (entity != null) {
public void updatePassengerPosition(Entity passenger, BlockPos riderDestination, int flags) {
if (passenger != null) {
int frontDir = frontDirection.getHorizontalIndex();

float yaw = (float) Math.toRadians(rotationYaw);
Expand All @@ -456,7 +463,7 @@ public void updatePassengerPosition(Entity entity, BlockPos riderDestination, in
x1 -= 1;
}

IBlockState state = mobileChunk.getBlockState(new BlockPos(x1, MathHelper.floor_double(y1 + getMountedYOffset() + entity.getYOffset()), z1));
IBlockState state = mobileChunk.getBlockState(new BlockPos(x1, MathHelper.floor_double(y1 + getMountedYOffset() + passenger.getYOffset()), z1));
if (state.isOpaqueCube()) {
x1 = riderDestination.getX();
y1 = riderDestination.getY();
Expand Down Expand Up @@ -485,10 +492,42 @@ public void updatePassengerPosition(Entity entity, BlockPos riderDestination, in
if ((flags & 1) == 1)
vec.addVector(0, 0.25, 0);

entity.setPosition(posX + vec.xCoord, posY + vec.yCoord + entity.getYOffset(), posZ + vec.zCoord);
passenger.setPosition(posX + vec.xCoord, posY + vec.yCoord + passenger.getYOffset(), posZ + vec.zCoord);

this.applyYawToEntity(passenger);
}
}

@Override
protected void applyYawToEntity(Entity entityToUpdate) {
int frontDirIndex = frontDirection.getHorizontalIndex();

float modifiedRotationYaw = -this.rotationYaw;
EnumFacing frontDirEnumFacing = EnumFacing.getHorizontal(frontDirIndex);
switch (frontDirEnumFacing) {
case NORTH: {
modifiedRotationYaw -= 180;
}
case SOUTH: {
modifiedRotationYaw -= 90;
}
case WEST: {
modifiedRotationYaw -= 180;
}
case EAST: {
modifiedRotationYaw -= 90;
}
}


entityToUpdate.setRenderYawOffset(modifiedRotationYaw);
float f = MathHelper.wrapDegrees(entityToUpdate.rotationYaw - modifiedRotationYaw);
float f1 = MathHelper.clamp_float(f, -105.0F, 105.0F);
entityToUpdate.prevRotationYaw += f1 - f;
entityToUpdate.rotationYaw += f1 - f;
entityToUpdate.setRotationYawHead(entityToUpdate.rotationYaw);
}

private boolean handleCollision(double cPosX, double cPosY, double cPosZ) {
boolean didCollide = false;
if (!worldObj.isRemote) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package darkevilmac.movingworld.common.entity;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;

/**
Expand All @@ -12,7 +12,7 @@ public interface IMixinEntity {

void resetPosToBB();

void updateFall(double y, boolean onGroundIn, Block blockIn, BlockPos pos);
void updateFall(double y, boolean onGroundIn, IBlockState state, BlockPos pos);

int getNextStepDistance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void onChunkUpdate() {
for (int k = chunk.minZ(); k < chunk.maxZ(); k++) {
BlockPos pos = new BlockPos(i, j, k);
IBlockState blockState = chunk.getBlockState(pos);
if (blockState.getMaterial() != Material.air) {
if (blockState != null && blockState.getMaterial() != Material.air) {
getMovingWorld().getCapabilities().onChunkBlockAdded(blockState, pos);
}
}
Expand Down

0 comments on commit 0dc2ce5

Please sign in to comment.