Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
- Edit translate files.
  - Added new translation keys.
- Added tags: `amulet_of_creation_nether_stage_biomes`, `amulet_of_creation_end_stage_biomes`, `amulet_of_creation_overworld_stage_biomes`, `amulet_of_creation_final_stage_biomes` and `amulet_of_creation_final_stage_dimensions` for change the places where you can improve the amulet of creation.
- Yhe amulet of creation is complete.
- Deleting `BWModelPredicateProviders`.
- Now, if an entity comes in contact with an infected unit, it gets the effect of being infected.
  • Loading branch information
SuperFeda committed Sep 15, 2024
1 parent 64631b7 commit f5bf62c
Show file tree
Hide file tree
Showing 27 changed files with 211 additions and 95 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Automatically build the project and run any configured tests for every push
# and submitted pull request. This can help catch issues that only occur on
# certain platforms or Java versions, and provides a first line of defence
# against bad commits.

name: build
on: [pull_request, push]

jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
21, # Current Java LTS
]
runs-on: ubuntu-22.04
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'microsoft'
- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.skylightmodding;

import com.skylightmodding.misc.BWModelPredicateProviders;

import net.fabricmc.api.ClientModInitializer;

public class BeautifulWorldClient implements ClientModInitializer {

@Override
public void onInitializeClient() {
BWModelPredicateProviders.register();

}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@
@Mixin(MinecraftClient.class)
public class ExampleClientMixin {
@Inject(at = @At("HEAD"), method = "run")
private void init(CallbackInfo info) {
// This code is injected into the start of MinecraftClient.run()V
}
private void init(CallbackInfo info) {}
}
2 changes: 1 addition & 1 deletion src/main/java/com/skylightmodding/BeautifulWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void onInitialize() {
.frameBlock(BWBlocks.FORTIFIED_CRYING_OBSIDIAN.getBlock())
.destDimID(Identifier.of(MOD_ID, "beautiful_world"))
.customPortalBlock(BWBlocks.BW_PORTAL_BLOCK)
.lightWithItem(BWItems.AMULET_OF_CREATION) // todo: сделать так, чтобы для активации использовался AMULET_OF_CREATION с STAGE_LVL == 2.
.lightWithItem(BWItems.AMULET_OF_CREATION) // todo: сделать так, чтобы для активации использовался AMULET_OF_CREATION с AMULET_OF_CREATION_STAGE == 2.
/*
Ооо бля, я придумал как эту проблему (из to_do выше) решить можно. Надо сделать миксин метода `lightWithItem`, туда просто запихать проверку: является ли
предмет AMULET_OF_CREATION и == ли его дата компонент `amulet_of_creation_stage` двум, если да, то активировать портал, иначе fuck you leather man.
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/skylightmodding/blocks/InfectedBlock.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
package com.skylightmodding.blocks;

import com.skylightmodding.init.BWStatusEffects;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.world.BlockView;

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

@Override
public void onEntityLand(BlockView world, Entity entity) {
super.onEntityLand(world, entity);
LivingEntity living = (LivingEntity) entity;
if (!living.hasStatusEffect(BWStatusEffects.IMMUNITY)) {
living.addStatusEffect(new StatusEffectInstance(BWStatusEffects.INFECTION, 1200, 0));
}
}

// TODO: Сделать возможность распространения
}
2 changes: 1 addition & 1 deletion src/main/java/com/skylightmodding/init/BWBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
@Override
@Environment(EnvType.CLIENT)
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
if (random.nextInt(100) == 0) {
if (random.nextInt(99) == 0) {
world.playSound((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, random.nextFloat() * 0.4F + 0.8F, false);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/skylightmodding/init/BWItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.skylightmodding.BeautifulWorld;
import com.skylightmodding.items.*;
import com.skylightmodding.items.types.*;
import com.skylightmodding.items.components.BWFoodComponents;
import com.skylightmodding.items.components.ToolModifications;
import com.skylightmodding.items.types.*;
import com.skylightmodding.items.components.BWArmorMaterial;
import com.skylightmodding.items.components.BWToolMaterials;

Expand Down Expand Up @@ -90,7 +90,7 @@ public class BWItems {
@Override
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
super.postHit(stack, target, attacker);
ToolModifications.torchTheEnemy(6, target);
ToolModifications.torchTheEnemy((byte)6, target);

return true;
}
Expand Down Expand Up @@ -129,7 +129,7 @@ public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attack
);
public static final Item AMULET_OF_CREATION = registerItem(
"amulet_of_creation",
new AmuletOfCreation(new Item.Settings().maxCount(1).rarity(Rarity.EPIC).component(BWDataComponents.AMULET_OF_CREATION_STAGE, 0))
new AmuletOfCreation(new Item.Settings().maxCount(1).rarity(Rarity.EPIC))
);


Expand Down
51 changes: 36 additions & 15 deletions src/main/java/com/skylightmodding/items/AmuletOfCreation.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
package com.skylightmodding.items;

import com.skylightmodding.BeautifulWorld;
import com.skylightmodding.init.BWDataComponents;
import com.skylightmodding.worldgen.dimensions.BeautifulWorldDim;
import com.skylightmodding.misc.BWTags;

import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.CustomModelDataComponent;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.StackReference;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.Text;
import net.minecraft.util.ClickType;
import net.minecraft.util.Formatting;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeKeys;

import java.util.List;

Expand All @@ -27,14 +24,36 @@ public AmuletOfCreation(Item.Settings settings) {
super(settings);
}

@Override
public ItemStack getDefaultStack() {
ItemStack stack = super.getDefaultStack();
stack.set(BWDataComponents.AMULET_OF_CREATION_STAGE, 0);
stack.set(DataComponentTypes.CUSTOM_MODEL_DATA, CustomModelDataComponent.DEFAULT);
return stack;
}

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
ItemStack itemStack = user.getStackInHand(hand);
RegistryEntry<Biome> biome = world.getBiome(user.getBlockPos());

if (world.isClient()) {return TypedActionResult.success(itemStack);}
if (world.isClient()) { return TypedActionResult.success(itemStack); }

int stage = itemStack.getOrDefault(BWDataComponents.AMULET_OF_CREATION_STAGE, 0);
itemStack.set(BWDataComponents.AMULET_OF_CREATION_STAGE, stage == 4 ? stage : ++stage);

if (stage == 4) { return TypedActionResult.success(itemStack); }

if (stage == 0 && biome.isIn(BWTags.Biomes.AMULET_OF_CREATION_NETHER_STAGE_BIOMES)) {
++stage;
} else if (stage == 1 && biome.isIn(BWTags.Biomes.AMULET_OF_CREATION_END_STAGE_BIOMES)) {
++stage;
} else if (stage == 2 && biome.isIn(BWTags.Biomes.AMULET_OF_CREATION_OVERWORLD_STAGE_BIOMES)) {
++stage;
} else if (stage == 3 && biome.isIn(BWTags.Biomes.AMULET_OF_CREATION_FINAL_STAGE_BIOMES) && world.getDimensionEntry().isIn(BWTags.DimensionTypes.AMULET_OF_CREATION_FINAL_STAGE_DIMENSIONS)) {
++stage;
}
itemStack.set(BWDataComponents.AMULET_OF_CREATION_STAGE, stage);
itemStack.set(DataComponentTypes.CUSTOM_MODEL_DATA, new CustomModelDataComponent(stage));

return TypedActionResult.success(itemStack);
}
Expand All @@ -44,12 +63,14 @@ public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> to
tooltip.add(Text.translatable("tooltip.beautifulworld.amulet_of_creation", stageConv(stack.getOrDefault(BWDataComponents.AMULET_OF_CREATION_STAGE, 0))).formatted(Formatting.GOLD));
}

private String stageConv(int stage) {
if (stage == 0) { return "\"Null\""; }
else if (stage == 1) { return "\"Nether\""; }
else if (stage == 2) { return "\"End\""; }
else if (stage == 3) { return "\"Overworld\""; }
else if (stage == 4) { return "\"Sculk\""; }
return "ERROR";
private Text stageConv(int stage) {
return switch (stage) {
case 0 -> Text.translatable("item.beautifulworld.amulet_of_creation.stage.void");
case 1 -> Text.translatable("item.beautifulworld.amulet_of_creation.stage.nether");
case 2 -> Text.translatable("item.beautifulworld.amulet_of_creation.stage.end");
case 3 -> Text.translatable("item.beautifulworld.amulet_of_creation.stage.overworld");
case 4 -> Text.translatable("item.beautifulworld.amulet_of_creation.stage.sculk");
default -> Text.translatable("item.beautifulworld.amulet_of_creation.stage.error");
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {

@Override
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
tooltip.add(Text.translatable("tooltip.beautifulworld.baikal_water").formatted(Formatting.GRAY));
tooltip.add(Text.translatable("tooltip.beautifulworld.only_for_creative").formatted(Formatting.GRAY));
}

public int getMaxUseTime(ItemStack stack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static void blockSmelting(World world, BlockState state, BlockPos pos, It
isSmelting = true;
serverWorld.spawnParticles(ParticleTypes.FLAME, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, 20, 0.15D, 0.25D, 0.15D, 0.035f);
serverWorld.playSound(null, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.4F, 2.6F);
for (int i = 0; i < inputList.getFirst().getCount(); i++) {
for (byte i = 0; i < inputList.getFirst().getCount(); i++) {
Block.dropStack(world, pos, result);
}
}
Expand All @@ -87,7 +87,7 @@ public static void blockSmelting(World world, BlockState state, BlockPos pos, It


/** Поджигание атакуемых мобов */
public static void torchTheEnemy(int seconds, LivingEntity enemy) {
public static void torchTheEnemy(byte seconds, LivingEntity enemy) {
if (!enemy.isFireImmune()) {
enemy.setOnFireFor(seconds);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.skylightmodding.items.types;

import com.skylightmodding.BeautifulWorld;

import net.minecraft.item.SmithingTemplateItem;
import net.minecraft.resource.featuretoggle.FeatureFlag;
import net.minecraft.text.Text;
Expand All @@ -11,8 +12,8 @@
import java.util.List;

public class BWSmithingTemplateItem extends SmithingTemplateItem {
private static final Formatting TITLE_FORMATTING;
private static final Formatting DESCRIPTION_FORMATTING;
private static final Formatting TITLE_FORMATTING = Formatting.GRAY;
private static final Formatting DESCRIPTION_FORMATTING = Formatting.BLUE;

private static final Identifier EMPTY_ARMOR_SLOT_HELMET_TEXTURE;
private static final Identifier EMPTY_ARMOR_SLOT_CHESTPLATE_TEXTURE;
Expand All @@ -36,21 +37,28 @@ public BWSmithingTemplateItem(Text appliesToText, Text ingredientsText, Text tit
}

public static BWSmithingTemplateItem createOverloudUpgrade() {
return new BWSmithingTemplateItem(OVERLOUD_UPGRADE_APPLIES_TO_TEXT, OVERLOUD_UPGRADE_INGREDIENTS_TEXT, OVERLOUD_UPGRADE_TEXT, OVERLOUD_UPGRADE_BASE_SLOT_DESCRIPTION_TEXT, OVERLOUD_UPGRADE_ADDITIONS_SLOT_DESCRIPTION_TEXT, getOverloudUpgradeEmptyBaseSlotTextures(), getOverloudUpgradeEmptyAdditionsSlotTextures(), new FeatureFlag[0]);
}

private static List<Identifier> getOverloudUpgradeEmptyBaseSlotTextures() {
return List.of(EMPTY_ARMOR_SLOT_HELMET_TEXTURE, EMPTY_SLOT_SWORD_TEXTURE, EMPTY_ARMOR_SLOT_CHESTPLATE_TEXTURE, EMPTY_SLOT_PICKAXE_TEXTURE, EMPTY_ARMOR_SLOT_LEGGINGS_TEXTURE, EMPTY_SLOT_AXE_TEXTURE, EMPTY_ARMOR_SLOT_BOOTS_TEXTURE, EMPTY_SLOT_HOE_TEXTURE, EMPTY_SLOT_SHOVEL_TEXTURE);
}

private static List<Identifier> getOverloudUpgradeEmptyAdditionsSlotTextures() {
return List.of(EMPTY_SLOT_INGOT_TEXTURE);
return new BWSmithingTemplateItem(
OVERLOUD_UPGRADE_APPLIES_TO_TEXT,
OVERLOUD_UPGRADE_INGREDIENTS_TEXT,
OVERLOUD_UPGRADE_TEXT,
OVERLOUD_UPGRADE_BASE_SLOT_DESCRIPTION_TEXT,
OVERLOUD_UPGRADE_ADDITIONS_SLOT_DESCRIPTION_TEXT,
List.of(
EMPTY_ARMOR_SLOT_HELMET_TEXTURE,
EMPTY_SLOT_SWORD_TEXTURE,
EMPTY_ARMOR_SLOT_CHESTPLATE_TEXTURE,
EMPTY_SLOT_PICKAXE_TEXTURE,
EMPTY_ARMOR_SLOT_LEGGINGS_TEXTURE,
EMPTY_SLOT_AXE_TEXTURE,
EMPTY_ARMOR_SLOT_BOOTS_TEXTURE,
EMPTY_SLOT_HOE_TEXTURE,
EMPTY_SLOT_SHOVEL_TEXTURE
),
List.of(EMPTY_SLOT_INGOT_TEXTURE)
);
}

static {
TITLE_FORMATTING = Formatting.GRAY;
DESCRIPTION_FORMATTING = Formatting.BLUE;

OVERLOUD_UPGRADE_TEXT = Text.translatable(Util.createTranslationKey("upgrade", Identifier.of(BeautifulWorld.MOD_ID, "overloud_upgrade"))).formatted(TITLE_FORMATTING);
OVERLOUD_UPGRADE_APPLIES_TO_TEXT = Text.translatable(Util.createTranslationKey("item", Identifier.of(BeautifulWorld.MOD_ID, "smithing_template.overloud_upgrade.applies_to"))).formatted(DESCRIPTION_FORMATTING);
OVERLOUD_UPGRADE_INGREDIENTS_TEXT = Text.translatable(Util.createTranslationKey("item", Identifier.of(BeautifulWorld.MOD_ID, "smithing_template.overloud_upgrade.ingredients"))).formatted(DESCRIPTION_FORMATTING);
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/skylightmodding/misc/BWTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.dimension.DimensionOptions;
import net.minecraft.world.dimension.DimensionType;

public class BWTags {
public static class Blocks {
Expand All @@ -32,9 +34,21 @@ private static TagKey<Item> createTag(String name) {
public static class Biomes {
public static final TagKey<Biome> OVERLOUD_ORE_GEN_BIOMES = createTag("overloud_ore_gen_biomes");
public static final TagKey<Biome> RHODIUM_ORE_GEN_BIOMES = createTag("rhodium_ore_gen_biomes");
public static final TagKey<Biome> AMULET_OF_CREATION_NETHER_STAGE_BIOMES = createTag("amulet_of_creation_nether_stage_biomes");
public static final TagKey<Biome> AMULET_OF_CREATION_END_STAGE_BIOMES = createTag("amulet_of_creation_end_stage_biomes");
public static final TagKey<Biome> AMULET_OF_CREATION_OVERWORLD_STAGE_BIOMES = createTag("amulet_of_creation_overworld_stage_biomes");
public static final TagKey<Biome> AMULET_OF_CREATION_FINAL_STAGE_BIOMES = createTag("amulet_of_creation_final_stage_biomes");

private static TagKey<Biome> createTag(String name) {
return TagKey.of(RegistryKeys.BIOME, Identifier.of(BeautifulWorld.MOD_ID, name));
}
}

public static class DimensionTypes {
public static final TagKey<DimensionType> AMULET_OF_CREATION_FINAL_STAGE_DIMENSIONS = createTag("amulet_of_creation_final_stage_dimensions");

private static TagKey<DimensionType> createTag(String name) {
return TagKey.of(RegistryKeys.DIMENSION_TYPE, Identifier.of(BeautifulWorld.MOD_ID, name));
}
}
}
15 changes: 14 additions & 1 deletion src/main/resources/assets/beautifulworld/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,20 @@
"item.beautifulworld.rhodium_sword": "Rhodium Sword",
"item.beautifulworld.rhodium_multitool": "Rhodium Multi-Tool",
"item.beautifulworld.pitahaya": "Pitahaya",
"item.beautifulworld.amulet_of_creation": "Amulet of Creation",
"item.beautifulworld.crystallite_axe": "Crystallite axe",
"item.beautifulworld.crystallite_shovel": "Crystallite shovel",
"item.beautifulworld.crystallite_pickaxe": "Crystallite pickaxe",

"tooltip.beautifulworld.baikal_water": "Only for Creative",
"item.beautifulworld.amulet_of_creation.stage.void": "Void",
"item.beautifulworld.amulet_of_creation.stage.nether": "Nether",
"item.beautifulworld.amulet_of_creation.stage.end": "End",
"item.beautifulworld.amulet_of_creation.stage.overworld": "Overworld",
"item.beautifulworld.amulet_of_creation.stage.sculk": "Sculk",
"item.beautifulworld.amulet_of_creation.stage.error": "ERROR",

"tooltip.beautifulworld.amulet_of_creation": "Stage: %s",
"tooltip.beautifulworld.only_for_creative": "Only for Creative",

"block.beautifulworld.overloud_block": "Overloud Block",
"block.beautifulworld.raw_overloud_block": "Raw Overloud Block",
Expand All @@ -46,6 +58,7 @@
"block.beautifulworld.pitahaya_tree_stairs": "Pitahaya Tree Stairs",
"block.beautifulworld.pitahaya_tree_trapdoor": "Pitahaya Tree Trapdoor",
"block.beautifulworld.pitahaya_tree_door": "Pitahaya Tree Door",
"block.beautifulworld.fortified_crying_obsidian": "Fortified crying obsidian",

"effect.beautifulworld.immunity": "Immunity",
"effect.beautifulworld.infection": "Infection",
Expand Down
Loading

0 comments on commit f5bf62c

Please sign in to comment.