Skip to content

Commit

Permalink
1.1.0 Update
Browse files Browse the repository at this point in the history
Added Crafting Terminal
Added the ability to paint some of the blocks
Added Inventory Cable & Connector
Added Inventory Proxy
Added Wireless Terminal
Added config to change Inventory Connector range.
  • Loading branch information
tom5454 committed May 24, 2020
1 parent d9445d2 commit a06a43d
Show file tree
Hide file tree
Showing 115 changed files with 6,181 additions and 511 deletions.
Binary file modified banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '1.0.2'
version = '1.1.0'
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'toms_storage'

Expand All @@ -25,7 +25,7 @@ minecraft {
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'stable', version: '60-1.15'
mappings channel: 'snapshot', version: '20200423-1.15.1'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
Expand Down
68 changes: 68 additions & 0 deletions src/main/java/com/tom/storagemod/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.tom.storagemod;

import org.apache.commons.lang3.tuple.Pair;

import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.IntValue;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.config.ModConfig;

public class Config {
public static boolean onlyTrims;
public static int invRange;
public static int invConnectorMax = 0;
public static int wirelessRange;

public static class Server {
public IntValue inventoryConnectorRange;
public IntValue inventoryCableConnectorMaxCables;
public IntValue wirelessRange;
public BooleanValue onlyTrimsConnect;

private Server(ForgeConfigSpec.Builder builder) {
inventoryConnectorRange = builder.comment("Inventory Connector Range").
translation("tomsstorage.config.inventory_connector_range").
defineInRange("inventoryConnectorRange", 16, 4, 256);

onlyTrimsConnect = builder.comment("Only Allow Trims to Connect Inventories").
translation("tomsstorage.config.only_trims_connect").
define("onlyTrimsConnect", false);

inventoryCableConnectorMaxCables = builder.comment("Inventory Cable Connector Maximum number of cables").
translation("tomsstorage.config.inv_cable_connector_max_scan").
defineInRange("invCableConnectorMaxScanSize", 2048, 16, Integer.MAX_VALUE);

wirelessRange = builder.comment("Wireless terminal reach").
translation("tomsstorage.config.wireless_reach").
defineInRange("wirelessReach", 16, 4, 64);
}
}

static final ForgeConfigSpec serverSpec;
public static final Server SERVER;
static {
final Pair<Server, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(Server::new);
serverSpec = specPair.getRight();
SERVER = specPair.getLeft();
}

private static void load() {
onlyTrims = SERVER.onlyTrimsConnect.get();
invRange = SERVER.inventoryConnectorRange.get() * SERVER.inventoryConnectorRange.get();
invConnectorMax = SERVER.inventoryCableConnectorMaxCables.get();
wirelessRange = SERVER.wirelessRange.get();
}

@SubscribeEvent
public static void onLoad(final ModConfig.Loading configEvent) {
StorageMod.LOGGER.info("Loaded Tom's Simple Storage config file {}", configEvent.getConfig().getFileName());
load();
}

@SubscribeEvent
public static void onFileChange(final ModConfig.Reloading configEvent) {
StorageMod.LOGGER.info("Tom's Simple Storage config just got changed on the file system!");
load();
}
}
28 changes: 28 additions & 0 deletions src/main/java/com/tom/storagemod/ItemBlockConnector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.tom.storagemod;

import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;

public class ItemBlockConnector extends BlockItem {

public ItemBlockConnector() {
super(StorageMod.invCableConnector, new Properties());
setRegistryName(StorageMod.invCableConnector.getRegistryName());
}

@Override
public ITextComponent getDisplayName(ItemStack is) {
ITextComponent tc = super.getDisplayName(is);
tc.appendText(" (");
if(is.hasTag() && is.getTag().getCompound("BlockStateTag").contains("color")) {
String color = is.getTag().getCompound("BlockStateTag").getString("color");
tc.appendSibling(new TranslationTextComponent("color.minecraft." + color));
} else {
tc.appendSibling(new TranslationTextComponent("color.minecraft.white"));
}
tc.appendText(")");
return tc;
}
}
105 changes: 95 additions & 10 deletions src/main/java/com/tom/storagemod/StorageMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,85 @@
import org.apache.logging.log4j.Logger;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityType;

import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

import com.tom.storagemod.block.BlockInventoryCable;
import com.tom.storagemod.block.BlockInventoryCableConnector;
import com.tom.storagemod.block.BlockInventoryCableFramed;
import com.tom.storagemod.block.BlockInventoryProxy;
import com.tom.storagemod.block.BlockOpenCrate;
import com.tom.storagemod.block.BlockPaintedTrim;
import com.tom.storagemod.block.BlockTrim;
import com.tom.storagemod.block.CraftingTerminal;
import com.tom.storagemod.block.InventoryConnector;
import com.tom.storagemod.block.StorageTerminal;
import com.tom.storagemod.block.TileEntityInventoryConnector;
import com.tom.storagemod.block.TileEntityOpenCrate;
import com.tom.storagemod.block.TileEntityStorageTerminal;
import com.tom.storagemod.gui.ContainerCraftingTerminal;
import com.tom.storagemod.gui.ContainerStorageTerminal;
import com.tom.storagemod.item.ItemBlockPainted;
import com.tom.storagemod.item.ItemPaintKit;
import com.tom.storagemod.item.ItemWirelessTerminal;
import com.tom.storagemod.proxy.ClientProxy;
import com.tom.storagemod.proxy.IProxy;
import com.tom.storagemod.proxy.ServerProxy;
import com.tom.storagemod.tile.TileEntityCraftingTerminal;
import com.tom.storagemod.tile.TileEntityInventoryCableConnector;
import com.tom.storagemod.tile.TileEntityInventoryConnector;
import com.tom.storagemod.tile.TileEntityInventoryProxy;
import com.tom.storagemod.tile.TileEntityOpenCrate;
import com.tom.storagemod.tile.TileEntityPainted;
import com.tom.storagemod.tile.TileEntityStorageTerminal;

// The value here should match an entry in the META-INF/mods.toml file
@Mod("toms_storage")
@Mod(StorageMod.modid)
public class StorageMod
{
public static final String modid = "toms_storage";
public static IProxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> ServerProxy::new);
public static InventoryConnector connector;
public static StorageTerminal terminal;
public static Block inventoryTrim;
public static BlockTrim inventoryTrim;
public static BlockOpenCrate openCrate;
public static BlockPaintedTrim paintedTrim;
public static BlockInventoryCable invCable;
public static BlockInventoryCableFramed invCableFramed;
public static BlockInventoryCableConnector invCableConnector;
public static BlockInventoryProxy invProxy;
public static CraftingTerminal craftingTerminal;

public static ItemPaintKit paintingKit;
public static ItemWirelessTerminal wirelessTerminal;

public static TileEntityType<TileEntityInventoryConnector> connectorTile;
public static TileEntityType<TileEntityStorageTerminal> terminalTile;
public static TileEntityType<TileEntityOpenCrate> openCrateTile;
public static TileEntityType<TileEntityPainted> paintedTile;
public static TileEntityType<TileEntityInventoryCableConnector> invCableConnectorTile;
public static TileEntityType<TileEntityInventoryProxy> invProxyTile;
public static TileEntityType<TileEntityCraftingTerminal> craftingTerminalTile;

public static ContainerType<ContainerStorageTerminal> storageTerminal;
public static ContainerType<ContainerCraftingTerminal> craftingTerminalCont;

// Directly reference a log4j logger.
private static final Logger LOGGER = LogManager.getLogger();
public static final Logger LOGGER = LogManager.getLogger();

public StorageMod() {
// Register the setup method for modloading
Expand All @@ -60,6 +94,9 @@ public StorageMod() {
// Register the doClientStuff method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);

ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.serverSpec);
FMLJavaModLoadingContext.get().getModEventBus().register(Config.class);

// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
}
Expand All @@ -73,6 +110,15 @@ private void doClientStuff(final FMLClientSetupEvent event) {
proxy.clientSetup();
}

public static final ItemGroup STORAGE_MOD_TAB = new ItemGroup("toms_storage") {

@Override
@OnlyIn(Dist.CLIENT)
public ItemStack createIcon() {
return new ItemStack(terminal);
}
};

// You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
// Event bus for receiving Registry Events)
@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
Expand All @@ -82,23 +128,47 @@ public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockReg
connector = new InventoryConnector();
terminal = new StorageTerminal();
openCrate = new BlockOpenCrate();
inventoryTrim = new Block(Block.Properties.create(Material.WOOD).hardnessAndResistance(3).harvestTool(ToolType.AXE)).setRegistryName("ts.trim");
inventoryTrim = new BlockTrim();
paintedTrim = new BlockPaintedTrim();
invCable = new BlockInventoryCable();
invCableFramed = new BlockInventoryCableFramed();
invCableConnector = new BlockInventoryCableConnector();
invProxy = new BlockInventoryProxy();
craftingTerminal = new CraftingTerminal();
blockRegistryEvent.getRegistry().register(connector);
blockRegistryEvent.getRegistry().register(terminal);
blockRegistryEvent.getRegistry().register(openCrate);
blockRegistryEvent.getRegistry().register(inventoryTrim);
blockRegistryEvent.getRegistry().register(paintedTrim);
blockRegistryEvent.getRegistry().register(invCable);
blockRegistryEvent.getRegistry().register(invCableFramed);
blockRegistryEvent.getRegistry().register(invCableConnector);
blockRegistryEvent.getRegistry().register(invProxy);
blockRegistryEvent.getRegistry().register(craftingTerminal);
}

