From dfa131336364d10539d5ae7129bf13ff05be3b0c Mon Sep 17 00:00:00 2001 From: smilodon79 Date: Wed, 24 Feb 2021 17:53:28 -0500 Subject: [PATCH] Working, but interim copy. Signed-off-by: smilodon79 --- .../fabric/lookingglass/block/CursedEarthBlock.java | 11 ++++++++++- .../fabric/lookingglass/block/LookingGlassBlocks.java | 2 +- .../lookingglass/item/AdvancedAngelRingItem.java | 11 ++++------- .../azzy/fabric/lookingglass/item/AngelBlockItem.java | 4 ++-- .../lookingglass/item/CursedEarthBlockItem.java | 11 +++++++++++ .../fabric/lookingglass/item/LookingGlassItems.java | 7 ++++--- .../resources/assets/lookingglass/lang/en_us.json | 1 - .../lookingglass/models/block/cursed_earth.json | 7 +++---- .../assets/lookingglass/models/item/cursed_earth.json | 3 +++ 9 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 src/main/java/azzy/fabric/lookingglass/item/CursedEarthBlockItem.java create mode 100644 src/main/resources/assets/lookingglass/models/item/cursed_earth.json diff --git a/src/main/java/azzy/fabric/lookingglass/block/CursedEarthBlock.java b/src/main/java/azzy/fabric/lookingglass/block/CursedEarthBlock.java index 779be0d..b3a6940 100644 --- a/src/main/java/azzy/fabric/lookingglass/block/CursedEarthBlock.java +++ b/src/main/java/azzy/fabric/lookingglass/block/CursedEarthBlock.java @@ -1,15 +1,24 @@ package azzy.fabric.lookingglass.block; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.minecraft.block.BlockState; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; +import java.util.Random; + public class CursedEarthBlock extends LookingGlassBlock { public CursedEarthBlock(FabricBlockSettings settings) { super(settings, false); } - protected void doTick(ServerWorld world,BlockPos pos, boolean fastSpreading) { + @Override + public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + if (!world.isClient) + doTick(world, pos, true); + } + + protected void doTick(ServerWorld world, BlockPos pos, boolean fastSpreading) { int light = world.getLightLevel(pos.up()); System.out.println("Reached here...: '" + light + "'."); } diff --git a/src/main/java/azzy/fabric/lookingglass/block/LookingGlassBlocks.java b/src/main/java/azzy/fabric/lookingglass/block/LookingGlassBlocks.java index 0183b3c..058f75b 100644 --- a/src/main/java/azzy/fabric/lookingglass/block/LookingGlassBlocks.java +++ b/src/main/java/azzy/fabric/lookingglass/block/LookingGlassBlocks.java @@ -146,7 +146,7 @@ private static FabricBlockSettings eldenMachine() { public static final Block ELDENMETAL_BLOCK = registerBlock("eldenmetal_block", new Block(FabricBlockSettings.copyOf(Blocks.OBSIDIAN).luminance(state -> 3).nonOpaque().sounds(LookingGlassSounds.ELDENMETAL)), basicItem().fireproof().rarity(ELDENMETAL_RARITY)); public static final Block SALMON_EGGS = registerBlock("salmon_egg", new SalmonEggBlock(FabricBlockSettings.copyOf(Blocks.TURTLE_EGG).sounds(BlockSoundGroup.HONEY).ticksRandomly()), basicItem()); public static final Block ANGEL_BLOCK = Registry.register(Registry.BLOCK, new Identifier(MODID, "angel_block"), new AngelBlock(FabricBlockSettings.copyOf(Blocks.DIRT).breakInstantly())); - public static final Block CURSED_EARTH_BLOCK = registerBlock("cursed_earth", new CursedEarthBlock(FabricBlockSettings.copyOf(Blocks.GRASS_BLOCK).strength(50f, 1200f).breakInstantly().ticksRandomly()), basicItem()); + public static final Block CURSED_EARTH_BLOCK = Registry.register(Registry.BLOCK, new Identifier(MODID, "cursed_earth"), new CursedEarthBlock(FabricBlockSettings.copyOf(Blocks.GRASS_BLOCK).ticksRandomly())); // BLOCK ENTITIES //Machines diff --git a/src/main/java/azzy/fabric/lookingglass/item/AdvancedAngelRingItem.java b/src/main/java/azzy/fabric/lookingglass/item/AdvancedAngelRingItem.java index 58c1eb7..00e903c 100644 --- a/src/main/java/azzy/fabric/lookingglass/item/AdvancedAngelRingItem.java +++ b/src/main/java/azzy/fabric/lookingglass/item/AdvancedAngelRingItem.java @@ -4,15 +4,11 @@ import io.github.ladysnake.pal.AbilitySource; import io.github.ladysnake.pal.Pal; import io.github.ladysnake.pal.VanillaAbilities; -import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.network.MessageType; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; -import net.minecraft.util.Util; import net.minecraft.world.World; // This Ring will have an expensive recipe. This is really not a ring. It's an item that on use, rewards the user with creative flight - forever. @@ -21,7 +17,6 @@ // For a simpler item that gives creative flight on equip, check out the SimpleAngelRing class. public class AdvancedAngelRingItem extends Item { public static final AbilitySource ADVANCED_ANGEL_RING_ABILITY_SOURCE = Pal.getAbilitySource(LookingGlassCommon.MODID, "advanced_angel_ring"); - private static final MinecraftClient client = MinecraftClient.getInstance(); public AdvancedAngelRingItem(Settings settings) { super(settings); @@ -34,11 +29,13 @@ public TypedActionResult use(World world, PlayerEntity user, Hand han if (ADVANCED_ANGEL_RING_ABILITY_SOURCE.grants(user, VanillaAbilities.ALLOW_FLYING)) { // If the item is giving flight, remove it. ADVANCED_ANGEL_RING_ABILITY_SOURCE.revokeFrom(user, VanillaAbilities.ALLOW_FLYING); - client.inGameHud.addChatMessage(MessageType.GAME_INFO, new TranslatableText("item.lookingglass.angelRing.flightDisabled"), Util.NIL_UUID); + // TODO: Message to client HUD via networking. +// client.inGameHud.addChatMessage(MessageType.GAME_INFO, new TranslatableText("item.lookingglass.angelRing.flightDisabled"), Util.NIL_UUID); } else { // Otherwise, grant it. ADVANCED_ANGEL_RING_ABILITY_SOURCE.grantTo(user, VanillaAbilities.ALLOW_FLYING); - client.inGameHud.addChatMessage(MessageType.GAME_INFO, new TranslatableText("item.lookingglass.angelRing.flightEnabled"), Util.NIL_UUID); + // TODO: Message to client HUD via networking. +// client.inGameHud.addChatMessage(MessageType.GAME_INFO, new TranslatableText("item.lookingglass.angelRing.flightEnabled"), Util.NIL_UUID); } } diff --git a/src/main/java/azzy/fabric/lookingglass/item/AngelBlockItem.java b/src/main/java/azzy/fabric/lookingglass/item/AngelBlockItem.java index 9c970a3..0e7ad90 100644 --- a/src/main/java/azzy/fabric/lookingglass/item/AngelBlockItem.java +++ b/src/main/java/azzy/fabric/lookingglass/item/AngelBlockItem.java @@ -2,10 +2,10 @@ import azzy.fabric.lookingglass.block.LookingGlassBlocks; import com.jamieswhiteshirt.reachentityattributes.ReachEntityAttributes; +import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.minecraft.block.Block; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; @@ -15,7 +15,7 @@ import net.minecraft.world.World; public class AngelBlockItem extends BlockItem { - public AngelBlockItem(Block angelBlock, Item.Settings angelBlockSettings) { + public AngelBlockItem(Block angelBlock, FabricItemSettings angelBlockSettings) { super(angelBlock, angelBlockSettings); } diff --git a/src/main/java/azzy/fabric/lookingglass/item/CursedEarthBlockItem.java b/src/main/java/azzy/fabric/lookingglass/item/CursedEarthBlockItem.java new file mode 100644 index 0000000..4750eb3 --- /dev/null +++ b/src/main/java/azzy/fabric/lookingglass/item/CursedEarthBlockItem.java @@ -0,0 +1,11 @@ +package azzy.fabric.lookingglass.item; + +import net.fabricmc.fabric.api.item.v1.FabricItemSettings; +import net.minecraft.block.Block; +import net.minecraft.item.BlockItem; + +public class CursedEarthBlockItem extends BlockItem { + public CursedEarthBlockItem(Block cursedEarthBlock, FabricItemSettings fabricItemSettings) { + super(cursedEarthBlock, fabricItemSettings); + } +} \ No newline at end of file diff --git a/src/main/java/azzy/fabric/lookingglass/item/LookingGlassItems.java b/src/main/java/azzy/fabric/lookingglass/item/LookingGlassItems.java index bb84476..0bacbe7 100644 --- a/src/main/java/azzy/fabric/lookingglass/item/LookingGlassItems.java +++ b/src/main/java/azzy/fabric/lookingglass/item/LookingGlassItems.java @@ -12,7 +12,6 @@ import net.minecraft.entity.effect.StatusEffects; import net.minecraft.item.FoodComponent; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.util.Identifier; import net.minecraft.util.Rarity; import net.minecraft.util.registry.Registry; @@ -30,6 +29,7 @@ public class LookingGlassItems { private static FabricItemSettings defaultSettings() { return new FabricItemSettings().group(LOOKINGGLASS_ITEMS); } + public static void init() { //TrinketSlots.addSlot(SlotGroups.HAND, Slots.RING, new Identifier("trinkets", "textures/item/empty_trinket_slot_ring.png")); TrinketSlots.addSlot(SlotGroups.OFFHAND, Slots.RING, new Identifier("trinkets", "textures/item/empty_trinket_slot_ring.png")); @@ -71,7 +71,8 @@ private static FabricItemSettings eldenmetalSettings() { public static final Item PRISMATIC_SHIMMERFIN = registerItem("shimmerfin", new FishWeaponItem(true, 199, defaultSettings().rarity(WORLDFORGE_RARITY).fireproof().food(SHIMMERFIN))); //Registry shenanigans - public static final Item ANGEL_BLOCK = registerItem("angel_block", new AngelBlockItem(LookingGlassBlocks.ANGEL_BLOCK, new FabricItemSettings().group(LOOKINGGLASS_BLOCKS).fireproof().maxCount(64))); + public static final Item ANGEL_BLOCK = registerItem("angel_block", new AngelBlockItem(LookingGlassBlocks.ANGEL_BLOCK, new FabricItemSettings().group(LOOKINGGLASS_BLOCKS).fireproof())); + public static final Item CURSED_EARTH_BLOCK = registerItem("cursed_earth", new CursedEarthBlockItem(LookingGlassBlocks.CURSED_EARTH_BLOCK, new FabricItemSettings().group(LOOKINGGLASS_BLOCKS))); private static Item registerItem(String name, Item item) { return Registry.register(Registry.ITEM, new Identifier(MODID, name), item); @@ -79,7 +80,7 @@ private static Item registerItem(String name, Item item) { private static Item registerGeneratedItem(String name, Item item) { Identifier id = new Identifier(MODID, name); - if(REGEN_ITEMS) + if (REGEN_ITEMS) ModelJsonGen.genItemJson(METADATA, id); return Registry.register(Registry.ITEM, id, item); } diff --git a/src/main/resources/assets/lookingglass/lang/en_us.json b/src/main/resources/assets/lookingglass/lang/en_us.json index 71b3413..276c818 100644 --- a/src/main/resources/assets/lookingglass/lang/en_us.json +++ b/src/main/resources/assets/lookingglass/lang/en_us.json @@ -70,7 +70,6 @@ "block.lookingglass.whitestone": "Whitestone", "block.lookingglass.whitestone_tile": "Whitestone Tile", "block.lookingglass.angel_block": "Angel Block", - "item.lookingglass.angel_block": "Angel Block", "item.lookingglass.": "", "item.lookingglass.data_shard": "Data Shard", "item.lookingglass.energy_probe": "Lumen Resonator", diff --git a/src/main/resources/assets/lookingglass/models/block/cursed_earth.json b/src/main/resources/assets/lookingglass/models/block/cursed_earth.json index e45466e..5d55b27 100644 --- a/src/main/resources/assets/lookingglass/models/block/cursed_earth.json +++ b/src/main/resources/assets/lookingglass/models/block/cursed_earth.json @@ -1,7 +1,6 @@ { - "variants": { - "": { - "model": "minecraft:block/grass" - } + "parent": "minecraft:block/cube_all", + "textures": { + "all": "lookingglass:block/polished_whitestone" } } \ No newline at end of file diff --git a/src/main/resources/assets/lookingglass/models/item/cursed_earth.json b/src/main/resources/assets/lookingglass/models/item/cursed_earth.json new file mode 100644 index 0000000..ee25722 --- /dev/null +++ b/src/main/resources/assets/lookingglass/models/item/cursed_earth.json @@ -0,0 +1,3 @@ +{ + "parent": "lookingglass:block/polished_whitestone" +} \ No newline at end of file