This commit is contained in:
Chipperfluff 2025-12-19 12:13:43 +01:00
parent 8b2ebafe56
commit fcee5d7ee8
26 changed files with 571 additions and 362 deletions

327
agents.md Normal file
View File

@ -0,0 +1,327 @@
# Coding Guidelines (Java written C/C++-style)
These rules exist to **preserve intent, structure, and mental parseability**.
Formatting must reflect **logic**, not arbitrary line limits or formatter preferences.
Java syntax, **C/C++ brain**.
---
## 1. General Philosophy
* Java is written **as if it were C/C++**
* Formatting must never change perceived control flow
* Readability = how fast the code parses *correctly* in your head
* Tools must adapt to the codebase, not the other way around
---
## 2. Indentation & Whitespace
* **Indentation: 4 spaces**
* **No tabs**
* Avoid excessive vertical whitespace
* Blank lines only where they add logical separation
✅ **Good**
```java
int sum(int a, int b) {
int r = a + b;
return r;
}
```
❌ **Bad**
```java
int sum(int a, int b)
{
int r = a + b;
return r;
}
```
---
## 3. Braces
* Braces are **always required**
* Opening brace stays **on the same line**
* Never rely on implicit scopes
✅ **Good**
```java
if (value == null) {
return;
}
```
❌ **Bad**
```java
if (value == null)
{
return;
}
```
> Rationale: new-line braces create **false scope perception** and visual ambiguity.
---
## 4. Imports (IMPORTANT)
### ❗ Never use fully-qualified class names inline
❌ **Forbidden**
```java
net.minecraft.util.math.BlockPos pos = new net.minecraft.util.math.BlockPos(0, 0, 0);
```
✅ **Required**
```java
import net.minecraft.util.math.BlockPos;
BlockPos pos = new BlockPos(0, 0, 0);
```
### Why:
* Fully-qualified names **destroy readability**
* They bloat expressions and hide logic
* Imports exist to solve exactly this problem
**Rule:**
> If you need a class, **import it**.
> If imports collide, resolve the collision explicitly — do *not* inline paths everywhere.
---
## 5. Function & Method Definitions
* **Method signatures must stay on one line**
* Never break parameters across multiple lines
* Length is acceptable; ambiguity is not
✅ **Good**
```java
void processUser(User user, int flags, boolean force, long timeout) {
...
}
```
❌ **Bad**
```java
void processUser(
User user,
int flags,
boolean force,
long timeout
) {
...
}
```
> Reason: multiline signatures look like scopes and break C/C++ mental parsing.
---
## 6. Function Calls & Argument Layout
### Default rule
* **Single-line calls are preferred**
* Flat calls stay flat
* Length alone is **not** a reason to wrap
✅ **Good**
```java
Color color = user.getProfile().getSettings().getTheme().getPrimaryColor();
```
---
### When multiline calls ARE allowed (and expected)
Multiline calls are allowed **only when**:
* The call is **structural / declarative**
* Each argument is conceptually distinct
* Nesting would otherwise hide meaning
### Example (correct usage)
```java
BiomeModifications.addFeature(
BiomeSelectors.foundInOverworld(),
GenerationStep.Feature.UNDERGROUND_ORES,
RegistryKey.of(
RegistryKeys.PLACED_FEATURE,
new Identifier("chipi", "chipper_ore")
)
);
```
### Why this is correct:
* Each argument represents a **different conceptual layer**
* Nested calls are grouped logically
* Visual structure mirrors logical structure
* This reads like a configuration block, not a simple call
---
### ❌ Incorrect multiline usage
```java
doThing(
a,
b,
c
);
```
> This adds vertical noise with **no semantic gain**.
---
## 7. Chained Calls
* Flat chains stay on one line
* Long or builder-style chains may be split vertically
* Each chained step gets its own line
✅ **Good**
```java
builder
.withColor(theme.getPrimaryColor())
.withSize(32)
.enableShadow()
.build();
```
❌ **Bad**
```java
builder.withColor(
theme.getPrimaryColor()
).withSize(
32
).enableShadow().build();
```
---
## 8. Control Flow & Returns
* **Early returns are encouraged**
* Avoid artificial nesting
* Single-exit functions are **not required**
✅ **Good**
```java
void handle(User user) {
if (user == null) return;
if (!user.isActive()) return;
process(user);
}
```
❌ **Bad**
```java
void handle(User user) {
if (user != null) {
if (user.isActive()) {
process(user);
}
}
}
```
---
## 9. One-Liners
* One-liners allowed for **simple guard clauses**
* No complex logic on one line
✅ **Allowed**
```java
if (value == null) return;
```
❌ **Not allowed**
```java
if (a == b && c != d && flag && check()) doThing();
```
---
## 10. Null Handling
* `null` is a **valid, intentional state**
* Do not over-engineer around it
* Prefer clarity over defensive clutter
✅ **Good**
```java
User user = findUser(id);
if (user == null) return;
```
---
## 11. Logging & Debug Output
* Logging must be **short and readable**
* Prefer `System.out.println` for quick diagnostics
* Verbose logging only when justified
✅ **Good**
```java
System.out.println("Loaded structure: " + id);
```
---
## 12. Autoformatters & Linters
Autoformatters **must not**:
* Break method signatures
* Move braces to new lines
* Introduce unwanted trailing newlines
* Rewrap stable code repeatedly
If a formatter fights these rules: **disable or reconfigure it**.
---
## Summary (Non-Negotiable)
* Java written with **C/C++ structure**
* Compact signatures, explicit layout
* Imports always used
* Multiline only when it adds meaning
* Formatting reflects logic, not fashion
> If a tool disagrees with this file, the tool is wrong.

