Change meteor compass to target chest (#332)
This commit is contained in:
@@ -26,6 +26,8 @@ import appeng.helpers.ICustomCollision;
|
|||||||
import appeng.tile.storage.TileSkyChest;
|
import appeng.tile.storage.TileSkyChest;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@@ -48,6 +50,8 @@ public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision {
|
|||||||
private static final double AABB_OFFSET_SIDES = 0.06;
|
private static final double AABB_OFFSET_SIDES = 0.06;
|
||||||
private static final double AABB_OFFSET_TOP = 0.125;
|
private static final double AABB_OFFSET_TOP = 0.125;
|
||||||
|
|
||||||
|
public static final PropertyBool NATURAL = PropertyBool.create("natural");
|
||||||
|
|
||||||
public enum SkyChestType {
|
public enum SkyChestType {
|
||||||
STONE, BLOCK
|
STONE, BLOCK
|
||||||
}
|
}
|
||||||
@@ -61,6 +65,22 @@ public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision {
|
|||||||
this.setHardness(50);
|
this.setHardness(50);
|
||||||
this.blockResistance = 150.0f;
|
this.blockResistance = 150.0f;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
setDefaultState(getDefaultState().withProperty(NATURAL, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IProperty[] getAEStates() {
|
||||||
|
return new IProperty[]{NATURAL};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetaFromState(IBlockState state) {
|
||||||
|
return state.getValue(NATURAL) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockState getStateFromMeta(int meta) {
|
||||||
|
return getDefaultState().withProperty(NATURAL, meta == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,11 +21,13 @@ package appeng.services;
|
|||||||
|
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.util.DimensionalCoord;
|
import appeng.api.util.DimensionalCoord;
|
||||||
|
import appeng.block.storage.BlockSkyChest;
|
||||||
import appeng.services.compass.CompassReader;
|
import appeng.services.compass.CompassReader;
|
||||||
import appeng.services.compass.ICompassCallback;
|
import appeng.services.compass.ICompassCallback;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
@@ -117,20 +119,24 @@ public final class CompassService {
|
|||||||
// lower level...
|
// lower level...
|
||||||
final Chunk c = w.getChunk(cx, cz);
|
final Chunk c = w.getChunk(cx, cz);
|
||||||
|
|
||||||
Optional<Block> maybeBlock = AEApi.instance().definitions().blocks().skyStoneBlock().maybeBlock();
|
Optional<Block> maybeBlock = AEApi.instance().definitions().blocks().skyStoneChest().maybeBlock();
|
||||||
if (maybeBlock.isPresent()) {
|
if (maybeBlock.isPresent()) {
|
||||||
Block skyStoneBlock = maybeBlock.get();
|
Block skyStoneChest = maybeBlock.get();
|
||||||
for (int i = 0; i < CHUNK_SIZE; i++) {
|
for (int i = 0; i < CHUNK_SIZE; i++) {
|
||||||
for (int j = 0; j < CHUNK_SIZE; j++) {
|
for (int j = 0; j < CHUNK_SIZE; j++) {
|
||||||
for (int k = low_y; k < hi_y; k++) {
|
for (int k = low_y; k < hi_y; k++) {
|
||||||
final Block blk = c.getBlockState(i, k, j).getBlock();
|
final IBlockState state = c.getBlockState(i, k, j);
|
||||||
if (blk == skyStoneBlock) {
|
final Block blk = state.getBlock();
|
||||||
|
if (blk == skyStoneChest) {
|
||||||
|
if (state.getPropertyKeys().contains(BlockSkyChest.NATURAL)
|
||||||
|
&& state.getValue(BlockSkyChest.NATURAL)) {
|
||||||
return this.executor.submit(new CMUpdatePost(w, cx, cz, cdy, true));
|
return this.executor.submit(new CMUpdatePost(w, cx, cz, cdy, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this.executor.submit(new CMUpdatePost(w, cx, cz, cdy, false));
|
return this.executor.submit(new CMUpdatePost(w, cx, cz, cdy, false));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import appeng.api.AEApi;
|
|||||||
import appeng.api.definitions.IBlockDefinition;
|
import appeng.api.definitions.IBlockDefinition;
|
||||||
import appeng.api.definitions.IBlocks;
|
import appeng.api.definitions.IBlocks;
|
||||||
import appeng.api.definitions.IMaterials;
|
import appeng.api.definitions.IMaterials;
|
||||||
|
import appeng.block.storage.BlockSkyChest;
|
||||||
import appeng.core.AEConfig;
|
import appeng.core.AEConfig;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
import appeng.core.worlddata.WorldData;
|
import appeng.core.worlddata.WorldData;
|
||||||
@@ -192,7 +193,8 @@ public final class MeteoritePlacer {
|
|||||||
this.skyStoneDefinition.maybeBlock().ifPresent(block -> this.placeMeteoriteSkyStone(w, x, y, z, block));
|
this.skyStoneDefinition.maybeBlock().ifPresent(block -> this.placeMeteoriteSkyStone(w, x, y, z, block));
|
||||||
|
|
||||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.SPAWN_PRESSES_IN_METEORITES)) {
|
if (AEConfig.instance().isFeatureEnabled(AEFeature.SPAWN_PRESSES_IN_METEORITES)) {
|
||||||
this.skyChestDefinition.maybeBlock().ifPresent(block -> this.putter.put(w, x, y, z, block));
|
this.skyChestDefinition.maybeBlock().ifPresent(block -> this.putter.put(w, x, y, z,
|
||||||
|
block.getDefaultState().withProperty(BlockSkyChest.NATURAL, true)));
|
||||||
|
|
||||||
final TileEntity te = w.getTileEntity(x, y, z);
|
final TileEntity te = w.getTileEntity(x, y, z);
|
||||||
final InventoryAdaptor ap = InventoryAdaptor.getAdaptor(te, EnumFacing.UP);
|
final InventoryAdaptor ap = InventoryAdaptor.getAdaptor(te, EnumFacing.UP);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class FalloutCopy extends Fallout {
|
|||||||
public void getRandomFall(final IMeteoriteWorld w, final int x, final int y, final int z) {
|
public void getRandomFall(final IMeteoriteWorld w, final int x, final int y, final int z) {
|
||||||
final double a = Math.random();
|
final double a = Math.random();
|
||||||
if (a > SPECIFIED_BLOCK_THRESHOLD) {
|
if (a > SPECIFIED_BLOCK_THRESHOLD) {
|
||||||
this.putter.put(w, x, y, z, this.block, 3);
|
this.putter.put(w, x, y, z, this.block);
|
||||||
} else {
|
} else {
|
||||||
this.getOther(w, x, y, z, a);
|
this.getOther(w, x, y, z, a);
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ public class FalloutCopy extends Fallout {
|
|||||||
public void getRandomInset(final IMeteoriteWorld w, final int x, final int y, final int z) {
|
public void getRandomInset(final IMeteoriteWorld w, final int x, final int y, final int z) {
|
||||||
final double a = Math.random();
|
final double a = Math.random();
|
||||||
if (a > SPECIFIED_BLOCK_THRESHOLD) {
|
if (a > SPECIFIED_BLOCK_THRESHOLD) {
|
||||||
this.putter.put(w, x, y, z, this.block, 3);
|
this.putter.put(w, x, y, z, this.block);
|
||||||
} else if (a > AIR_BLOCK_THRESHOLD) {
|
} else if (a > AIR_BLOCK_THRESHOLD) {
|
||||||
this.putter.put(w, x, y, z, Platform.AIR_BLOCK);
|
this.putter.put(w, x, y, z, Platform.AIR_BLOCK);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class MeteoriteBlockPutter {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void put(final IMeteoriteWorld w, final int i, final int j, final int k, final IBlockState state, final int meta) {
|
public void put(final IMeteoriteWorld w, final int i, final int j, final int k, final IBlockState state) {
|
||||||
if (w.getBlock(i, j, k) == Blocks.BEDROCK) {
|
if (w.getBlock(i, j, k) == Blocks.BEDROCK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
{
|
{
|
||||||
"__comment": "This block is rendered via TESR, so this is only used for the particle texture.",
|
"__comment": "This block is rendered via TESR, so this is only used for the particle texture.",
|
||||||
"variants": {
|
"forge_marker": 1,
|
||||||
"normal": {
|
"defaults": {
|
||||||
"model": "appliedenergistics2:sky_stone_block"
|
"model": "appliedenergistics2:sky_stone_block"
|
||||||
|
},
|
||||||
|
"variants": {
|
||||||
|
"natural": {
|
||||||
|
"true": {},
|
||||||
|
"false": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user