From 645460f66342ea8e0468f845e6c6fa4d39753d42 Mon Sep 17 00:00:00 2001 From: Unix Date: Thu, 13 Jun 2024 10:59:40 -0500 Subject: [PATCH] initial builders stone --- .../assets/alchemist/lang/en_us.json | 1 + .../content/AlchemistItems.java | 6 +- .../unix_supremacist/interfaces/AreaBox.java | 34 +++++++++ .../item/AlchemistBlockItem.java | 9 --- .../unix_supremacist/item/BuildersStone.java | 65 ++++++++++++++++++ .../unix_supremacist/item/GaleItem.java | 3 +- .../alchemist/models/item/builders_stone.json | 6 ++ .../textures/item/builders_stone.png | Bin 0 -> 240 bytes src/main/resources/assets/spritesheet.ase | Bin 2444 -> 2552 bytes 9 files changed, 110 insertions(+), 14 deletions(-) create mode 100644 src/main/java/io/github/unix_supremacist/item/BuildersStone.java create mode 100644 src/main/resources/assets/alchemist/models/item/builders_stone.json create mode 100644 src/main/resources/assets/alchemist/textures/item/builders_stone.png diff --git a/src/main/generated/assets/alchemist/lang/en_us.json b/src/main/generated/assets/alchemist/lang/en_us.json index b8b3632..2b09f89 100644 --- a/src/main/generated/assets/alchemist/lang/en_us.json +++ b/src/main/generated/assets/alchemist/lang/en_us.json @@ -2,6 +2,7 @@ "block.alchemist.transmutation_circle": "Transmutation Circle", "item.alchemist.aeternalis_fuel": "Aeternalis Fuel", "item.alchemist.alchemical_coal": "Alchemical Coal", + "item.alchemist.builders_stone": "Builders Stone", "item.alchemist.catalytic_lens": "Catalytic Lens", "item.alchemist.chalk": "Chalk", "item.alchemist.coal_coke": "Coal Coke", diff --git a/src/main/java/io/github/unix_supremacist/content/AlchemistItems.java b/src/main/java/io/github/unix_supremacist/content/AlchemistItems.java index d510413..c6c903b 100644 --- a/src/main/java/io/github/unix_supremacist/content/AlchemistItems.java +++ b/src/main/java/io/github/unix_supremacist/content/AlchemistItems.java @@ -2,10 +2,7 @@ import eu.pb4.factorytools.api.item.ModeledItem; import io.github.unix_supremacist.Alchemist; -import io.github.unix_supremacist.item.AlchemistBlockItem; -import io.github.unix_supremacist.item.DestructionItem; -import io.github.unix_supremacist.item.GaleItem; -import io.github.unix_supremacist.item.PhilosophersStoneItem; +import io.github.unix_supremacist.item.*; import lombok.Getter; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.fabricmc.fabric.api.registry.FuelRegistry; @@ -23,6 +20,7 @@ public enum AlchemistItems { aeternalis_fuel(1638400, Items.NETHERITE_SCRAP), //archangels_smite, //black_hole_band, + builders_stone(new BuildersStone(new Properties().stacksTo(1).durability(16),4,4)), catalytic_lens(new DestructionItem(new Properties().stacksTo(1).durability(30), 3, 10, 5, Items.GOLD_NUGGET)), chalk(new AlchemistBlockItem(AlchemistBlocks.transmutation_circle.getBlock(), new Properties().durability(64), Items.STICK)), coal_coke(3200, Items.COOKED_BEEF), diff --git a/src/main/java/io/github/unix_supremacist/interfaces/AreaBox.java b/src/main/java/io/github/unix_supremacist/interfaces/AreaBox.java index 286ce56..ac6ac0f 100644 --- a/src/main/java/io/github/unix_supremacist/interfaces/AreaBox.java +++ b/src/main/java/io/github/unix_supremacist/interfaces/AreaBox.java @@ -36,4 +36,38 @@ default ArrayList getAreaFromFacing(Direction dir, BlockPos anchor, in return null; } } + + default ArrayList getAreaFromFacing(Direction dir, Direction playerDir, BlockPos anchor, int width, int height, int depth){ + switch(dir) { + case SOUTH: + return getArea(dir, anchor, new BlockPos(-width, -height, -depth), new BlockPos(width, height, 0)); + case NORTH: + return getArea(dir, anchor, new BlockPos(-width, -height, 0), new BlockPos(width, height, depth)); + case EAST: + return getArea(dir, anchor, new BlockPos(-depth, -height, -width), new BlockPos(0, height, width)); + case WEST: + return getArea(dir, anchor, new BlockPos(0, -height, -width), new BlockPos(depth, height, width)); + case UP: + switch (playerDir){ + case SOUTH: + case NORTH: + return getArea(dir, anchor, new BlockPos(-width, -depth, -height), new BlockPos(width, 0, height)); + case EAST: + case WEST: + return getArea(dir, anchor, new BlockPos(-height, -depth, -width), new BlockPos(height, 0, width)); + } + case DOWN: + switch (playerDir){ + case SOUTH: + case NORTH: + return getArea(dir, anchor, new BlockPos(-width, 0, -height), new BlockPos(width, depth, height)); + case EAST: + case WEST: + return getArea(dir, anchor, new BlockPos(-height, 0, -width), new BlockPos(height, depth, width)); + } + default: + Alchemist.LOGGER.error("HOW DID YOU CLICK A DIRECTION THAT ISN'T NORTH SOUTH EAST WEST TOP OR BOTTOM"); + return null; + } + } } diff --git a/src/main/java/io/github/unix_supremacist/item/AlchemistBlockItem.java b/src/main/java/io/github/unix_supremacist/item/AlchemistBlockItem.java index a7de4d5..17e2e2d 100644 --- a/src/main/java/io/github/unix_supremacist/item/AlchemistBlockItem.java +++ b/src/main/java/io/github/unix_supremacist/item/AlchemistBlockItem.java @@ -1,15 +1,8 @@ package io.github.unix_supremacist.item; import eu.pb4.factorytools.api.item.AutoModeledPolymerItem; -import eu.pb4.factorytools.api.item.FactoryBlockItem; -import io.github.unix_supremacist.block.TransmutionCircleBlock; -import io.github.unix_supremacist.content.AlchemistItems; import lombok.Getter; import net.minecraft.core.BlockPos; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.network.protocol.game.ClientboundSoundPacket; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.BlockItem; @@ -19,8 +12,6 @@ import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.phys.Vec3; public class AlchemistBlockItem extends BlockItem implements AutoModeledPolymerItem { @Getter Item polymerItem; diff --git a/src/main/java/io/github/unix_supremacist/item/BuildersStone.java b/src/main/java/io/github/unix_supremacist/item/BuildersStone.java new file mode 100644 index 0000000..52bafbc --- /dev/null +++ b/src/main/java/io/github/unix_supremacist/item/BuildersStone.java @@ -0,0 +1,65 @@ +package io.github.unix_supremacist.item; + +import io.github.unix_supremacist.interfaces.AreaBox; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; + +import java.util.ArrayList; + +public class BuildersStone extends AbstractEmpowerableItem implements AreaBox { + protected final int[] MODES; + private final int maxWidth; + private final int maxHeight; + + public BuildersStone(Properties properties, int maxWidth, int maxHeight) { + super(properties, maxWidth * maxHeight, Items.GOLDEN_CARROT); + this.maxWidth = maxWidth; + this.maxHeight = maxHeight; + + MODES = new int[maxWidth * maxHeight * 2]; + for (int i = 0; i < maxPower; i++) { + MODES[i * 2] = i % maxWidth; + MODES[i * 2 + 1] = i / maxWidth; + } + } + + @Override + public void empower(ItemStack item, Player p){ + super.empower(item, p); + p.displayClientMessage(Component.literal("Width: "+((maxWidth-1)*2-MODES[getPower(item)*2]*2+1)+" and Height: "+((maxHeight-1)*2-MODES[getPower(item)*2+1]*2+1)), true); + } + + @Override + public InteractionResult useOn(UseOnContext context) { + InteractionResult result = super.useOn(context); + if (context.getPlayer().isShiftKeyDown() == false){ + ArrayList againstBlocks = getAreaFromFacing(context.getClickedFace(), context.getPlayer().getDirection(), context.getClickedPos(), maxWidth-1-MODES[getPower(context.getItemInHand())*2], (maxHeight-1-MODES[getPower(context.getItemInHand())*2+1]), 0); + ArrayList blocks = getAreaFromFacing(context.getClickedFace(), context.getPlayer().getDirection(), context.getClickedPos().relative(context.getClickedFace()), maxWidth-1-MODES[getPower(context.getItemInHand())*2], (maxHeight-1-MODES[getPower(context.getItemInHand())*2+1]), 0); + + if(!blocks.isEmpty()){ + if (!context.getLevel().isClientSide()) for (int i = 0; i < againstBlocks.size(); i++){ + BlockState state = context.getLevel().getBlockState(againstBlocks.get(i)); + + Block block = context.getLevel().getBlockState(blocks.get(i)).getBlock(); + if (block.equals(Blocks.AIR) && state.equals(context.getLevel().getBlockState(context.getClickedPos()))) { + context.getLevel().setBlock(blocks.get(i), state, 3); + ItemStack stack = context.getPlayer().getItemInHand(context.getHand()).copy(); + context.getPlayer().setItemInHand(context.getHand(), stack); + result = InteractionResult.SUCCESS; + } + } + } + } + + return result; + } + +} diff --git a/src/main/java/io/github/unix_supremacist/item/GaleItem.java b/src/main/java/io/github/unix_supremacist/item/GaleItem.java index 7a01cd7..f85b058 100644 --- a/src/main/java/io/github/unix_supremacist/item/GaleItem.java +++ b/src/main/java/io/github/unix_supremacist/item/GaleItem.java @@ -1,6 +1,7 @@ package io.github.unix_supremacist.item; -import dev.emi.trinkets.api.*; +import dev.emi.trinkets.api.SlotReference; +import dev.emi.trinkets.api.TrinketItem; import eu.pb4.factorytools.api.item.AutoModeledPolymerItem; import io.github.ladysnake.pal.AbilitySource; import io.github.ladysnake.pal.Pal; diff --git a/src/main/resources/assets/alchemist/models/item/builders_stone.json b/src/main/resources/assets/alchemist/models/item/builders_stone.json new file mode 100644 index 0000000..fa52efc --- /dev/null +++ b/src/main/resources/assets/alchemist/models/item/builders_stone.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "alchemist:item/builders_stone" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/alchemist/textures/item/builders_stone.png b/src/main/resources/assets/alchemist/textures/item/builders_stone.png new file mode 100644 index 0000000000000000000000000000000000000000..68028c21361cef1114d7668f825762606e7dcb59 GIT binary patch literal 240 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`+dW+zLo9le6C^SYbod5re0{S% z=h64mOAM|gb7+*={?6Z|CAvB{+~=_5I{$v>i_M1u-&B3u|KcE1oA2*!4@*7?A2$(k ze!w&1to**3BP%6mEBY85tk+*Bv{X{oKrqZHmHFSlzo!rU;eHtOYuAJK_xJPI*ZogP z`1xB-uT7};lk4vPt8=rDteV)^*!b}H`}sWgWtb%NbXFYhag(^{P#6$^c=4D oTxDPbg60;rHJ*~OpC2$VoLuJ_^*-kjJJ1UZp00i_>zopr0Kl+lBme*a literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/spritesheet.ase b/src/main/resources/assets/spritesheet.ase index af04d284fe7859f6518926473958bf63d79c2cac..a2e7e19c61779ed05b8f9583aa4e173a6f6eb5a5 100644 GIT binary patch delta 1875 zcmXX`X;f2J7kv~ISX!b&1ud9FDL7E9Lj}Z;&!j326r^RaM4|!>$`Hm7c;FL3;47^X z6i|UgsG<=i4g`o8q9R4c2q>Tov6Mv!Aqg`0GQGTpRqu~|&e{8(wf0^2p8LDC+S)|T zGQpaVS$HazX$b(@k7htP@ZY*;0sw1p2#$Lu?dZ6pHVjh zj9bZhV`S3-b-YaMcL=~x{Fhir5ur0N2?>w3TxZPirBv5+7W4$`9+WQpd3aB9m31*=2qFZi*CXDH z5i%+}F_#BMMMY((aC<^1l;L>g{L3GlUp6~w&&}CL?``$(KHlKmjcD7M&ZiW02IkX_ zAP1B}D4kyy3D3v(Jpc8z5+4{8lv4RyRw)$gT%QX2AN3BdD;d5$(ig8EZ~I03b=yj4 zt9`nwU2$U2aNp=L`)u%4Nd+Tsv(*`R+?|~*te|GN82UoR1p@&4P^G#3}Ws!y!kBL_dj*3^PY4N<@ARwb( z>CglpeKLTH^J{e5wX1l9fJ+r8V?K`M4(R%cQOac+nz8Epzcu(?B1ocqKzfJep1BKr!e`jW{}Z3Rf@C3s;?O?Z7&yORZ&fGXiSXw8#F+lB zmAy7&MLPO4UC@*4xyr|LQY)F4K7+_uiSZeRN&YFJ+vM5n*2_*59Y|V*SN4=DeXi=hu6FlwF=-+9Qn{h(HVllGBk_-!$Xv%fZ%MdSou|1EI58pg zTUV>DPgcrEFM36T_7iudqOU#@`HYHa$csZBY8D0~Cj-o7p^d@A%OC>n-Tn>TG3jwk z=U8FN19iqMi!BfQNeppikE2WdMJwc4@^Vk8b7220JHqPB-K;qJtW+cmJ?xEe=*r~j zG;spqPG(9=NtlBw>59i-6ml^?guZrY9glt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