@SubscribeEvent
public static void onItemsRegistry(final RegistryEvent.Register<Item> itemRegistryEvent) {
paintingKit = new ItemPaintKit();
wirelessTerminal = new ItemWirelessTerminal();

registerItemForBlock(itemRegistryEvent, connector);
registerItemForBlock(itemRegistryEvent, terminal);
registerItemForBlock(itemRegistryEvent, openCrate);
registerItemForBlock(itemRegistryEvent, inventoryTrim);
itemRegistryEvent.getRegistry().register(new ItemBlockPainted(paintedTrim));
registerItemForBlock(itemRegistryEvent, invCable);
itemRegistryEvent.getRegistry().register(new ItemBlockPainted(invCableFramed, new Item.Properties().group(STORAGE_MOD_TAB)));
itemRegistryEvent.getRegistry().register(new ItemBlockConnector());
itemRegistryEvent.getRegistry().register(new ItemBlockPainted(invProxy, new Item.Properties().group(STORAGE_MOD_TAB)));
registerItemForBlock(itemRegistryEvent, craftingTerminal);

itemRegistryEvent.getRegistry().register(paintingKit);
itemRegistryEvent.getRegistry().register(wirelessTerminal);
}

private static void registerItemForBlock(RegistryEvent.Register<Item> itemRegistryEvent, Block block) {
itemRegistryEvent.getRegistry().register(new BlockItem(block, new Item.Properties().group(ItemGroup.REDSTONE)).setRegistryName(block.getRegistryName()));
itemRegistryEvent.getRegistry().register(new BlockItem(block, new Item.Properties().group(STORAGE_MOD_TAB)).setRegistryName(block.getRegistryName()));
}

