mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 11:49:37 +00:00
Merge 1.12
This commit is contained in:
commit
7d318bb3bf
17 files changed
+1655
-1489
No files matched your search
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.entity;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@@ -124,12 +125,12 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
|
||||
|
||||
private static final DataParameter<Integer> INVUL_TIME = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.VARINT);
|
||||
|
||||
private static final BlockPos[] PYLON_LOCATIONS = {
|
||||
private static final List<BlockPos> PYLON_LOCATIONS = ImmutableList.of(
|
||||
new BlockPos(4, 1, 4),
|
||||
new BlockPos(4, 1, -4),
|
||||
new BlockPos(-4, 1, 4),
|
||||
new BlockPos(-4, 1, -4)
|
||||
};
|
||||
);
|
||||
|
||||
private static final List<ResourceLocation> CHEATY_BLOCKS = Arrays.asList(
|
||||
new ResourceLocation("openblocks", "beartrap"),
|
||||
@@ -195,25 +196,22 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
|
||||
}
|
||||
|
||||
//check pylons
|
||||
for(BlockPos coords : PYLON_LOCATIONS) {
|
||||
BlockPos pos_ = pos.add(coords);
|
||||
|
||||
BlockState state = world.getBlockState(pos_);
|
||||
if(state.getBlock() != ModBlocks.gaiaPylon) {
|
||||
if(!world.isRemote)
|
||||
player.sendMessage(new TranslationTextComponent("botaniamisc.needsCatalysts").setStyle(new Style().setColor(TextFormatting.RED)));
|
||||
return false;
|
||||
List<BlockPos> invalidPylonBlocks = checkPylons(world, pos);
|
||||
if(!invalidPylonBlocks.isEmpty()) {
|
||||
if(world.isRemote) {
|
||||
warnInvalidBlocks(invalidPylonBlocks);
|
||||
} else {
|
||||
player.sendMessage(new TranslationTextComponent("botaniamisc.needsCatalysts").setStyle(new Style().setColor(TextFormatting.RED)));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//check arena shape
|
||||
List<BlockPos> invalidArenaBlocks = checkArena(world, pos);
|
||||
if(!invalidArenaBlocks.isEmpty()) {
|
||||
if(world.isRemote) {
|
||||
Botania.proxy.setWispFXDepthTest(false);
|
||||
for(BlockPos pos_ : invalidArenaBlocks)
|
||||
Botania.proxy.wispFX(pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5, 1F, 0.2F, 0.2F, 0.5F, 0F, 8);
|
||||
Botania.proxy.setWispFXDepthTest(true);
|
||||
warnInvalidBlocks(invalidArenaBlocks);
|
||||
} else {
|
||||
PacketHandler.sendTo((ServerPlayerEntity) player,
|
||||
new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.ARENA_INDICATOR, pos.getX(), pos.getY(), pos.getZ()));
|
||||
@@ -250,6 +248,21 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
|
||||
return true;
|
||||
}
|
||||
|
||||
private static List<BlockPos> checkPylons(World world, BlockPos beaconPos) {
|
||||
List<BlockPos> invalidPylonBlocks = new ArrayList<>();
|
||||
|
||||
for(BlockPos coords : PYLON_LOCATIONS) {
|
||||
BlockPos pos_ = beaconPos.add(coords);
|
||||
|
||||
BlockState state = world.getBlockState(pos_);
|
||||
if(state.getBlock() != ModBlocks.gaiaPylon) {
|
||||
invalidPylonBlocks.add(pos_);
|
||||
}
|
||||
}
|
||||
|
||||
return invalidPylonBlocks;
|
||||
}
|
||||
|
||||
private static List<BlockPos> checkArena(World world, BlockPos beaconPos) {
|
||||
List<BlockPos> trippedPositions = new ArrayList<>();
|
||||
int range = (int) Math.ceil(ARENA_RANGE);
|
||||
@@ -260,24 +273,41 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
|
||||
if(Math.abs(x) == 4 && Math.abs(z) == 4 || vazkii.botania.common.core.helper.MathHelper.pointDistancePlane(x, z, 0, 0) > ARENA_RANGE)
|
||||
continue; // Ignore pylons and out of circle
|
||||
|
||||
for(int y = -1; y <= ARENA_HEIGHT; y++) {
|
||||
boolean hasFloor = false;
|
||||
|
||||
for(int y = -2; y <= ARENA_HEIGHT; y++) {
|
||||
if(x == 0 && y == 0 && z == 0)
|
||||
continue; //this is the beacon
|
||||
continue; //the beacon
|
||||
|
||||
pos = beaconPos.add(x, y, z);
|
||||
|
||||
boolean expectedBlockHere = y == -1; //the floor
|
||||
boolean isBlockHere = !world.getBlockState(pos).getCollisionShape(world, pos).isEmpty();
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
if(expectedBlockHere != isBlockHere) {
|
||||
boolean allowBlockHere = y < 0;
|
||||
boolean isBlockHere = !state.getCollisionShape(world, pos).isEmpty();
|
||||
|
||||
if(allowBlockHere && isBlockHere) //floor is here! good
|
||||
hasFloor = true;
|
||||
|
||||
if(y == 0 && !hasFloor) //column is entirely missing floor
|
||||
trippedPositions.add(pos.down());
|
||||
|
||||
if(!allowBlockHere && isBlockHere && !BLACKLIST.contains(state.getBlock())) //ceiling is obstructed in this column
|
||||
trippedPositions.add(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return trippedPositions;
|
||||
}
|
||||
|
||||
private static void warnInvalidBlocks(Iterable<BlockPos> invalidPositions) {
|
||||
Botania.proxy.setWispFXDepthTest(false);
|
||||
for(BlockPos pos_ : invalidPositions) {
|
||||
Botania.proxy.wispFX(pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5, 1F, 0.2F, 0.2F, 0.5F, 0F, 8);
|
||||
}
|
||||
Botania.proxy.setWispFXDepthTest(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
goalSelector.addGoal(0, new SwimGoal(this));
|
||||
@@ -552,7 +582,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
|
||||
//don't break blacklisted blocks
|
||||
if(BLACKLIST.contains(block)) continue;
|
||||
//don't break the floor
|
||||
if(y == source.getY() - 1) continue;
|
||||
if(y < source.getY()) continue;
|
||||
//don't break blocks in pylon columns
|
||||
if(Math.abs(source.getX() - x) == 4 && Math.abs(source.getZ() - z) == 4) continue;
|
||||
|
||||
@@ -812,12 +842,11 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
|
||||
private void teleportRandomly() {
|
||||
//choose a location to teleport to
|
||||
double oldX = posX, oldY = posY, oldZ = posZ;
|
||||
double newX, newY, newZ;
|
||||
double newX, newY = source.getY(), newZ;
|
||||
int tries = 0;
|
||||
|
||||
do {
|
||||
newX = source.getX() + (rand.nextDouble() - .5) * ARENA_RANGE;
|
||||
newY = source.getY();
|
||||
newZ = source.getZ() + (rand.nextDouble() - .5) * ARENA_RANGE;
|
||||
tries++;
|
||||
//ensure it's inside the arena ring, and not just its bounding square
|
||||
@@ -830,6 +859,12 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti
|
||||
newY = source.getY() + 1.6;
|
||||
newZ = source.getZ() + .5;
|
||||
}
|
||||
|
||||
//for low-floor arenas, ensure landing on the ground
|
||||
BlockPos tentativeFloorPos = new BlockPos(newX, newY - 1, newZ);
|
||||
if(world.getBlockState(tentativeFloorPos).getCollisionShape(world, tentativeFloorPos).isEmpty()) {
|
||||
newY--;
|
||||
}
|
||||
|
||||
//teleport there
|
||||
setPositionAndUpdate(newX, newY, newZ);
|
||||
|
||||
Reference in new issue
Block a user