🏗️ Configs, other mods compact init, art
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
// 1.19.2 2023-08-16T15:56:06.979095197 Registrate Provider for trading_station [Recipes, Advancements, Loot tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
|
// 1.19.2 2023-08-16T17:59:11.715017504 Registrate Provider for trading_station [Recipes, Advancements, Loot tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
|
||||||
ac427e21e7a0915809800ce83800780c045678c6 assets/trading_station/blockstates/powered_trading_station.json
|
ac427e21e7a0915809800ce83800780c045678c6 assets/trading_station/blockstates/powered_trading_station.json
|
||||||
391b0f87f6c9bd80e20dfc8b949e7dd99cd16fe9 assets/trading_station/blockstates/trading_station.json
|
391b0f87f6c9bd80e20dfc8b949e7dd99cd16fe9 assets/trading_station/blockstates/trading_station.json
|
||||||
2b8f51b49619e47225d4710f7917205a31ff362e assets/trading_station/lang/en_ud.json
|
2c8a8b7c6874dcb7e5474ba19b33fbb2d166c834 assets/trading_station/lang/en_ud.json
|
||||||
53756e3e6b11fb1c70ccf8979a5a36504a702fca assets/trading_station/lang/en_us.json
|
efb3401e9c37c753973bf81e4da4bb0946061a19 assets/trading_station/lang/en_us.json
|
||||||
373be6ce42eee460888161c967f098e5943e3778 assets/trading_station/models/item/powered_trading_station.json
|
373be6ce42eee460888161c967f098e5943e3778 assets/trading_station/models/item/powered_trading_station.json
|
||||||
7ddda578b6d6072db924599a9959579470354897 assets/trading_station/models/item/trading_station.json
|
7ddda578b6d6072db924599a9959579470354897 assets/trading_station/models/item/trading_station.json
|
||||||
c3b4c04c1cecdc5001fcddda7b30b11b15f0b2b2 data/trading_station/loot_tables/blocks/powered_trading_station.json
|
c3b4c04c1cecdc5001fcddda7b30b11b15f0b2b2 data/trading_station/loot_tables/blocks/powered_trading_station.json
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"block.trading_station.powered_trading_station": "uoıʇɐʇS buıpɐɹ⟘ pǝɹǝʍoԀ",
|
"block.trading_station.powered_trading_station": "uoıʇɐʇS buıpɐɹ⟘ pǝɹǝʍoԀ",
|
||||||
"block.trading_station.trading_station": "uoıʇɐʇS buıpɐɹ⟘",
|
"block.trading_station.trading_station": "uoıʇɐʇS buıpɐɹ⟘",
|
||||||
"config.jade.plugin_trading_station.trading_station_data": "ɐʇɐp uoıʇɐʇS buıpɐɹ⟘",
|
"config.jade.plugin_trading_station.trading_station_data": "ɐʇɐp uoıʇɐʇS buıpɐɹ⟘",
|
||||||
"itemGroup.trading_station:main": "uoıʇɐʇS buıpɐɹ⟘",
|
"itemGroup.trading_station": "uoıʇɐʇS buıpɐɹ⟘",
|
||||||
"trading_station.powered_trading_station.block.display": "uoıʇɐʇS buıpɐɹ⟘ pǝɹǝʍoԀ",
|
"trading_station.powered_trading_station.block.display": "uoıʇɐʇS buıpɐɹ⟘ pǝɹǝʍoԀ",
|
||||||
"trading_station.select_target.button": "ʇǝbɹɐʇ ʇɔǝןǝS",
|
"trading_station.select_target.button": "ʇǝbɹɐʇ ʇɔǝןǝS",
|
||||||
"trading_station.select_target.clear": "ɹɐǝןƆ",
|
"trading_station.select_target.clear": "ɹɐǝןƆ",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"block.trading_station.powered_trading_station": "Powered Trading Station",
|
"block.trading_station.powered_trading_station": "Powered Trading Station",
|
||||||
"block.trading_station.trading_station": "Trading Station",
|
"block.trading_station.trading_station": "Trading Station",
|
||||||
"config.jade.plugin_trading_station.trading_station_data": "Trading Station data",
|
"config.jade.plugin_trading_station.trading_station_data": "Trading Station data",
|
||||||
"itemGroup.trading_station:main": "Trading Station",
|
"itemGroup.trading_station": "Trading Station",
|
||||||
"trading_station.powered_trading_station.block.display": "Powered Trading Station",
|
"trading_station.powered_trading_station.block.display": "Powered Trading Station",
|
||||||
"trading_station.select_target.button": "Select target",
|
"trading_station.select_target.button": "Select target",
|
||||||
"trading_station.select_target.clear": "Clear",
|
"trading_station.select_target.clear": "Clear",
|
||||||
|
|||||||
@@ -3,14 +3,17 @@ package com.oierbravo.trading_station;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
|
import com.oierbravo.trading_station.compat.Mods;
|
||||||
|
import com.oierbravo.trading_station.content.trading_station.TradingStationConfig;
|
||||||
import com.oierbravo.trading_station.foundation.util.ModLang;
|
import com.oierbravo.trading_station.foundation.util.ModLang;
|
||||||
import com.oierbravo.trading_station.registrate.*;
|
import com.oierbravo.trading_station.registrate.*;
|
||||||
import com.tterrag.registrate.Registrate;
|
import com.tterrag.registrate.Registrate;
|
||||||
|
import net.minecraft.data.DataGenerator;
|
||||||
import net.minecraftforge.common.util.Lazy;
|
import net.minecraftforge.common.util.Lazy;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.data.event.GatherDataEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
@@ -44,15 +47,29 @@ public class TradingStation
|
|||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
|
||||||
ModCreativeTab modTab = new ModCreativeTab();
|
ModCreativeTab modTab = new ModCreativeTab();
|
||||||
|
|
||||||
ModBlocks.register();
|
|
||||||
ModBlockEntities.register();
|
|
||||||
ModRecipes.register(modEventBus);
|
|
||||||
ModMessages.register();
|
|
||||||
ModMenus.register();
|
|
||||||
Config.register();
|
Config.register();
|
||||||
|
|
||||||
registrate().addRawLang("itemGroup.trading_station:main", "Trading Station");
|
TradingStationRegistrate.register();
|
||||||
|
PoweredTradingStationRegistrate.register();
|
||||||
|
|
||||||
|
ModRecipes.register(modEventBus);
|
||||||
|
ModMessages.register();
|
||||||
|
|
||||||
|
modEventBus.addListener(EventPriority.LOWEST, TradingStation::gatherData);
|
||||||
|
|
||||||
|
Mods.CREATE.executeIfInstalled(() -> MechanicalTradingStationRegistrate::register);
|
||||||
|
}
|
||||||
|
public static void gatherData(GatherDataEvent event) {
|
||||||
|
DataGenerator gen = event.getGenerator();
|
||||||
|
if (event.includeClient()) {
|
||||||
|
registerLanguageKeys();
|
||||||
|
}
|
||||||
|
if (event.includeServer()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void registerLanguageKeys(){
|
||||||
|
registrate().addRawLang("itemGroup.trading_station", "Trading Station");
|
||||||
registrate().addRawLang(ModLang.key("trading_station.block.display"), "Trading Station");
|
registrate().addRawLang(ModLang.key("trading_station.block.display"), "Trading Station");
|
||||||
registrate().addRawLang(ModLang.key("powered_trading_station.block.display"), "Powered Trading Station");
|
registrate().addRawLang(ModLang.key("powered_trading_station.block.display"), "Powered Trading Station");
|
||||||
registrate().addRawLang(ModLang.key("trading.recipe"), "Trading recipe");
|
registrate().addRawLang(ModLang.key("trading.recipe"), "Trading recipe");
|
||||||
@@ -61,10 +78,7 @@ public class TradingStation
|
|||||||
registrate().addRawLang(ModLang.key("select_target.button"), "Select target");
|
registrate().addRawLang(ModLang.key("select_target.button"), "Select target");
|
||||||
registrate().addRawLang(ModLang.key("select_target.clear"), "Clear");
|
registrate().addRawLang(ModLang.key("select_target.clear"), "Clear");
|
||||||
registrate().addRawLang("config.jade.plugin_trading_station.trading_station_data", "Trading Station data");
|
registrate().addRawLang("config.jade.plugin_trading_station.trading_station_data", "Trading Station data");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Registrate registrate() {
|
public static Registrate registrate() {
|
||||||
return REGISTRATE.get();
|
return REGISTRATE.get();
|
||||||
}
|
}
|
||||||
|
|||||||
61
src/main/java/com/oierbravo/trading_station/compat/Mods.java
Normal file
61
src/main/java/com/oierbravo/trading_station/compat/Mods.java
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package com.oierbravo.trading_station.compat;
|
||||||
|
|
||||||
|
import com.oierbravo.trading_station.foundation.util.ModLang;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraftforge.fml.ModList;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
/**
|
||||||
|
* From Create mod.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For compatibility with and without another mod present, we have to define load conditions of the specific code
|
||||||
|
*/
|
||||||
|
public enum Mods {
|
||||||
|
CREATE,
|
||||||
|
ARS_NOUVEAU;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a boolean of whether the mod is loaded or not based on mod id
|
||||||
|
*/
|
||||||
|
public boolean isLoaded() {
|
||||||
|
return ModList.get().isLoaded(asId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the mod id
|
||||||
|
*/
|
||||||
|
public String asId() {
|
||||||
|
return ModLang.asId(name());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple hook to run code if a mod is installed
|
||||||
|
* @param toRun will be run only if the mod is loaded
|
||||||
|
* @return Optional.empty() if the mod is not loaded, otherwise an Optional of the return value of the given supplier
|
||||||
|
*/
|
||||||
|
public <T> Optional<T> runIfInstalled(Supplier<Supplier<T>> toRun) {
|
||||||
|
if (isLoaded())
|
||||||
|
return Optional.of(toRun.get().get());
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple hook to execute code if a mod is installed
|
||||||
|
* @param toExecute will be executed only if the mod is loaded
|
||||||
|
*/
|
||||||
|
public void executeIfInstalled(Supplier<Runnable> toExecute) {
|
||||||
|
if (isLoaded()) {
|
||||||
|
toExecute.get().run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Block getBlock(String id) {
|
||||||
|
return ForgeRegistries.BLOCKS.getValue(new ResourceLocation(asId(), id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,9 @@ package com.oierbravo.trading_station.compat.jei;
|
|||||||
|
|
||||||
import com.oierbravo.trading_station.TradingStation;
|
import com.oierbravo.trading_station.TradingStation;
|
||||||
import com.oierbravo.trading_station.content.trading_recipe.TradingRecipe;
|
import com.oierbravo.trading_station.content.trading_recipe.TradingRecipe;
|
||||||
import com.oierbravo.trading_station.registrate.ModBlocks;
|
import com.oierbravo.trading_station.content.trading_station.TradingStationConfig;
|
||||||
|
import com.oierbravo.trading_station.registrate.PoweredTradingStationRegistrate;
|
||||||
|
import com.oierbravo.trading_station.registrate.TradingStationRegistrate;
|
||||||
import mezz.jei.api.IModPlugin;
|
import mezz.jei.api.IModPlugin;
|
||||||
import mezz.jei.api.JeiPlugin;
|
import mezz.jei.api.JeiPlugin;
|
||||||
import mezz.jei.api.recipe.RecipeType;
|
import mezz.jei.api.recipe.RecipeType;
|
||||||
@@ -33,8 +35,8 @@ public class JEIPlugin implements IModPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
|
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
|
||||||
registration.addRecipeCatalyst(new ItemStack(ModBlocks.TRADING_STATION.get()),new RecipeType<>(TradingRecipeCategory.UID, TradingRecipe.class));
|
registration.addRecipeCatalyst(new ItemStack(TradingStationRegistrate.TRADING_STATION_BLOCK.get()),new RecipeType<>(TradingRecipeCategory.UID, TradingRecipe.class));
|
||||||
registration.addRecipeCatalyst(new ItemStack(ModBlocks.POWERED_TRADING_STATION.get()),new RecipeType<>(TradingRecipeCategory.UID, TradingRecipe.class));
|
registration.addRecipeCatalyst(new ItemStack(PoweredTradingStationRegistrate.POWERED_TRADING_STATION_BLOCK.get()),new RecipeType<>(TradingRecipeCategory.UID, TradingRecipe.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||||||
import com.oierbravo.trading_station.TradingStation;
|
import com.oierbravo.trading_station.TradingStation;
|
||||||
import com.oierbravo.trading_station.content.trading_recipe.TradingRecipe;
|
import com.oierbravo.trading_station.content.trading_recipe.TradingRecipe;
|
||||||
import com.oierbravo.trading_station.foundation.util.ModLang;
|
import com.oierbravo.trading_station.foundation.util.ModLang;
|
||||||
import com.oierbravo.trading_station.registrate.ModBlocks;
|
import com.oierbravo.trading_station.registrate.TradingStationRegistrate;
|
||||||
import mezz.jei.api.constants.VanillaTypes;
|
import mezz.jei.api.constants.VanillaTypes;
|
||||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
|
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
|
||||||
import mezz.jei.api.gui.drawable.IDrawable;
|
import mezz.jei.api.gui.drawable.IDrawable;
|
||||||
@@ -26,6 +26,7 @@ import net.minecraft.network.chat.Component;
|
|||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@@ -63,7 +64,7 @@ public class TradingRecipeCategory implements IRecipeCategory<TradingRecipe> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(ModBlocks.TRADING_STATION.get()));
|
this.icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(TradingStationRegistrate.TRADING_STATION_BLOCK.get()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.oierbravo.trading_station.content.trading_station;
|
package com.oierbravo.trading_station.content.trading_station;
|
||||||
|
|
||||||
import com.oierbravo.trading_station.registrate.ModBlockEntities;
|
import com.oierbravo.trading_station.registrate.PoweredTradingStationRegistrate;
|
||||||
|
import com.oierbravo.trading_station.registrate.TradingStationRegistrate;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
@@ -8,7 +9,6 @@ import net.minecraft.server.level.ServerPlayer;
|
|||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.MenuProvider;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
@@ -79,7 +79,7 @@ public class TradingStationBlock extends BaseEntityBlock {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
|
public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
|
||||||
return ModBlockEntities.TRADING_STATION.create(pPos, pState);
|
return TradingStationRegistrate.TRADING_STATION_BLOCK_ENTITY.create(pPos, pState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -95,7 +95,7 @@ public class TradingStationBlock extends BaseEntityBlock {
|
|||||||
if(pLevel.isClientSide()) {
|
if(pLevel.isClientSide()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return createTickerHelper(pBlockEntityType, ModBlockEntities.TRADING_STATION.get(),
|
return createTickerHelper(pBlockEntityType, TradingStationRegistrate.TRADING_STATION_BLOCK_ENTITY.get(),
|
||||||
(pLevel1, pPos, pState1, pBlockEntity) -> pBlockEntity.tick(pLevel1, pPos, pState1));
|
(pLevel1, pPos, pState1, pBlockEntity) -> pBlockEntity.tick(pLevel1, pPos, pState1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,13 +57,11 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
|
|||||||
private BlockState lastBlockState;
|
private BlockState lastBlockState;
|
||||||
|
|
||||||
protected final ContainerData containerData;
|
protected final ContainerData containerData;
|
||||||
private Item preferedItem;
|
|
||||||
|
|
||||||
public TradingStationBlockEntity(BlockEntityType<?> pType, BlockPos pWorldPosition, BlockState pBlockState) {
|
public TradingStationBlockEntity(BlockEntityType<?> pType, BlockPos pWorldPosition, BlockState pBlockState) {
|
||||||
super(pType, pWorldPosition, pBlockState);
|
super(pType, pWorldPosition, pBlockState);
|
||||||
updateTag = getPersistentData();
|
updateTag = getPersistentData();
|
||||||
lastBlockState = this.getBlockState();
|
lastBlockState = this.getBlockState();
|
||||||
preferedItem = ItemStack.EMPTY.getItem();
|
|
||||||
containerData = TradingStationBlockEntity.createContainerData(this);
|
containerData = TradingStationBlockEntity.createContainerData(this);
|
||||||
}
|
}
|
||||||
public static ContainerData createContainerData(TradingStationBlockEntity pBlockEntity){
|
public static ContainerData createContainerData(TradingStationBlockEntity pBlockEntity){
|
||||||
@@ -99,6 +97,7 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
|
|||||||
@Override
|
@Override
|
||||||
protected void onContentsChanged(int slot) {
|
protected void onContentsChanged(int slot) {
|
||||||
setChanged();
|
setChanged();
|
||||||
|
resetProgress();
|
||||||
if(!level.isClientSide()) {
|
if(!level.isClientSide()) {
|
||||||
ModMessages.sendToClients(new ItemStackSyncS2CPacket(slot,this.getStackInSlot(0), worldPosition, ItemStackSyncS2CPacket.SlotType.TARGET));
|
ModMessages.sendToClients(new ItemStackSyncS2CPacket(slot,this.getStackInSlot(0), worldPosition, ItemStackSyncS2CPacket.SlotType.TARGET));
|
||||||
}
|
}
|
||||||
@@ -127,9 +126,11 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
|
|||||||
|
|
||||||
private ItemStackHandler createInputItemHandler() {
|
private ItemStackHandler createInputItemHandler() {
|
||||||
return new ItemStackHandler(2) {
|
return new ItemStackHandler(2) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onContentsChanged(int slot) {
|
protected void onContentsChanged(int slot) {
|
||||||
setChanged();
|
setChanged();
|
||||||
|
resetProgress();
|
||||||
if(!level.isClientSide()) {
|
if(!level.isClientSide()) {
|
||||||
ModMessages.sendToClients(new ItemStackSyncS2CPacket(slot,this.getStackInSlot(0), worldPosition, ItemStackSyncS2CPacket.SlotType.INPUT));
|
ModMessages.sendToClients(new ItemStackSyncS2CPacket(slot,this.getStackInSlot(0), worldPosition, ItemStackSyncS2CPacket.SlotType.INPUT));
|
||||||
}
|
}
|
||||||
@@ -206,7 +207,6 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
|
|||||||
tag.put("target", targetItemHandler.serializeNBT());
|
tag.put("target", targetItemHandler.serializeNBT());
|
||||||
tag.putInt("trading_station.progress", progress);
|
tag.putInt("trading_station.progress", progress);
|
||||||
tag.putInt("trading_station.maxProgress", maxProgress);
|
tag.putInt("trading_station.maxProgress", maxProgress);
|
||||||
String preferedItemString = ForgeRegistries.ITEMS.getKey(preferedItem).toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -217,8 +217,6 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
|
|||||||
targetItemHandler.deserializeNBT(tag.getCompound("target"));
|
targetItemHandler.deserializeNBT(tag.getCompound("target"));
|
||||||
progress = tag.getInt("trading_station.progress");
|
progress = tag.getInt("trading_station.progress");
|
||||||
maxProgress = tag.getInt("trading_station.maxProgress");
|
maxProgress = tag.getInt("trading_station.maxProgress");
|
||||||
String preferedItemString = tag.getString("trading_station.preferedItem");
|
|
||||||
preferedItem = ForgeRegistries.ITEMS.getValue( ResourceLocation.tryParse(preferedItemString));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drops() {
|
public void drops() {
|
||||||
@@ -256,25 +254,20 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
|
|||||||
}
|
}
|
||||||
if(!isPowered(this))
|
if(!isPowered(this))
|
||||||
return;
|
return;
|
||||||
|
if(!canCraftItem())
|
||||||
|
return;
|
||||||
|
|
||||||
if (canCraftItem()) {
|
this.updateProgress();
|
||||||
this.updateProgress();
|
BlockEntity.setChanged(pLevel, pPos, pState);
|
||||||
BlockEntity.setChanged(pLevel, pPos, pState);
|
this.maxProgress = this.getProcessingTime(this);
|
||||||
this.maxProgress = this.getProcessingTime(this);
|
if (this.progress > this.maxProgress) {
|
||||||
if (this.progress > this.maxProgress) {
|
craftItem();
|
||||||
craftItem();
|
|
||||||
}
|
|
||||||
BlockEntity.setChanged(pLevel, pPos, pState);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this.resetProgress();
|
|
||||||
BlockEntity.setChanged(pLevel, pPos, pState);
|
|
||||||
}
|
}
|
||||||
|
BlockEntity.setChanged(pLevel, pPos, pState);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateProgress(){
|
protected void updateProgress(){
|
||||||
this.progress += 1;
|
this.progress += TradingStationConfig.PROGRESS_PER_TICK.get();
|
||||||
|
|
||||||
}
|
}
|
||||||
private static boolean isPowered(TradingStationBlockEntity pBlockEntity){
|
private static boolean isPowered(TradingStationBlockEntity pBlockEntity){
|
||||||
@@ -299,7 +292,6 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
|
|||||||
return inputInventory;
|
return inputInventory;
|
||||||
}
|
}
|
||||||
private void craftItem() {
|
private void craftItem() {
|
||||||
Level level = this.getLevel();
|
|
||||||
SimpleContainer inputInventory = getInputInventory(this);
|
SimpleContainer inputInventory = getInputInventory(this);
|
||||||
|
|
||||||
Optional<TradingRecipe> recipe = getRecipe(this);
|
Optional<TradingRecipe> recipe = getRecipe(this);
|
||||||
@@ -320,33 +312,25 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.resetProgress();
|
this.resetProgress();
|
||||||
this.setChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected boolean canCraftItem() {
|
protected boolean canCraftItem() {
|
||||||
Level level = this.getLevel();
|
|
||||||
if(level == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
SimpleContainer inputInventory = getInputInventory(this);
|
SimpleContainer inputInventory = getInputInventory(this);
|
||||||
|
|
||||||
Optional<TradingRecipe> match = getRecipe(this);
|
Optional<TradingRecipe> match = getRecipe(this);
|
||||||
|
|
||||||
if(match.isEmpty()) {
|
if(!match.isPresent()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//return false;
|
return hasEnoughInputItems(inputInventory, match.get().getIngredients())
|
||||||
return match.isPresent()
|
&& hasEnoughOutputSpace(this.outputItems, match.get().getResultItem());
|
||||||
&& TradingStationBlockEntity.hasEnoughInputItems(inputInventory,match.get().getIngredients())
|
|
||||||
&& TradingStationBlockEntity.hasEnoughOutputSpace(this.outputItems,match.get().getResultItem());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canProcess(ItemStack stack) {
|
private boolean canProcess(ItemStack stack) {
|
||||||
|
|
||||||
return getRecipe(this).isPresent();
|
return getRecipe(this).isPresent();
|
||||||
}
|
}
|
||||||
protected static boolean hasEnoughInputItems(SimpleContainer inventory, NonNullList<Ingredient> ingredients){
|
protected boolean hasEnoughInputItems(SimpleContainer inventory, NonNullList<Ingredient> ingredients){
|
||||||
int enough = 0;
|
int enough = 0;
|
||||||
for(int ingredientIndex = 0; ingredientIndex < ingredients.size();ingredientIndex ++){
|
for(int ingredientIndex = 0; ingredientIndex < ingredients.size();ingredientIndex ++){
|
||||||
Ingredient ingredient = ingredients.get(ingredientIndex);
|
Ingredient ingredient = ingredients.get(ingredientIndex);
|
||||||
@@ -360,7 +344,7 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
|
|||||||
return ingredients.size() == enough;
|
return ingredients.size() == enough;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean hasEnoughOutputSpace(ItemStackHandler stackHandler,ItemStack resultItemStack){
|
protected boolean hasEnoughOutputSpace(ItemStackHandler stackHandler,ItemStack resultItemStack){
|
||||||
return stackHandler.getStackInSlot(0).isEmpty() || stackHandler.getStackInSlot(0).is(resultItemStack.getItem()) && stackHandler.getStackInSlot(0).getMaxStackSize() - stackHandler.getStackInSlot(0).getCount() >= resultItemStack.getCount() ;
|
return stackHandler.getStackInSlot(0).isEmpty() || stackHandler.getStackInSlot(0).is(resultItemStack.getItem()) && stackHandler.getStackInSlot(0).getMaxStackSize() - stackHandler.getStackInSlot(0).getCount() >= resultItemStack.getCount() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,17 +3,15 @@ package com.oierbravo.trading_station.content.trading_station;
|
|||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
|
||||||
public class TradingStationConfig {
|
public class TradingStationConfig {
|
||||||
//public static ForgeConfigSpec.IntValue MELTER_CAPACITY;
|
public static ForgeConfigSpec.IntValue PROGRESS_PER_TICK;
|
||||||
//public static ForgeConfigSpec.IntValue MELTER_FLUID_PER_TICK;
|
|
||||||
|
|
||||||
public static void registerServerConfig(ForgeConfigSpec.Builder COMMON_BUILDER) {
|
public static void registerCommonConfig(ForgeConfigSpec.Builder COMMON_BUILDER) {
|
||||||
/* SERVER_BUILDER.comment("Settings for the trading_station").push("trading_station");
|
COMMON_BUILDER.comment("Settings for the trading_station").push("trading_station");
|
||||||
MELTER_CAPACITY = SERVER_BUILDER
|
PROGRESS_PER_TICK = COMMON_BUILDER
|
||||||
.comment("How much liquid fits into the trading_station, in mB")
|
.comment("How much progress per tick")
|
||||||
.defineInRange("capacity", 1000, 1, Integer.MAX_VALUE);
|
.defineInRange("progressPerTick", 1, 1, Integer.MAX_VALUE);
|
||||||
MELTER_FLUID_PER_TICK = SERVER_BUILDER
|
COMMON_BUILDER.pop();
|
||||||
.comment("How much liquid generates per tick, in mB")
|
|
||||||
.defineInRange("liquidPerTick", 2, 1, Integer.MAX_VALUE);
|
|
||||||
SERVER_BUILDER.pop();*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,25 @@
|
|||||||
package com.oierbravo.trading_station.content.trading_station;
|
package com.oierbravo.trading_station.content.trading_station;
|
||||||
|
|
||||||
import com.oierbravo.trading_station.foundation.gui.AbstractTradingMenu;
|
import com.oierbravo.trading_station.foundation.gui.AbstractTradingMenu;
|
||||||
import com.oierbravo.trading_station.registrate.ModBlocks;
|
import com.oierbravo.trading_station.registrate.TradingStationRegistrate;
|
||||||
import com.oierbravo.trading_station.registrate.ModMenus;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.world.MenuProvider;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.*;
|
import net.minecraft.world.inventory.ContainerData;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.inventory.ContainerLevelAccess;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class TradingStationMenu extends AbstractTradingMenu {
|
public class TradingStationMenu extends AbstractTradingMenu {
|
||||||
protected final int[] outputSlotCoords = {131,38};
|
protected final int[] outputSlotCoords = {131,38};
|
||||||
|
|
||||||
public TradingStationMenu(int pContainerId, Inventory pInv, BlockEntity pBlockEntity, ContainerData pData) {
|
public TradingStationMenu(int pContainerId, Inventory pInv, BlockEntity pBlockEntity, ContainerData pData) {
|
||||||
super(ModMenus.TRADING_STATION.get(), pContainerId, pInv, pBlockEntity, pData);
|
super(TradingStationRegistrate.TRADING_STATION_MENU.get(), pContainerId, pInv, pBlockEntity, pData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TradingStationMenu(int pContainerId, Inventory inventory, FriendlyByteBuf buf) {
|
public TradingStationMenu(int pContainerId, Inventory inventory, FriendlyByteBuf buf) {
|
||||||
super(ModMenus.TRADING_STATION.get(), pContainerId, inventory, buf);
|
super(TradingStationRegistrate.TRADING_STATION_MENU.get(), pContainerId, inventory, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TradingStationMenu factory(@Nullable MenuType<TradingStationMenu> pMenuType, int pContainerId, Inventory inventory, FriendlyByteBuf buf) {
|
public static TradingStationMenu factory(@Nullable MenuType<TradingStationMenu> pMenuType, int pContainerId, Inventory inventory, FriendlyByteBuf buf) {
|
||||||
@@ -35,7 +27,7 @@ public class TradingStationMenu extends AbstractTradingMenu {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(Player pPlayer) {
|
public boolean stillValid(Player pPlayer) {
|
||||||
return stillValid(ContainerLevelAccess.create(level, blockEntity.getBlockPos()), pPlayer, ModBlocks.TRADING_STATION.get());
|
return stillValid(ContainerLevelAccess.create(level, blockEntity.getBlockPos()), pPlayer, TradingStationRegistrate.TRADING_STATION_BLOCK.get());
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int[][] getInputSlotCoords() {
|
public int[][] getInputSlotCoords() {
|
||||||
|
|||||||
@@ -1,39 +1,21 @@
|
|||||||
package com.oierbravo.trading_station.content.trading_station.powered;
|
package com.oierbravo.trading_station.content.trading_station.powered;
|
||||||
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationBlock;
|
import com.oierbravo.trading_station.content.trading_station.TradingStationBlock;
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationBlockEntity;
|
import com.oierbravo.trading_station.registrate.PoweredTradingStationRegistrate;
|
||||||
import com.oierbravo.trading_station.registrate.ModBlockEntities;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.MenuProvider;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
|
||||||
import net.minecraft.world.level.BlockGetter;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.RenderShape;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.StateDefinition;
|
|
||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
|
||||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
||||||
import net.minecraft.world.phys.shapes.Shapes;
|
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
|
||||||
|
|
||||||
|
|
||||||
public class PoweredTradingStationBlock extends TradingStationBlock {
|
public class PoweredTradingStationBlock extends TradingStationBlock {
|
||||||
|
|
||||||
@@ -45,7 +27,7 @@ public class PoweredTradingStationBlock extends TradingStationBlock {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
|
public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
|
||||||
return ModBlockEntities.POWERED_TRADING_STATION.create(pPos, pState);
|
return PoweredTradingStationRegistrate.POWERED_TRADING_STATION_BLOCK_ENTITY.create(pPos, pState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -54,7 +36,7 @@ public class PoweredTradingStationBlock extends TradingStationBlock {
|
|||||||
if(pLevel.isClientSide()) {
|
if(pLevel.isClientSide()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return createTickerHelper(pBlockEntityType, ModBlockEntities.POWERED_TRADING_STATION.get(),
|
return createTickerHelper(pBlockEntityType, PoweredTradingStationRegistrate.POWERED_TRADING_STATION_BLOCK_ENTITY.get(),
|
||||||
(pLevel1, pPos, pState1, pBlockEntity) -> pBlockEntity.tick(pLevel1, pPos, pState1));
|
(pLevel1, pPos, pState1, pBlockEntity) -> pBlockEntity.tick(pLevel1, pPos, pState1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.oierbravo.trading_station.content.trading_station.powered;
|
package com.oierbravo.trading_station.content.trading_station.powered;
|
||||||
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationBlockEntity;
|
import com.oierbravo.trading_station.content.trading_station.TradingStationBlockEntity;
|
||||||
|
import com.oierbravo.trading_station.content.trading_station.TradingStationConfig;
|
||||||
import com.oierbravo.trading_station.foundation.util.ModEnergyStorage;
|
import com.oierbravo.trading_station.foundation.util.ModEnergyStorage;
|
||||||
import com.oierbravo.trading_station.foundation.util.ModLang;
|
import com.oierbravo.trading_station.foundation.util.ModLang;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@@ -38,7 +39,7 @@ public class PoweredTradingStationBlockEntity extends TradingStationBlockEntity
|
|||||||
super(pType, pWorldPosition, pBlockState);
|
super(pType, pWorldPosition, pBlockState);
|
||||||
}
|
}
|
||||||
private ModEnergyStorage createEnergyStorage() {
|
private ModEnergyStorage createEnergyStorage() {
|
||||||
return new ModEnergyStorage(64000, 200) {
|
return new ModEnergyStorage(PoweredTradingStationConfig.ENERGY_CAPACITY.get(), PoweredTradingStationConfig.ENERGY_TRANSFER.get()) {
|
||||||
@Override
|
@Override
|
||||||
public void onEnergyChanged() {
|
public void onEnergyChanged() {
|
||||||
setChanged();
|
setChanged();
|
||||||
@@ -94,11 +95,11 @@ public class PoweredTradingStationBlockEntity extends TradingStationBlockEntity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateProgress() {
|
protected void updateProgress() {
|
||||||
super.updateProgress();
|
this.progress += PoweredTradingStationConfig.PROGRESS_PER_TICK.get();
|
||||||
extractEnergy();
|
extractEnergy();
|
||||||
}
|
}
|
||||||
private void extractEnergy() {
|
private void extractEnergy() {
|
||||||
this.energyStorage.extractEnergy(1000, false);
|
this.energyStorage.extractEnergy(PoweredTradingStationConfig.ENERGY_PER_TICK.get(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -107,7 +108,7 @@ public class PoweredTradingStationBlockEntity extends TradingStationBlockEntity
|
|||||||
if(level == null)
|
if(level == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(this.energyStorage.getEnergyStored() < 1000){
|
if(this.energyStorage.getEnergyStored() < PoweredTradingStationConfig.ENERGY_PER_TICK.get()){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return super.canCraftItem();
|
return super.canCraftItem();
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.oierbravo.trading_station.content.trading_station.powered;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
|
||||||
|
public class PoweredTradingStationConfig {
|
||||||
|
public static ForgeConfigSpec.IntValue PROGRESS_PER_TICK;
|
||||||
|
public static ForgeConfigSpec.IntValue ENERGY_CAPACITY;
|
||||||
|
public static ForgeConfigSpec.IntValue ENERGY_TRANSFER;
|
||||||
|
public static ForgeConfigSpec.IntValue ENERGY_PER_TICK;
|
||||||
|
|
||||||
|
public static void registerCommonConfig(ForgeConfigSpec.Builder COMMON_BUILDER) {
|
||||||
|
COMMON_BUILDER.comment("Settings for the Powered Trading Station").push("powered_trading_station");
|
||||||
|
PROGRESS_PER_TICK = COMMON_BUILDER
|
||||||
|
.comment("How much progress per tick")
|
||||||
|
.defineInRange("progressPerTick", 1, 1, Integer.MAX_VALUE);
|
||||||
|
ENERGY_CAPACITY = COMMON_BUILDER
|
||||||
|
.comment("How much energy capacity has")
|
||||||
|
.defineInRange("energyCapacity", 64000, 1, Integer.MAX_VALUE);
|
||||||
|
ENERGY_TRANSFER = COMMON_BUILDER
|
||||||
|
.comment("How much energy can transfer")
|
||||||
|
.defineInRange("energyTransfer", 200, 1, Integer.MAX_VALUE);
|
||||||
|
ENERGY_PER_TICK = COMMON_BUILDER
|
||||||
|
.comment("How much energy can transfer")
|
||||||
|
.defineInRange("energyPerTick", 1000, 1, Integer.MAX_VALUE);
|
||||||
|
COMMON_BUILDER.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,32 +1,23 @@
|
|||||||
package com.oierbravo.trading_station.content.trading_station.powered;
|
package com.oierbravo.trading_station.content.trading_station.powered;
|
||||||
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.ITradingStationBlockEntity;
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationBlockEntity;
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationMenu;
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationScreen;
|
|
||||||
import com.oierbravo.trading_station.foundation.gui.AbstractTradingMenu;
|
import com.oierbravo.trading_station.foundation.gui.AbstractTradingMenu;
|
||||||
import com.oierbravo.trading_station.registrate.ModBlocks;
|
import com.oierbravo.trading_station.registrate.PoweredTradingStationRegistrate;
|
||||||
import com.oierbravo.trading_station.registrate.ModMenus;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.*;
|
import net.minecraft.world.inventory.ContainerData;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.inventory.ContainerLevelAccess;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class PoweredTradingStationMenu extends AbstractTradingMenu {
|
public class PoweredTradingStationMenu extends AbstractTradingMenu {
|
||||||
public PoweredTradingStationMenu(int pContainerId, Inventory pInv, BlockEntity pBlockEntity, ContainerData pData) {
|
public PoweredTradingStationMenu(int pContainerId, Inventory pInv, BlockEntity pBlockEntity, ContainerData pData) {
|
||||||
super(ModMenus.POWERED_TRADING_STATION.get(), pContainerId, pInv, pBlockEntity, pData);
|
super(PoweredTradingStationRegistrate.POWERED_TRADING_STATION_MENU.get(), pContainerId, pInv, pBlockEntity, pData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoweredTradingStationMenu(int pContainerId, Inventory inventory, FriendlyByteBuf buf) {
|
public PoweredTradingStationMenu(int pContainerId, Inventory inventory, FriendlyByteBuf buf) {
|
||||||
super(ModMenus.POWERED_TRADING_STATION.get(), pContainerId, inventory, buf);
|
super(PoweredTradingStationRegistrate.POWERED_TRADING_STATION_MENU.get(), pContainerId, inventory, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PoweredTradingStationMenu factory(@Nullable MenuType<PoweredTradingStationMenu> pMenuType, int pContainerId, Inventory inventory, FriendlyByteBuf buf) {
|
public static PoweredTradingStationMenu factory(@Nullable MenuType<PoweredTradingStationMenu> pMenuType, int pContainerId, Inventory inventory, FriendlyByteBuf buf) {
|
||||||
@@ -34,7 +25,7 @@ public class PoweredTradingStationMenu extends AbstractTradingMenu {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(Player pPlayer) {
|
public boolean stillValid(Player pPlayer) {
|
||||||
return stillValid(ContainerLevelAccess.create(level, blockEntity.getBlockPos()), pPlayer, ModBlocks.POWERED_TRADING_STATION.get());
|
return stillValid(ContainerLevelAccess.create(level, blockEntity.getBlockPos()), pPlayer, PoweredTradingStationRegistrate.POWERED_TRADING_STATION_BLOCK.get());
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int[][] getInputSlotCoords() {
|
public int[][] getInputSlotCoords() {
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
package com.oierbravo.trading_station.foundation.gui;
|
package com.oierbravo.trading_station.foundation.gui;
|
||||||
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.ITradingStationBlockEntity;
|
import com.oierbravo.trading_station.content.trading_station.ITradingStationBlockEntity;
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationBlockEntity;
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationScreen;
|
|
||||||
import com.oierbravo.trading_station.registrate.ModBlocks;
|
|
||||||
import com.oierbravo.trading_station.registrate.ModMenus;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|||||||
@@ -3,8 +3,12 @@ package com.oierbravo.trading_station.foundation.util;
|
|||||||
import com.oierbravo.trading_station.TradingStation;
|
import com.oierbravo.trading_station.TradingStation;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
public class ModLang {
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class ModLang {
|
||||||
|
public static String asId(String name) {
|
||||||
|
return name.toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
public static Component translate(String key){
|
public static Component translate(String key){
|
||||||
return Component.translatable(TradingStation.MODID + '.' + key);
|
return Component.translatable(TradingStation.MODID + '.' + key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.oierbravo.trading_station.registrate;
|
package com.oierbravo.trading_station.registrate;
|
||||||
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationConfig;
|
import com.oierbravo.trading_station.content.trading_station.TradingStationConfig;
|
||||||
|
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationConfig;
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
@@ -8,8 +9,8 @@ import net.minecraftforge.fml.config.ModConfig;
|
|||||||
//From https://github.com/McJty/TutorialV3/blob/1.19/src/main/java/com/example/tutorialv3/setup/Config.java
|
//From https://github.com/McJty/TutorialV3/blob/1.19/src/main/java/com/example/tutorialv3/setup/Config.java
|
||||||
public class Config {
|
public class Config {
|
||||||
public static void register() {
|
public static void register() {
|
||||||
registerServerConfigs();
|
//registerServerConfigs();
|
||||||
//registerCommonConfigs();
|
registerCommonConfigs();
|
||||||
//registerClientConfigs();
|
//registerClientConfigs();
|
||||||
}
|
}
|
||||||
private static void registerClientConfigs() {
|
private static void registerClientConfigs() {
|
||||||
@@ -19,12 +20,13 @@ public class Config {
|
|||||||
|
|
||||||
private static void registerCommonConfigs() {
|
private static void registerCommonConfigs() {
|
||||||
ForgeConfigSpec.Builder COMMON_BUILDER = new ForgeConfigSpec.Builder();
|
ForgeConfigSpec.Builder COMMON_BUILDER = new ForgeConfigSpec.Builder();
|
||||||
|
TradingStationConfig.registerCommonConfig(COMMON_BUILDER);
|
||||||
|
PoweredTradingStationConfig.registerCommonConfig(COMMON_BUILDER);
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, COMMON_BUILDER.build());
|
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, COMMON_BUILDER.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerServerConfigs() {
|
private static void registerServerConfigs() {
|
||||||
ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder();
|
ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder();
|
||||||
TradingStationConfig.registerServerConfig(SERVER_BUILDER);
|
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SERVER_BUILDER.build());
|
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SERVER_BUILDER.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.oierbravo.trading_station.registrate;
|
||||||
|
|
||||||
|
import com.oierbravo.trading_station.TradingStation;
|
||||||
|
import com.oierbravo.trading_station.content.trading_station.TradingStationBlockRenderer;
|
||||||
|
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationBlock;
|
||||||
|
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationBlockEntity;
|
||||||
|
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationMenu;
|
||||||
|
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationScreen;
|
||||||
|
import com.tterrag.registrate.util.entry.BlockEntityEntry;
|
||||||
|
import com.tterrag.registrate.util.entry.BlockEntry;
|
||||||
|
import com.tterrag.registrate.util.entry.MenuEntry;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
|
import net.minecraftforge.client.model.generators.ConfiguredModel;
|
||||||
|
|
||||||
|
public class MechanicalTradingStationRegistrate {
|
||||||
|
/*public static final BlockEntry<PoweredTradingStationBlock> POWERED_TRADING_STATION_BLOCK = TradingStation.registrate()
|
||||||
|
.block("powered_trading_station", PoweredTradingStationBlock::new)
|
||||||
|
.lang("Powered Trading Station")
|
||||||
|
.blockstate((ctx, prov) ->
|
||||||
|
prov.getVariantBuilder(ctx.getEntry()).forAllStates(state -> {
|
||||||
|
String modelFileName = "trading_station:block/powered_trading_station";
|
||||||
|
if(state.getValue(BlockStateProperties.POWERED))
|
||||||
|
modelFileName += "_powered";
|
||||||
|
return ConfiguredModel.builder().modelFile(prov.models().getExistingFile(ResourceLocation.tryParse(modelFileName)))
|
||||||
|
.rotationY(((int) state.getValue(BlockStateProperties.HORIZONTAL_FACING).toYRot() + 180) % 360).build();
|
||||||
|
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.simpleItem()
|
||||||
|
.blockEntity(PoweredTradingStationBlockEntity::new)
|
||||||
|
.build()
|
||||||
|
.register();
|
||||||
|
|
||||||
|
public static final BlockEntityEntry<PoweredTradingStationBlockEntity> POWERED_TRADING_STATION_BLOCK_ENTITY = TradingStation.registrate()
|
||||||
|
.blockEntity("powered_trading_station", PoweredTradingStationBlockEntity::new)
|
||||||
|
.validBlocks(POWERED_TRADING_STATION_BLOCK)
|
||||||
|
.renderer(() -> TradingStationBlockRenderer::new)
|
||||||
|
.register();
|
||||||
|
|
||||||
|
public static final MenuEntry<PoweredTradingStationMenu> POWERED_TRADING_STATION_MENU = TradingStation.registrate()
|
||||||
|
.menu("powered_trading_station", PoweredTradingStationMenu::factory, () -> PoweredTradingStationScreen::new)
|
||||||
|
.register();*/
|
||||||
|
public static void register() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.oierbravo.trading_station.registrate;
|
|
||||||
|
|
||||||
import com.oierbravo.trading_station.TradingStation;
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationBlockEntity;
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationBlockRenderer;
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationBlockEntity;
|
|
||||||
import com.tterrag.registrate.util.entry.BlockEntityEntry;
|
|
||||||
|
|
||||||
public class ModBlockEntities {
|
|
||||||
public static final BlockEntityEntry<TradingStationBlockEntity> TRADING_STATION = TradingStation.registrate()
|
|
||||||
.blockEntity("trading_station", TradingStationBlockEntity::new)
|
|
||||||
.validBlocks(ModBlocks.TRADING_STATION)
|
|
||||||
.renderer(() -> TradingStationBlockRenderer::new)
|
|
||||||
.register();
|
|
||||||
|
|
||||||
public static final BlockEntityEntry<PoweredTradingStationBlockEntity> POWERED_TRADING_STATION = TradingStation.registrate()
|
|
||||||
.blockEntity("powered_trading_station", PoweredTradingStationBlockEntity::new)
|
|
||||||
.validBlocks(ModBlocks.POWERED_TRADING_STATION)
|
|
||||||
.renderer(() -> TradingStationBlockRenderer::new)
|
|
||||||
.register();
|
|
||||||
public static void register() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,19 +3,20 @@ package com.oierbravo.trading_station.registrate;
|
|||||||
import com.oierbravo.trading_station.TradingStation;
|
import com.oierbravo.trading_station.TradingStation;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
|
||||||
public class ModCreativeTab extends CreativeModeTab {
|
public class ModCreativeTab extends CreativeModeTab {
|
||||||
public static ModCreativeTab MAIN;
|
public static ModCreativeTab MAIN;
|
||||||
|
|
||||||
|
|
||||||
public ModCreativeTab() {
|
public ModCreativeTab() {
|
||||||
super(TradingStation.DISPLAY_NAME);
|
super(TradingStation.MODID);
|
||||||
MAIN = this;
|
MAIN = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack makeIcon() {
|
public ItemStack makeIcon() {
|
||||||
return new ItemStack(ModBlocks.TRADING_STATION.get());
|
return new ItemStack(TradingStationRegistrate.TRADING_STATION_BLOCK.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.oierbravo.trading_station.registrate;
|
|
||||||
|
|
||||||
import com.oierbravo.trading_station.TradingStation;
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationMenu;
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationScreen;
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationMenu;
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationScreen;
|
|
||||||
import com.tterrag.registrate.util.entry.MenuEntry;
|
|
||||||
|
|
||||||
public class ModMenus {
|
|
||||||
public static final MenuEntry<TradingStationMenu> TRADING_STATION = TradingStation.registrate()
|
|
||||||
.menu("trading_station",TradingStationMenu::factory, () -> TradingStationScreen::new)
|
|
||||||
.register();
|
|
||||||
public static final MenuEntry<PoweredTradingStationMenu> POWERED_TRADING_STATION = TradingStation.registrate()
|
|
||||||
.menu("powered_trading_station", PoweredTradingStationMenu::factory, () -> PoweredTradingStationScreen::new)
|
|
||||||
.register();
|
|
||||||
|
|
||||||
public static void register() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -42,6 +42,7 @@ public class ModRecipes {
|
|||||||
|
|
||||||
}
|
}
|
||||||
public static void register(IEventBus eventBus) {
|
public static void register(IEventBus eventBus) {
|
||||||
|
|
||||||
SERIALIZERS.register(eventBus);
|
SERIALIZERS.register(eventBus);
|
||||||
|
|
||||||
RECIPE_TYPES.register(eventBus);
|
RECIPE_TYPES.register(eventBus);
|
||||||
|
|||||||
@@ -1,38 +1,21 @@
|
|||||||
package com.oierbravo.trading_station.registrate;
|
package com.oierbravo.trading_station.registrate;
|
||||||
|
|
||||||
import com.oierbravo.trading_station.TradingStation;
|
import com.oierbravo.trading_station.TradingStation;
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationBlock;
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationBlock;
|
|
||||||
import com.oierbravo.trading_station.content.trading_station.TradingStationBlockEntity;
|
import com.oierbravo.trading_station.content.trading_station.TradingStationBlockEntity;
|
||||||
|
import com.oierbravo.trading_station.content.trading_station.TradingStationBlockRenderer;
|
||||||
|
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationBlock;
|
||||||
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationBlockEntity;
|
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationBlockEntity;
|
||||||
|
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationMenu;
|
||||||
import com.tterrag.registrate.Registrate;
|
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationScreen;
|
||||||
|
import com.tterrag.registrate.util.entry.BlockEntityEntry;
|
||||||
import com.tterrag.registrate.util.entry.BlockEntry;
|
import com.tterrag.registrate.util.entry.BlockEntry;
|
||||||
|
import com.tterrag.registrate.util.entry.MenuEntry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
import net.minecraftforge.client.model.generators.ConfiguredModel;
|
import net.minecraftforge.client.model.generators.ConfiguredModel;
|
||||||
|
|
||||||
public class ModBlocks {
|
public class PoweredTradingStationRegistrate {
|
||||||
private static final Registrate REGISTRATE = TradingStation.registrate()
|
public static final BlockEntry<PoweredTradingStationBlock> POWERED_TRADING_STATION_BLOCK = TradingStation.registrate()
|
||||||
.creativeModeTab(() -> ModCreativeTab.MAIN);
|
|
||||||
public static final BlockEntry<TradingStationBlock> TRADING_STATION = TradingStation.registrate()
|
|
||||||
.block("trading_station", TradingStationBlock::new)
|
|
||||||
.lang("Trading Station")
|
|
||||||
.blockstate((ctx, prov) ->
|
|
||||||
prov.getVariantBuilder(ctx.getEntry()).forAllStates(state -> {
|
|
||||||
String modelFileName = "trading_station:block/trading_station";
|
|
||||||
if(state.getValue(BlockStateProperties.POWERED))
|
|
||||||
modelFileName += "_powered";
|
|
||||||
return ConfiguredModel.builder().modelFile(prov.models().getExistingFile(ResourceLocation.tryParse(modelFileName)))
|
|
||||||
.rotationY(((int) state.getValue(BlockStateProperties.HORIZONTAL_FACING).toYRot() + 180) % 360).build();
|
|
||||||
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.simpleItem()
|
|
||||||
.blockEntity(TradingStationBlockEntity::new)
|
|
||||||
.build()
|
|
||||||
.register();
|
|
||||||
public static final BlockEntry<PoweredTradingStationBlock> POWERED_TRADING_STATION = TradingStation.registrate()
|
|
||||||
.block("powered_trading_station", PoweredTradingStationBlock::new)
|
.block("powered_trading_station", PoweredTradingStationBlock::new)
|
||||||
.lang("Powered Trading Station")
|
.lang("Powered Trading Station")
|
||||||
.blockstate((ctx, prov) ->
|
.blockstate((ctx, prov) ->
|
||||||
@@ -49,6 +32,16 @@ public class ModBlocks {
|
|||||||
.blockEntity(PoweredTradingStationBlockEntity::new)
|
.blockEntity(PoweredTradingStationBlockEntity::new)
|
||||||
.build()
|
.build()
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
|
public static final BlockEntityEntry<PoweredTradingStationBlockEntity> POWERED_TRADING_STATION_BLOCK_ENTITY = TradingStation.registrate()
|
||||||
|
.blockEntity("powered_trading_station", PoweredTradingStationBlockEntity::new)
|
||||||
|
.validBlocks(POWERED_TRADING_STATION_BLOCK)
|
||||||
|
.renderer(() -> TradingStationBlockRenderer::new)
|
||||||
|
.register();
|
||||||
|
|
||||||
|
public static final MenuEntry<PoweredTradingStationMenu> POWERED_TRADING_STATION_MENU = TradingStation.registrate()
|
||||||
|
.menu("powered_trading_station", PoweredTradingStationMenu::factory, () -> PoweredTradingStationScreen::new)
|
||||||
|
.register();
|
||||||
public static void register() {
|
public static void register() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.oierbravo.trading_station.registrate;
|
||||||
|
|
||||||
|
import com.oierbravo.trading_station.TradingStation;
|
||||||
|
import com.oierbravo.trading_station.content.trading_station.*;
|
||||||
|
import com.oierbravo.trading_station.content.trading_station.powered.PoweredTradingStationBlockEntity;
|
||||||
|
import com.tterrag.registrate.Registrate;
|
||||||
|
import com.tterrag.registrate.util.entry.BlockEntityEntry;
|
||||||
|
import com.tterrag.registrate.util.entry.BlockEntry;
|
||||||
|
import com.tterrag.registrate.util.entry.MenuEntry;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
|
import net.minecraftforge.client.model.generators.ConfiguredModel;
|
||||||
|
|
||||||
|
public class TradingStationRegistrate {
|
||||||
|
private static final Registrate REGISTRATE = TradingStation.registrate()
|
||||||
|
.creativeModeTab(() -> ModCreativeTab.MAIN);
|
||||||
|
|
||||||
|
public static final BlockEntry<TradingStationBlock> TRADING_STATION_BLOCK = TradingStation.registrate()
|
||||||
|
.block("trading_station", TradingStationBlock::new)
|
||||||
|
.lang("Trading Station")
|
||||||
|
.blockstate((ctx, prov) ->
|
||||||
|
prov.getVariantBuilder(ctx.getEntry()).forAllStates(state -> {
|
||||||
|
String modelFileName = "trading_station:block/trading_station";
|
||||||
|
if(state.getValue(BlockStateProperties.POWERED))
|
||||||
|
modelFileName += "_powered";
|
||||||
|
return ConfiguredModel.builder().modelFile(prov.models().getExistingFile(ResourceLocation.tryParse(modelFileName)))
|
||||||
|
.rotationY(((int) state.getValue(BlockStateProperties.HORIZONTAL_FACING).toYRot() + 180) % 360).build();
|
||||||
|
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.simpleItem()
|
||||||
|
.blockEntity(TradingStationBlockEntity::new)
|
||||||
|
.build()
|
||||||
|
.register();
|
||||||
|
public static final BlockEntityEntry<TradingStationBlockEntity> TRADING_STATION_BLOCK_ENTITY = REGISTRATE
|
||||||
|
.blockEntity("trading_station", TradingStationBlockEntity::new)
|
||||||
|
.validBlocks(TRADING_STATION_BLOCK)
|
||||||
|
.renderer(() -> TradingStationBlockRenderer::new)
|
||||||
|
.register();
|
||||||
|
|
||||||
|
public static final MenuEntry<TradingStationMenu> TRADING_STATION_MENU = REGISTRATE
|
||||||
|
.menu("trading_station",TradingStationMenu::factory, () -> TradingStationScreen::new)
|
||||||
|
.register();
|
||||||
|
|
||||||
|
public static void register() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 988 B After Width: | Height: | Size: 999 B |
Reference in New Issue
Block a user