Skip to content

Commit

Permalink
Matter Blocks
Browse files Browse the repository at this point in the history
Textures made by @32polaris on discord
  • Loading branch information
DonovanDMC committed Oct 13, 2023
1 parent 930f65e commit 547d83e
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 24 deletions.
60 changes: 36 additions & 24 deletions src/main/java/cool/furry/mc/forge/projectexpansion/util/Matter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import cool.furry.mc.forge.projectexpansion.item.ItemCompressedEnergyCollector;
import cool.furry.mc.forge.projectexpansion.registries.Blocks;
import cool.furry.mc.forge.projectexpansion.registries.Items;
import moze_intel.projecte.gameObjs.registries.PEBlocks;
import moze_intel.projecte.gameObjs.registries.PEItems;
import moze_intel.projecte.utils.text.ILangEntry;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.registries.RegistryObject;

import javax.annotation.Nullable;
Expand All @@ -29,22 +31,22 @@

@SuppressWarnings("unused")
public enum Matter {
BASIC( 0, null, Lang.Blocks.BASIC_COLLECTOR),
DARK( 2, PEItems.DARK_MATTER, Lang.Blocks.DARK_COLLECTOR),
RED( 4, PEItems.RED_MATTER, Lang.Blocks.RED_COLLECTOR),
MAGENTA(4, null, Lang.Blocks.MAGENTA_COLLECTOR),
PINK( 5, null, Lang.Blocks.PINK_COLLECTOR),
PURPLE( 5, null, Lang.Blocks.PURPLE_COLLECTOR),
VIOLET( 6, null, Lang.Blocks.VIOLET_COLLECTOR),
BLUE( 6, null, Lang.Blocks.BLUE_COLLECTOR),
CYAN( 7, null, Lang.Blocks.CYAN_COLLECTOR),
GREEN( 7, null, Lang.Blocks.GREEN_COLLECTOR),
LIME( 8, null, Lang.Blocks.LIME_COLLECTOR),
YELLOW( 8, null, Lang.Blocks.YELLOW_COLLECTOR),
ORANGE( 9, null, Lang.Blocks.ORANGE_COLLECTOR),
WHITE( 9, null, Lang.Blocks.WHITE_COLLECTOR),
FADING( 10, null, Lang.Blocks.FADING_COLLECTOR),
FINAL( 10, Items.FINAL_STAR_SHARD, Lang.Blocks.FINAL_COLLECTOR);
BASIC( 0, null, null),
DARK( 2, PEItems.DARK_MATTER, PEBlocks.DARK_MATTER::getBlock),
RED( 4, PEItems.RED_MATTER, PEBlocks.RED_MATTER::getBlock),
MAGENTA(4, null, null),
PINK( 5, null, null),
PURPLE( 5, null, null),
VIOLET( 6, null, null),
BLUE( 6, null, null),
CYAN( 7, null, null),
GREEN( 7, null, null),
LIME( 8, null, null),
YELLOW( 8, null, null),
ORANGE( 9, null, null),
WHITE( 9, null, null),
FADING( 10, null, null),
FINAL( 10, Items.FINAL_STAR_SHARD, null);
public final BigDecimal BASE_COLLECTOR_OUTPUT = BigDecimal.valueOf(4L);
public final BigDecimal BASE_RELAY_BONUS = BigDecimal.valueOf(1L);
public final BigDecimal BASE_RELAY_TRANSFER = BigDecimal.valueOf(64L);
Expand All @@ -61,6 +63,7 @@ public Matter next() {

public final String name;
public final boolean hasItem;
public final boolean hasBlock;
public final int level;
public final BigDecimal collectorOutputBase;
public final BigDecimal relayBonusBase;
Expand All @@ -71,6 +74,8 @@ public Matter next() {
public final int fluidEfficiency;
@Nullable
public final Supplier<Item> existingItem;
@Nullable
public final Supplier<Block> existingBlock;
public final Rarity rarity;
@Nullable
private RegistryObject<Item> itemMatter = null;
Expand All @@ -93,22 +98,25 @@ public Matter next() {
@Nullable
private RegistryObject<BlockItem> itemEMCLink = null;
@Nullable
private ILangEntry collectorLang = null;
private RegistryObject<BlockItem> itemMatterBlock = null;
@Nullable
private RegistryObject<Block> blockMatterBlock = null;

public static final int UNCOMMON_THRESHOLD = 4;
public static final int RARE_THRESHOLD = 15;
public static final int EPIC_THRESHOLD = 16;
Matter(int fluidEfficiency, @Nullable Supplier<Item> existingItem, ILangEntry collectorLang) {
Matter(int fluidEfficiency, @Nullable Supplier<Item> existingItem, @Nullable Supplier<Block> existingBlock) {
boolean isFinal = name().equals("FINAL"); // we can't access the FINAL member because we're in the constructor
this.name = name().toLowerCase(Locale.US);
this.hasItem = existingItem == null && ordinal() != 0;
this.hasBlock = existingBlock == null && ordinal() != 0 && ordinal() != 15;
this.level = ordinal() + 1;
this.collectorOutputBase = getValue(BASE_COLLECTOR_OUTPUT);
this.relayBonusBase = getValue(BASE_RELAY_BONUS);
this.relayTransferBase = isFinal ? BigDecimal.valueOf(Long.MAX_VALUE) : getValue(BASE_RELAY_TRANSFER);
this.fluidEfficiency = fluidEfficiency;
this.existingItem = existingItem;
this.collectorLang = collectorLang;
this.existingBlock = existingBlock;
this.rarity =
level >= EPIC_THRESHOLD ? Rarity.EPIC :
level >= RARE_THRESHOLD ? Rarity.RARE :
Expand Down Expand Up @@ -272,10 +280,6 @@ public MutableComponent getRelayTransferComponent() {
return itemEMCLink == null ? null : itemEMCLink.get();
}

public @Nullable ILangEntry getCollectorLang() {
return collectorLang;
}

/* Registration */

private void register(RegistrationType reg) {
Expand All @@ -286,6 +290,13 @@ private void register(RegistrationType reg) {
}
}

case MATTER_BLOCK -> {
if (hasBlock) {
blockMatterBlock = Blocks.Registry.register(String.format("%s_matter_block", name), () -> new Block(Block.Properties.of(Material.STONE).strength(2000000.0F, 6000000.0F).requiresCorrectToolForDrops().lightLevel((state) -> Math.min(ordinal(), 15))));
itemMatterBlock = Items.Registry.register(String.format("%s_matter_block", name), () -> new BlockItem(Objects.requireNonNull(blockMatterBlock).get(), new Item.Properties().tab(Main.tab).rarity(rarity)));
}
}

case COLLECTOR -> {
collector = Blocks.Registry.register(String.format("%s_collector", name), () -> new BlockCollector(this));
itemCollector = Items.Registry.register(String.format("%s_collector", name), () -> new BlockItem(Objects.requireNonNull(collector).get(), new Item.Properties().tab(Main.tab).rarity(rarity)));
Expand All @@ -312,6 +323,7 @@ public static void registerAll() {

private enum RegistrationType {
MATTER,
MATTER_BLOCK,
COLLECTOR,
COMPRESSED_COLLECTOR,
POWER_FLOWER,
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Textures made by @32polaris on discord
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"animation": {"frametime": 1, "frames": [2, 1, 0, 2, 1, 0, 1, 0, 3, 0, 0, 1, 1, 2, 3, 1, 0, 3, 0, 0]}}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 547d83e

Please sign in to comment.