@SubscribeEvent
Expand All @@ -109,16 +179,31 @@ public static void onTileRegistry(final RegistryEvent.Register<TileEntityType<?>
terminalTile.setRegistryName("ts.storage_terminal.tile");
openCrateTile = TileEntityType.Builder.create(TileEntityOpenCrate::new, openCrate).build(null);
openCrateTile.setRegistryName("ts.open_crate.tile");
paintedTile = TileEntityType.Builder.create(TileEntityPainted::new, paintedTrim, invCableFramed).build(null);
paintedTile.setRegistryName("ts.painted.tile");
invCableConnectorTile = TileEntityType.Builder.create(TileEntityInventoryCableConnector::new, invCableConnector).build(null);
invCableConnectorTile.setRegistryName("ts.inventory_cable_connector.tile");
invProxyTile = TileEntityType.Builder.create(TileEntityInventoryProxy::new, invProxy).build(null);
invProxyTile.setRegistryName("ts.inventory_proxy.tile");
craftingTerminalTile = TileEntityType.Builder.create(TileEntityCraftingTerminal::new, craftingTerminal).build(null);
craftingTerminalTile.setRegistryName("ts.crafting_terminal.tile");
tileRegistryEvent.getRegistry().register(connectorTile);
tileRegistryEvent.getRegistry().register(terminalTile);
tileRegistryEvent.getRegistry().register(openCrateTile);
tileRegistryEvent.getRegistry().register(paintedTile);
tileRegistryEvent.getRegistry().register(invCableConnectorTile);
tileRegistryEvent.getRegistry().register(invProxyTile);
tileRegistryEvent.getRegistry().register(craftingTerminalTile);
}

@SubscribeEvent
public static void onContainerRegistry(final RegistryEvent.Register<ContainerType<?>> containerRegistryEvent) {
storageTerminal = new ContainerType<>(ContainerStorageTerminal::new);
storageTerminal.setRegistryName("ts.storage_terminal.container");
craftingTerminalCont = new ContainerType<>(ContainerCraftingTerminal::new);
craftingTerminalCont.setRegistryName("ts.crafting_terminal.container");
containerRegistryEvent.getRegistry().register(storageTerminal);
containerRegistryEvent.getRegistry().register(craftingTerminalCont);
}
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/tom/storagemod/StorageTags.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.tom.storagemod;

import net.minecraft.block.Block;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.Tag;
import net.minecraft.util.ResourceLocation;

public class StorageTags {
public static final Tag<Block> REMOTE_ACTIVATE = new BlockTags.Wrapper(new ResourceLocation("toms_storage", "remote_activate"));
}
Loading

0 comments on commit a06a43d

Please sign in to comment.