View File

@ -37,14 +37,9 @@ public class ChipiMod implements ModInitializer {
public static final String MOD_ID = "chipi";
public static final RegistryKey<World> CHIPI_DIMENSION_KEY =
RegistryKey.of(
RegistryKeys.WORLD,
new Identifier("chipi", "chipi_dimension")
);
public static final RegistryKey<World> CHIPI_DIMENSION_KEY = RegistryKey.of(RegistryKeys.WORLD, new Identifier("chipi", "chipi_dimension"));
private static final Identifier SPAWN_STRUCTURE =
new Identifier("chipi", "spawn");
private static final Identifier SPAWN_STRUCTURE = new Identifier("chipi", "spawn");
private static MinecraftServer SERVER;
@ -60,25 +55,17 @@ public class ChipiMod implements ModInitializer {
ChipiBlessingEvents.register();
ChipiHungerHandler.register();
FabricDefaultAttributeRegistry.register(
ModEntities.MEP,
MepEntity.createMepAttributes()
);
FabricDefaultAttributeRegistry.register(ModEntities.MEP, MepEntity.createMepAttributes());
BiomeModifications.addFeature(
BiomeSelectors.foundInOverworld(),
GenerationStep.Feature.UNDERGROUND_ORES,
RegistryKey.of(
RegistryKeys.PLACED_FEATURE,
new Identifier("chipi", "chipper_ore")
)
RegistryKey.of(RegistryKeys.PLACED_FEATURE, new Identifier("chipi", "chipper_ore"))
);
CommandRegistrationCallback.EVENT.register(
(dispatcher, registryAccess, environment) -> {
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
ChpCommand.register(dispatcher);
}
);
});
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
SERVER = server;
@ -108,8 +95,7 @@ public class ChipiMod implements ModInitializer {
.get(GameRules.DO_DAYLIGHT_CYCLE)
.set(false, server);
SpawnPlacedState state =
world.getPersistentStateManager().getOrCreate(
SpawnPlacedState state = world.getPersistentStateManager().getOrCreate(
SpawnPlacedState::fromNbt,
SpawnPlacedState::new,
"chipi_spawn"
@ -119,10 +105,7 @@ public class ChipiMod implements ModInitializer {
return;
}
StructureTemplate spawnTemplate =
world.getStructureTemplateManager()
.getTemplate(SPAWN_STRUCTURE)
.orElse(null);
StructureTemplate spawnTemplate = world.getStructureTemplateManager().getTemplate(SPAWN_STRUCTURE).orElse(null);
if (spawnTemplate == null) {
System.err.println("[CHIPI] spawn.nbt not found!");
@ -131,14 +114,7 @@ public class ChipiMod implements ModInitializer {
BlockPos spawnCenter = new BlockPos(0, 80, 0);
spawnTemplate.place(
world,
spawnCenter,
spawnCenter,
new StructurePlacementData(),
world.getRandom(),
2
);
spawnTemplate.place(world, spawnCenter, spawnCenter, new StructurePlacementData(), world.getRandom(), 2);
world.setSpawnPos(spawnCenter.up(), 0.0f);

View File

@ -4,17 +4,13 @@ import net.minecraft.advancement.criterion.Criteria;
public class ModCriteria {
public static final PortalActivatedTrigger PORTAL_ACTIVATED =
Criteria.register(new PortalActivatedTrigger());
public static final PortalActivatedTrigger PORTAL_ACTIVATED = Criteria.register(new PortalActivatedTrigger());
public static final PortalDestroyedTrigger PORTAL_DESTROYED =
Criteria.register(new PortalDestroyedTrigger());
public static final PortalDestroyedTrigger PORTAL_DESTROYED = Criteria.register(new PortalDestroyedTrigger());
public static final VoidConsumedTrigger VOID_CONSUMED_TRIGGER =
Criteria.register(new VoidConsumedTrigger());
public static final VoidConsumedTrigger VOID_CONSUMED_TRIGGER = Criteria.register(new VoidConsumedTrigger());
public static final VoidConsumedFireTrigger VOID_CONSUMED_FIRE_TRIGGER =
Criteria.register(new VoidConsumedFireTrigger());
public static final VoidConsumedFireTrigger VOID_CONSUMED_FIRE_TRIGGER = Criteria.register(new VoidConsumedFireTrigger());
public static void register() {
// classload trigger

View File

@ -1,7 +1,6 @@
package net.Chipperfluff.chipi.advancement;
import com.google.gson.JsonObject;
import net.minecraft.advancement.criterion.AbstractCriterion;
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;

View File

@ -1,7 +1,6 @@
package net.Chipperfluff.chipi.advancement;
import com.google.gson.JsonObject;
import net.minecraft.advancement.criterion.AbstractCriterion;
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;

View File

@ -1,7 +1,6 @@
package net.Chipperfluff.chipi.advancement;
import com.google.gson.JsonObject;
import net.minecraft.advancement.criterion.AbstractCriterion;
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;

View File

@ -1,7 +1,6 @@
package net.Chipperfluff.chipi.advancement;
import com.google.gson.JsonObject;
import net.minecraft.advancement.criterion.AbstractCriterion;
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;

View File

@ -16,16 +16,14 @@ public class ChipperFrameBlock extends PillarBlock {
}
@Override
public void onPlaced(
World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
if (!world.isClient) {
ChipperPortalShape.tryCreate(world, pos);
}
}
@Override
public void onStateReplaced(
BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
if (!world.isClient && state.getBlock() != newState.getBlock()) {
ChipperPortalShape.destroyNearby(world, pos);

View File

@ -29,8 +29,7 @@ public class ChipperPortalBlock extends Block {
// Walk-through portal
@Override
public VoxelShape getCollisionShape(
BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return VoxelShapes.empty();
}
@ -46,8 +45,7 @@ public class ChipperPortalBlock extends Block {
}
@Override
public float calcBlockBreakingDelta(
BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
return player.isCreative() ? super.calcBlockBreakingDelta(state, player, world, pos) : 0.0F;
}

View File

@ -2,6 +2,7 @@ package net.Chipperfluff.chipi.block;
import net.Chipperfluff.chipi.advancement.ModCriteria;
import net.minecraft.block.BlockState;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
@ -27,9 +28,8 @@ public class ChipperPortalShape {
if (shape.isValid()) {
shape.placePortal();
if (serverWorld.getClosestPlayer(
placedPos.getX(), placedPos.getY(), placedPos.getZ(), 10, false)
instanceof net.minecraft.server.network.ServerPlayerEntity serverPlayer) {
if (serverWorld.getClosestPlayer(placedPos.getX(), placedPos.getY(), placedPos.getZ(), 10, false)
instanceof ServerPlayerEntity serverPlayer) {
ModCriteria.PORTAL_ACTIVATED.trigger(serverPlayer);
}
@ -46,7 +46,6 @@ public class ChipperPortalShape {
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 5; y++) {
boolean edge = x == 0 || x == 3 || y == 0 || y == 4;
BlockPos pos = offset(base, x, y);
BlockState state = world.getBlockState(pos);
@ -83,8 +82,7 @@ public class ChipperPortalShape {
for (int x = 1; x <= 2; x++) {
for (int y = 1; y <= 3; y++) {
world.setBlockState(
offset(base, x, y), ModBlocks.CHIPPER_PORTAL.getDefaultState(), 3);
world.setBlockState(offset(base, x, y), ModBlocks.CHIPPER_PORTAL.getDefaultState(), 3);
}
}
}

View File

@ -13,8 +13,7 @@ import net.minecraft.util.Identifier;
public class ModBlocks {
public static final Block VOID_BLOCK =
Registry.register(
public static final Block VOID_BLOCK = Registry.register(
Registries.BLOCK,
new Identifier(ChipiMod.MOD_ID, "void_block"),
new VoidBlock(
@ -22,36 +21,36 @@ public class ModBlocks {
.strength(-1.0F, 3600000.0F)
.mapColor(MapColor.BLACK)
.dropsNothing()
.pistonBehavior(PistonBehavior.BLOCK)));
.pistonBehavior(PistonBehavior.BLOCK))
);
public static final Block CHIPPER_FRAME =
Registry.register(
public static final Block CHIPPER_FRAME = Registry.register(
Registries.BLOCK,
new Identifier(ChipiMod.MOD_ID, "chipper_frame"),
new ChipperFrameBlock(
FabricBlockSettings.create().strength(3.0f).requiresTool()));
new ChipperFrameBlock(FabricBlockSettings.create().strength(3.0f).requiresTool())
);
public static final Block CHIPPER_PORTAL =
Registry.register(
public static final Block CHIPPER_PORTAL = Registry.register(
Registries.BLOCK,
new Identifier(ChipiMod.MOD_ID, "chipper_portal"),
new ChipperPortalBlock(
FabricBlockSettings.create()
.noCollision()
.luminance(3)
.strength(-1.0f)));
.strength(-1.0f))
);
public static final Block CHIPPER_ORE =
Registry.register(
public static final Block CHIPPER_ORE = Registry.register(
Registries.BLOCK,
new Identifier(ChipiMod.MOD_ID, "chipper_ore"),
new Block(AbstractBlock.Settings.copy(Blocks.IRON_ORE).requiresTool()));
new Block(AbstractBlock.Settings.copy(Blocks.IRON_ORE).requiresTool())
);
public static final Block CHIPPER_ALLOY_BLOCK =
Registry.register(
public static final Block CHIPPER_ALLOY_BLOCK = Registry.register(
Registries.BLOCK,
new Identifier(ChipiMod.MOD_ID, "chipper_alloy_block"),
new Block(AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).requiresTool()));
new Block(AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).requiresTool())
);
public static void register() {}
}

View File

@ -32,7 +32,6 @@ public class VoidBlock extends Block {
}
if (entity instanceof LivingEntity living) {
if (living instanceof PlayerEntity player) {
if (player.isCreative() || player.isSpectator()) {
return;
@ -41,13 +40,9 @@ public class VoidBlock extends Block {
boolean burning = living.isOnFire();
Identifier damageId =
burning
? new Identifier("chipi", "void_block_fire")
: new Identifier("chipi", "void_block");
Identifier damageId = burning ? new Identifier("chipi", "void_block_fire") : new Identifier("chipi", "void_block");
RegistryEntry<DamageType> damageType =
world.getRegistryManager()
RegistryEntry<DamageType> damageType = world.getRegistryManager()
.get(RegistryKeys.DAMAGE_TYPE)
.entryOf(RegistryKey.of(RegistryKeys.DAMAGE_TYPE, damageId));

View File

@ -10,10 +10,7 @@ public class ChipiClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
BlockRenderLayerMap.INSTANCE.putBlock(
ModBlocks.CHIPPER_PORTAL, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.CHIPPER_PORTAL, RenderLayer.getTranslucent());
ModEntityRenderers.register();
}
}

View File

@ -10,8 +10,7 @@ import net.minecraft.util.Identifier;
public class MepRenderer extends BipedEntityRenderer<MepEntity, BipedEntityModel<MepEntity>> {
private static final Identifier TEXTURE =
new Identifier(ChipiMod.MOD_ID, "textures/entity/mep.png");
private static final Identifier TEXTURE = new Identifier(ChipiMod.MOD_ID, "textures/entity/mep.png");
public MepRenderer(EntityRendererFactory.Context ctx) {
super(ctx, new BipedEntityModel<>(ctx.getPart(EntityModelLayers.PLAYER)), 0.5f);

View File

@ -17,7 +17,6 @@ import net.minecraft.util.math.BlockPos;
public class ChpCommand {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(
CommandManager.literal("chp")
.then(
@ -25,29 +24,22 @@ public class ChpCommand {
// autocomplete structure names
.suggests(
(ctx, builder) ->
CommandSource.suggestMatching(
ChipiStructures.getNames(),
builder))
CommandSource.suggestMatching(ChipiStructures.getNames(), builder))
.then(
CommandManager.argument(
"pos",
BlockPosArgumentType.blockPos())
CommandManager.argument("pos", BlockPosArgumentType.blockPos())
// default: no marker
.executes(ctx -> execute(ctx, false))
// optional marker flag
.then(
CommandManager.argument(
"marker",
BoolArgumentType
.bool())
CommandManager.argument("marker", BoolArgumentType.bool())
.executes(
ctx ->
execute(
ctx,
BoolArgumentType
.getBool(
ctx,
"marker")))))));
ctx -> execute(ctx, BoolArgumentType.getBool(ctx, "marker")
)
)
)
)
)
);
}
private static int execute(CommandContext<ServerCommandSource> ctx, boolean marker) {
@ -68,11 +60,7 @@ public class ChpCommand {
structure.placeCommand(world, pos, marker);
source.sendFeedback(
() ->
Text.literal(
"Placed structure '"
+ name
+ (marker ? "' with structure block" : "'")),
() -> Text.literal("Placed structure '" + name + (marker ? "' with structure block" : "'")),
false);
return 1;

View File

@ -11,9 +11,6 @@ public class ModEffects {
public static final StatusEffect CHIPI_BLESSING = new ChipiBlessingEffect();
public static void register() {
Registry.register(
Registries.STATUS_EFFECT,
new Identifier(ChipiMod.MOD_ID, "chipi_blessing"),
CHIPI_BLESSING);
Registry.register(Registries.STATUS_EFFECT, new Identifier(ChipiMod.MOD_ID, "chipi_blessing"), CHIPI_BLESSING);
}
}

View File

@ -11,14 +11,14 @@ import net.minecraft.util.Identifier;
public class ModEntities {
public static final EntityType<MepEntity> MEP =
Registry.register(
public static final EntityType<MepEntity> MEP = Registry.register(
Registries.ENTITY_TYPE,
new Identifier(ChipiMod.MOD_ID, "mep"),
FabricEntityTypeBuilder.createMob()
.entityFactory(MepEntity::new)
.dimensions(EntityDimensions.fixed(0.6f, 1.95f))
.build());
.build()
);
public static void register() {
// called from mod init

View File

@ -42,9 +42,9 @@ public class MepEntity extends PathAwareEntity {
this,
PlayerEntity.class,
true,
target ->
target instanceof PlayerEntity player
&& (angryAtPlayer || !isPlayerProtected(player))));
target -> target instanceof PlayerEntity player && (angryAtPlayer || !isPlayerProtected(player))
)
);
}
public static DefaultAttributeContainer.Builder createMepAttributes() {

View File

@ -4,6 +4,5 @@ import net.minecraft.item.FoodComponent;
public class ModFoodComponents {
public static final FoodComponent NUT =
new FoodComponent.Builder().hunger(4).saturationModifier(0.3f).snack().build();
public static final FoodComponent NUT = new FoodComponent.Builder().hunger(4).saturationModifier(0.3f).snack().build();
}

View File

@ -12,16 +12,13 @@ import net.minecraft.util.Identifier;
public class ModItemGroups {
public static final ItemGroup CHIPI_GROUP =
Registry.register(
public static final ItemGroup CHIPI_GROUP = Registry.register(
Registries.ITEM_GROUP,
new Identifier(ChipiMod.MOD_ID, "chipi"),
FabricItemGroup.builder()
.displayName(Text.translatable("itemGroup.chipi.chipi"))
.icon(() -> new ItemStack(ModBlocks.VOID_BLOCK.asItem()))
.entries(
(context, entries) -> {
.entries((context, entries) -> {
// Blocks
entries.add(ModBlocks.VOID_BLOCK);
entries.add(ModBlocks.CHIPPER_FRAME);
@ -42,7 +39,8 @@ public class ModItemGroups {
entries.add(ModItems.CHIPPER_LEGGINGS);
entries.add(ModItems.CHIPPER_BOOTS);
})
.build());
.build()
);
public static void register() {
// force class load

View File

@ -17,102 +17,90 @@ public class ModItems {
// ===== BLOCK ITEMS =====
public static final Item VOID_BLOCK =
Registry.register(
public static final Item VOID_BLOCK = Registry.register(
Registries.ITEM,
new Identifier(ChipiMod.MOD_ID, "void_block"),
new BlockItem(ModBlocks.VOID_BLOCK, new FabricItemSettings()));
new BlockItem(ModBlocks.VOID_BLOCK, new FabricItemSettings())
);
public static final Item CHIPPER_FRAME =
Registry.register(
public static final Item CHIPPER_FRAME = Registry.register(
Registries.ITEM,
new Identifier(ChipiMod.MOD_ID, "chipper_frame"),
new BlockItem(ModBlocks.CHIPPER_FRAME, new FabricItemSettings()));
new BlockItem(ModBlocks.CHIPPER_FRAME, new FabricItemSettings())
);
public static final Item CHIPPER_PORTAL =
Registry.register(
public static final Item CHIPPER_PORTAL = Registry.register(
Registries.ITEM,
new Identifier(ChipiMod.MOD_ID, "chipper_portal"),
new BlockItem(ModBlocks.CHIPPER_PORTAL, new FabricItemSettings()));
new BlockItem(ModBlocks.CHIPPER_PORTAL, new FabricItemSettings())
);
public static final Item CHIPPER_ORE =
Registry.register(
public static final Item CHIPPER_ORE = Registry.register(
Registries.ITEM,
new Identifier(ChipiMod.MOD_ID, "chipper_ore"),
new BlockItem(ModBlocks.CHIPPER_ORE, new FabricItemSettings()));
new BlockItem(ModBlocks.CHIPPER_ORE, new FabricItemSettings())
);
public static final Item CHIPPER_ALLOY_BLOCK =
Registry.register(
public static final Item CHIPPER_ALLOY_BLOCK = Registry.register(
Registries.ITEM,
new Identifier(ChipiMod.MOD_ID, "chipper_alloy_block"),
new BlockItem(ModBlocks.CHIPPER_ALLOY_BLOCK, new FabricItemSettings()));
new BlockItem(ModBlocks.CHIPPER_ALLOY_BLOCK, new FabricItemSettings())
);
public static final Item MEP_SPAWN_EGG =
Registry.register(
public static final Item MEP_SPAWN_EGG = Registry.register(
Registries.ITEM,
new Identifier(ChipiMod.MOD_ID, "mep_spawn_egg"),
new SpawnEggItem(ModEntities.MEP, 0x1E3A5F, 0x6BB6FF, new Item.Settings()));
new SpawnEggItem(ModEntities.MEP, 0x1E3A5F, 0x6BB6FF, new Item.Settings())
);
// ===== NORMAL ITEMS =====
public static final Item NUT =
Registry.register(
public static final Item NUT = Registry.register(
Registries.ITEM,
new Identifier(ChipiMod.MOD_ID, "nut"),
new Item(new FabricItemSettings().food(ModFoodComponents.NUT)));
new Item(new FabricItemSettings().food(ModFoodComponents.NUT))
);
public static final Item RAW_CHIPPER_ORE =
Registry.register(
public static final Item RAW_CHIPPER_ORE = Registry.register(
Registries.ITEM,
new Identifier(ChipiMod.MOD_ID, "raw_chipper_ore"),
new Item(new FabricItemSettings()));
new Item(new FabricItemSettings())
);
public static final Item CHIPPER_INGOT =
Registry.register(
public static final Item CHIPPER_INGOT = Registry.register(
Registries.ITEM,
new Identifier(ChipiMod.MOD_ID, "chipper_ingot"),
new Item(new FabricItemSettings()));
new Item(new FabricItemSettings())
);
public static final Item CHIPPER_ALLOY =
Registry.register(
public static final Item CHIPPER_ALLOY = Registry.register(
Registries.ITEM,
new Identifier(ChipiMod.MOD_ID, "chipper_alloy"),
new Item(new FabricItemSettings()));
new Item(new FabricItemSettings())
);
public static final Item CHIPPER_HELMET =
Registry.register(
public static final Item CHIPPER_HELMET = Registry.register(
Registries.ITEM,
new Identifier("chipi", "chipper_helmet"),
new ArmorItem(
ChipperArmorMaterial.INSTANCE,
ArmorItem.Type.HELMET,
new Item.Settings()));
new ArmorItem(ChipperArmorMaterial.INSTANCE, ArmorItem.Type.HELMET, new Item.Settings())
);
public static final Item CHIPPER_CHESTPLATE =
Registry.register(
public static final Item CHIPPER_CHESTPLATE = Registry.register(
Registries.ITEM,
new Identifier("chipi", "chipper_chestplate"),
new ArmorItem(
ChipperArmorMaterial.INSTANCE,
ArmorItem.Type.CHESTPLATE,
new Item.Settings()));
new ArmorItem(ChipperArmorMaterial.INSTANCE, ArmorItem.Type.CHESTPLATE, new Item.Settings())
);
public static final Item CHIPPER_LEGGINGS =
Registry.register(
public static final Item CHIPPER_LEGGINGS = Registry.register(
Registries.ITEM,
new Identifier("chipi", "chipper_leggings"),
new ArmorItem(
ChipperArmorMaterial.INSTANCE,
ArmorItem.Type.LEGGINGS,
new Item.Settings()));
new ArmorItem(ChipperArmorMaterial.INSTANCE, ArmorItem.Type.LEGGINGS, new Item.Settings())
);
public static final Item CHIPPER_BOOTS =
Registry.register(
public static final Item CHIPPER_BOOTS = Registry.register(
Registries.ITEM,
new Identifier("chipi", "chipper_boots"),
new ArmorItem(
ChipperArmorMaterial.INSTANCE,
ArmorItem.Type.BOOTS,
new Item.Settings()));
new ArmorItem(ChipperArmorMaterial.INSTANCE, ArmorItem.Type.BOOTS, new Item.Settings())
);
public static void register() {}
}

View File

@ -1,5 +1,6 @@
package net.Chipperfluff.chipi.item.armor;
import net.Chipperfluff.chipi.item.ModItems;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.recipe.Ingredient;
@ -14,15 +15,15 @@ public class ChipperArmorMaterial implements ArmorMaterial {
public static final ChipperArmorMaterial INSTANCE = new ChipperArmorMaterial();
private static final Map<ArmorItem.Type, Integer> PROTECTION =
Util.make(
private static final Map<ArmorItem.Type, Integer> PROTECTION = Util.make(
new EnumMap<>(ArmorItem.Type.class),
map -> {
map.put(ArmorItem.Type.HELMET, 2);
map.put(ArmorItem.Type.CHESTPLATE, 5);
map.put(ArmorItem.Type.LEGGINGS, 4);
map.put(ArmorItem.Type.BOOTS, 2);
});
}
);
@Override
public int getDurability(ArmorItem.Type type) {
@ -46,7 +47,7 @@ public class ChipperArmorMaterial implements ArmorMaterial {
@Override
public Ingredient getRepairIngredient() {
return Ingredient.ofItems(net.Chipperfluff.chipi.item.ModItems.CHIPPER_INGOT);
return Ingredient.ofItems(ModItems.CHIPPER_INGOT);
}
@Override

View File

@ -161,8 +161,7 @@ public class ChipiDungeonGenerator {
runInChipi(world, "fill 5 91 16 5 91 15 minecraft:deepslate_tiles");
}
private static void fillBox(
ServerWorld world, int x1, int y1, int z1, int x2, int y2, int z2, BlockState state) {
private static void fillBox(ServerWorld world, int x1, int y1, int z1, int x2, int y2, int z2, BlockState state) {
int minX = Math.min(x1, x2);
int maxX = Math.max(x1, x2);
int minY = Math.min(y1, y2);
@ -187,8 +186,7 @@ public class ChipiDungeonGenerator {
"execute in chipi:chipi_dimension run " + command);
}
private static DungeonContext ctx(
ServerWorld world, int gridX, int gridY, BlockPos origin, ChipiStructure structure) {
private static DungeonContext ctx(ServerWorld world, int gridX, int gridY, BlockPos origin, ChipiStructure structure) {
return DungeonContext.of(world, gridX, gridY, origin, structure);
}
}

View File

@ -1,8 +1,6 @@
package net.Chipperfluff.chipi.world.gen;
import java.util.Optional;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.StructureBlockBlockEntity;
import net.minecraft.block.enums.StructureBlockMode;
import net.minecraft.server.world.ServerWorld;
@ -11,6 +9,7 @@ import net.minecraft.structure.StructureTemplate;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.block.Blocks;
public abstract class ChipiStructure {
@ -33,23 +32,22 @@ public abstract class ChipiStructure {
return new BlockPos(size.getX(), size.getY(), size.getZ());
}
public void placeAt(ServerWorld world, BlockPos centerPos) {
public void placeAt(ServerWorld world, BlockPos structureOrigin) {
Optional<StructureTemplate> opt = world.getStructureTemplateManager().getTemplate(id);
if (opt.isEmpty()) {
System.out.println("[CHIPI] Missing structure: " + id);
return;
}
BlockPos origin = centerPos.add(deltaX, deltaY, deltaZ);
BlockPos origin = structureOrigin.add(deltaX, deltaY, deltaZ);
opt.get().place(world, origin, origin, new StructurePlacementData(), world.getRandom(), 2);
}
public void placeCommand(ServerWorld world, BlockPos placePos, boolean marker) {
placeAt(world, placePos);
public void placeCommand(ServerWorld world, BlockPos structureOrigin, boolean marker) {
placeAt(world, structureOrigin);
if (!marker) return;
BlockPos origin = placePos.add(deltaX, deltaY, deltaZ);
BlockPos origin = structureOrigin.add(deltaX, deltaY, deltaZ);
world.setBlockState(origin, Blocks.STRUCTURE_BLOCK.getDefaultState(), 3);
if (world.getBlockEntity(origin) instanceof StructureBlockBlockEntity be) {
@ -63,47 +61,7 @@ public abstract class ChipiStructure {
}
}
public BlockPos local(BlockPos centerPos, BlockPos localPos) {
return centerPos.add(deltaX + localPos.getX(), deltaY + localPos.getY(), deltaZ + localPos.getZ());
}
public void setBlock(
ServerWorld world,
BlockPos centerPos,
BlockPos localPos,
BlockState state,
Integer gridX,
Integer gridY) {
BlockPos worldPos = local(centerPos, localPos);
System.out.println(
"[CHIPI] setBlock grid=("
+ gridX
+ ","
+ gridY
+ ") worldPos="
+ worldPos);
world.setBlockState(worldPos, state, 3);
}
public void fillBlocks(
ServerWorld world,
BlockPos centerPos,
BlockPos from,
BlockPos to,
BlockState state,
Integer gridX,
Integer gridY) {
BlockPos start = local(centerPos, from);
BlockPos end = local(centerPos, to);
System.out.println(
"[CHIPI] fillBlocks grid=("
+ gridX
+ ","
+ gridY
+ ") from="
+ start
+ " to="
+ end);
BlockPos.stream(start, end).forEach(pos -> world.setBlockState(pos, state, 3));
public BlockPos localToWorld(BlockPos structureOrigin, BlockPos localPos) {
return structureOrigin.add(deltaX + localPos.getX(), deltaY + localPos.getY(), deltaZ + localPos.getZ());
}
}

View File

@ -1,5 +1,6 @@
package net.Chipperfluff.chipi.world.gen;
import net.minecraft.block.BlockState;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
@ -39,11 +40,20 @@ public final class DungeonContext {
return grid_y;
}
public BlockPos getStructureOrigin() {
return structure_origin;
}
public ChipiStructure getStructure() {
return structure;
}
public void setBlock(BlockPos localPos, BlockState state) {
BlockPos worldPos = structure.localToWorld(structure_origin, localPos);
System.out.println("[CHIPI] setBlock grid=(" + grid_x + "," + grid_y + ") worldPos=" + worldPos);
world.setBlockState(worldPos, state, 3);
}
public void fillBlocks(BlockPos from, BlockPos to, BlockState state) {
BlockPos start = structure.localToWorld(structure_origin, from);
BlockPos end = structure.localToWorld(structure_origin, to);
System.out.println("[CHIPI] fillBlocks grid=(" + grid_x + "," + grid_y + ") from=" + start + " to=" + end);
BlockPos.stream(start, end).forEach(pos -> world.setBlockState(pos, state, 3));
}
}

View File

@ -37,14 +37,7 @@ public final class WorldMaster {
public static RoomBaseStructure afterPlaceRoom(DungeonContext ctx) {
if (ctx.getGridX() == 1 && ctx.getGridY() == 1) {
ctx.getStructure().setBlock(
ctx.getWorld(),
ctx.getStructureOrigin(),
new BlockPos(0, 0, 0),
Blocks.REDSTONE_BLOCK.getDefaultState(),
ctx.getGridX(),
ctx.getGridY()
);
ctx.setBlock(new BlockPos(0, 0, 0), Blocks.REDSTONE_BLOCK.getDefaultState());
}
return getDefaultRoom();