Skip to content

Commit

Permalink
Working, but interim copy.
Browse files Browse the repository at this point in the history
Signed-off-by: smilodon79 <jayaramv2@hexaware.com>
  • Loading branch information
smilodon79 committed Feb 24, 2021
1 parent 5403735 commit dfa1313
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -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 + "'.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand All @@ -34,11 +29,13 @@ public TypedActionResult<ItemStack> 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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"));
Expand Down Expand Up @@ -71,15 +71,16 @@ 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);
}

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);
}
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/assets/lookingglass/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"variants": {
"": {
"model": "minecraft:block/grass"
}
"parent": "minecraft:block/cube_all",
"textures": {
"all": "lookingglass:block/polished_whitestone"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "lookingglass:block/polished_whitestone"
}

0 comments on commit dfa1313

Please sign in to comment.