Skip to content

Commit

Permalink
Added ✨ broken code ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
JunePrimavera committed Sep 3, 2023
1 parent 8e05dfb commit 8290c3e
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/github/teampropulsive/Items.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import io.github.teampropulsive.armor.SpaceArmorMaterial;
import io.github.teampropulsive.block.Blocks;
import io.github.teampropulsive.types.GasCanister;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
Expand All @@ -13,7 +14,6 @@
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

import static io.github.teampropulsive.util.Gases.*;

Expand Down
16 changes: 1 addition & 15 deletions src/main/java/io/github/teampropulsive/Propulsive.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
package io.github.teampropulsive;

import io.github.teampropulsive.block.Blocks;
import io.github.teampropulsive.celestial.Star;
import io.github.teampropulsive.celestial.Terrestrial;
import io.github.teampropulsive.types.AtmoCompositionGas;
import io.github.teampropulsive.types.Planet;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.damage.DamageType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec2f;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.feature.PlacedFeature;
import qouteall.q_misc_util.my_util.Vec2d;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

import static io.github.teampropulsive.util.Gases.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.teampropulsive;
package io.github.teampropulsive.block;

import io.github.teampropulsive.Propulsive;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.registry.Registries;
Expand Down Expand Up @@ -34,7 +35,7 @@ public class Blocks {
public static final Block LAUNCH_TOWER = new Block(
FabricBlockSettings.create().requiresTool().strength(5.0f, 11.0f)
);
public static final Block BLUEPRINT_TABLE = new Block(
public static final Block BLUEPRINT_TABLE = new BlueprintTable(
FabricBlockSettings.create().requiresTool().strength(5.0f, 11.0f)
);

Expand Down
89 changes: 89 additions & 0 deletions src/main/java/io/github/teampropulsive/block/BlueprintTable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package io.github.teampropulsive.block;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.util.ArrayList;

import static io.github.teampropulsive.block.Blocks.LAUNCH_PAD;
import static io.github.teampropulsive.block.Blocks.LAUNCH_TOWER;

public class BlueprintTable extends Block {
public BlueprintTable(Settings settings) {
super(settings);
}

@Override
public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
super.onPlaced(world, pos, state, placer, itemStack);
get_area(world, pos);

}

public void get_area(World world, BlockPos pos) {
ArrayList<BlockPos> pad = new ArrayList<>();
int max_y = pos.getY();
max_y = get_adjacent_pads(world, pos, pad, max_y); // Returns all launch pad block positions and the max y
int max_x = Integer.MIN_VALUE;
int max_z = Integer.MIN_VALUE;
int min_x = Integer.MAX_VALUE;
int min_z = Integer.MAX_VALUE;
for (BlockPos blockPos : pad) {
if (blockPos.getX() > max_x)
max_x = blockPos.getX();
if (blockPos.getZ() > max_z)
max_z = blockPos.getZ();
if (blockPos.getX() < min_x)
min_x = blockPos.getX();
if (blockPos.getZ() < min_z)
min_z = blockPos.getZ();
}

Vec3i point_a = new Vec3i(max_x, max_y, max_z);
Vec3i point_b = new Vec3i(min_x, pos.getY(), min_z);
System.out.println(pad);
System.out.println(point_a);
System.out.println(point_b);
}

public int get_adjacent_pads(World world, BlockPos pos, ArrayList<BlockPos> pad, int tower_y) {
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
BlockPos p = pos.add(new Vec3i(x, pos.getY(), z));
boolean exists = false;
for (BlockPos blockPos : pad) {
if (blockPos == p) {
exists = true;
break;
}
}
if (!exists) {
Block block = world.getBlockState(p).getBlock();
if (block == LAUNCH_PAD) {
pad.add(p);
tower_y = get_adjacent_pads(world, p, pad, tower_y); // Update tower_y recursively
} else if (block == LAUNCH_TOWER) {
BlockPos height = p.up();
while (world.getBlockState(height).getBlock() == LAUNCH_TOWER) {
height = height.up();
}
if (height.getY() > tower_y) {
tower_y = height.getY();
}
}
}

}
}
return tower_y;
}

}
Empty file.

0 comments on commit 8290c3e

Please sign in to comment.