Jei, exclusive condition, biome condition, maany more things

This commit is contained in:
2023-08-20 00:07:02 +02:00
parent 79d70e4c50
commit c6c74ec321
37 changed files with 495 additions and 130 deletions

View File

@@ -200,10 +200,10 @@ dependencies {
}
//if (create_enabled.toBoolean()) {
if (create_enabled.toBoolean()) {
implementation fg.deobf("com.simibubi.create:create-${create_minecraft_version}:${create_version}:slim") { transitive = false }
implementation fg.deobf("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}")
//}
}
if (ct_enabled.toBoolean()) {
def minecraftVersion= "net.minecraftforge:forge:${minecraft_version}-${forge_version}"

View File

@@ -3,7 +3,7 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
mod_version=0.0.1
mod_version=0.0.2
modid=trading_station
author=oierbravo
display_name=Trading Station
@@ -28,7 +28,7 @@ registrate_version = MC1.19-1.1.5
jei_minecraft_version = 1.19.2
jei_version = 11.4.0.290
create_enabled = true;
create_enabled = false;
create_minecraft_version = 1.19.2
flywheel_minecraft_version = 1.19.2
create_version = 0.5.1.c-36

View File

@@ -1,9 +1,15 @@
// 1.19.2 2023-08-19T22:34:02.349925986 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)]
d529016ef556a0231f5da8dd90e7b84a30aad7f7 assets/trading_station/blockstates/powered_trading_station.json
// 1.19.2 2023-08-20T05:34:06.144973297 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)]
76015b2093284d49b4645a032a1401ad54416aed assets/trading_station/blockstates/powered_trading_station.json
76015b2093284d49b4645a032a1401ad54416aed assets/trading_station/blockstates/powered_trading_station_unbreakable.json
d529016ef556a0231f5da8dd90e7b84a30aad7f7 assets/trading_station/blockstates/trading_station.json
72f9bf61c9db46a4fefece27497879b91d0290e3 assets/trading_station/lang/en_ud.json
b39694f8daf13daba09feddb32de6f23e9bf20ad assets/trading_station/lang/en_us.json
d529016ef556a0231f5da8dd90e7b84a30aad7f7 assets/trading_station/blockstates/trading_station_unbreakable.json
4a698dd4a98169d92e2307f2f3ecc9276eaa56bd assets/trading_station/lang/en_ud.json
be713c678361dbc9c9f0a45112214a71cf5faae4 assets/trading_station/lang/en_us.json
373be6ce42eee460888161c967f098e5943e3778 assets/trading_station/models/item/powered_trading_station.json
77bf5b94b46ff3ecdfec5e8edff0676571d9ed1b assets/trading_station/models/item/powered_trading_station_unbreakable.json
7ddda578b6d6072db924599a9959579470354897 assets/trading_station/models/item/trading_station.json
84ad64215c6c13c1dbe223941a19b03fbf5dd5e6 assets/trading_station/models/item/trading_station_unbreakable.json
c3b4c04c1cecdc5001fcddda7b30b11b15f0b2b2 data/trading_station/loot_tables/blocks/powered_trading_station.json
305e10b5cc680c810cea1e8e1cc8987fa6957c68 data/trading_station/loot_tables/blocks/powered_trading_station_unbreakable.json
4c82f05fb35c8b26972d5fd3abf4bb5da6cba466 data/trading_station/loot_tables/blocks/trading_station.json
e29db90ad205b2a74c29ed50e8ae52792d9670fe data/trading_station/loot_tables/blocks/trading_station_unbreakable.json

View File

@@ -1,63 +1,63 @@
{
"variants": {
"facing=east,lit=false,powered=false": {
"model": "trading_station:block/trading_station",
"model": "trading_station:block/powered_trading_station",
"y": 90
},
"facing=east,lit=false,powered=true": {
"model": "trading_station:block/trading_station_powered",
"model": "trading_station:block/powered_trading_station_powered",
"y": 90
},
"facing=east,lit=true,powered=false": {
"model": "trading_station:block/trading_station_lit",
"model": "trading_station:block/powered_trading_station_lit",
"y": 90
},
"facing=east,lit=true,powered=true": {
"model": "trading_station:block/trading_station_powered_lit",
"model": "trading_station:block/powered_trading_station_powered_lit",
"y": 90
},
"facing=north,lit=false,powered=false": {
"model": "trading_station:block/trading_station"
"model": "trading_station:block/powered_trading_station"
},
"facing=north,lit=false,powered=true": {
"model": "trading_station:block/trading_station_powered"
"model": "trading_station:block/powered_trading_station_powered"
},
"facing=north,lit=true,powered=false": {
"model": "trading_station:block/trading_station_lit"
"model": "trading_station:block/powered_trading_station_lit"
},
"facing=north,lit=true,powered=true": {
"model": "trading_station:block/trading_station_powered_lit"
"model": "trading_station:block/powered_trading_station_powered_lit"
},
"facing=south,lit=false,powered=false": {
"model": "trading_station:block/trading_station",
"model": "trading_station:block/powered_trading_station",
"y": 180
},
"facing=south,lit=false,powered=true": {
"model": "trading_station:block/trading_station_powered",
"model": "trading_station:block/powered_trading_station_powered",
"y": 180
},
"facing=south,lit=true,powered=false": {
"model": "trading_station:block/trading_station_lit",
"model": "trading_station:block/powered_trading_station_lit",
"y": 180
},
"facing=south,lit=true,powered=true": {
"model": "trading_station:block/trading_station_powered_lit",
"model": "trading_station:block/powered_trading_station_powered_lit",
"y": 180
},
"facing=west,lit=false,powered=false": {
"model": "trading_station:block/trading_station",
"model": "trading_station:block/powered_trading_station",
"y": 270
},
"facing=west,lit=false,powered=true": {
"model": "trading_station:block/trading_station_powered",
"model": "trading_station:block/powered_trading_station_powered",
"y": 270
},
"facing=west,lit=true,powered=false": {
"model": "trading_station:block/trading_station_lit",
"model": "trading_station:block/powered_trading_station_lit",
"y": 270
},
"facing=west,lit=true,powered=true": {
"model": "trading_station:block/trading_station_powered_lit",
"model": "trading_station:block/powered_trading_station_powered_lit",
"y": 270
}
}

View File

@@ -0,0 +1,64 @@
{
"variants": {
"facing=east,lit=false,powered=false": {
"model": "trading_station:block/powered_trading_station",
"y": 90
},
"facing=east,lit=false,powered=true": {
"model": "trading_station:block/powered_trading_station_powered",
"y": 90
},
"facing=east,lit=true,powered=false": {
"model": "trading_station:block/powered_trading_station_lit",
"y": 90
},
"facing=east,lit=true,powered=true": {
"model": "trading_station:block/powered_trading_station_powered_lit",
"y": 90
},
"facing=north,lit=false,powered=false": {
"model": "trading_station:block/powered_trading_station"
},
"facing=north,lit=false,powered=true": {
"model": "trading_station:block/powered_trading_station_powered"
},
"facing=north,lit=true,powered=false": {
"model": "trading_station:block/powered_trading_station_lit"
},
"facing=north,lit=true,powered=true": {
"model": "trading_station:block/powered_trading_station_powered_lit"
},
"facing=south,lit=false,powered=false": {
"model": "trading_station:block/powered_trading_station",
"y": 180
},
"facing=south,lit=false,powered=true": {
"model": "trading_station:block/powered_trading_station_powered",
"y": 180
},
"facing=south,lit=true,powered=false": {
"model": "trading_station:block/powered_trading_station_lit",
"y": 180
},
"facing=south,lit=true,powered=true": {
"model": "trading_station:block/powered_trading_station_powered_lit",
"y": 180
},
"facing=west,lit=false,powered=false": {
"model": "trading_station:block/powered_trading_station",
"y": 270
},
"facing=west,lit=false,powered=true": {
"model": "trading_station:block/powered_trading_station_powered",
"y": 270
},
"facing=west,lit=true,powered=false": {
"model": "trading_station:block/powered_trading_station_lit",
"y": 270
},
"facing=west,lit=true,powered=true": {
"model": "trading_station:block/powered_trading_station_powered_lit",
"y": 270
}
}
}

View File

@@ -0,0 +1,64 @@
{
"variants": {
"facing=east,lit=false,powered=false": {
"model": "trading_station:block/trading_station",
"y": 90
},
"facing=east,lit=false,powered=true": {
"model": "trading_station:block/trading_station_powered",
"y": 90
},
"facing=east,lit=true,powered=false": {
"model": "trading_station:block/trading_station_lit",
"y": 90
},
"facing=east,lit=true,powered=true": {
"model": "trading_station:block/trading_station_powered_lit",
"y": 90
},
"facing=north,lit=false,powered=false": {
"model": "trading_station:block/trading_station"
},
"facing=north,lit=false,powered=true": {
"model": "trading_station:block/trading_station_powered"
},
"facing=north,lit=true,powered=false": {
"model": "trading_station:block/trading_station_lit"
},
"facing=north,lit=true,powered=true": {
"model": "trading_station:block/trading_station_powered_lit"
},
"facing=south,lit=false,powered=false": {
"model": "trading_station:block/trading_station",
"y": 180
},
"facing=south,lit=false,powered=true": {
"model": "trading_station:block/trading_station_powered",
"y": 180
},
"facing=south,lit=true,powered=false": {
"model": "trading_station:block/trading_station_lit",
"y": 180
},
"facing=south,lit=true,powered=true": {
"model": "trading_station:block/trading_station_powered_lit",
"y": 180
},
"facing=west,lit=false,powered=false": {
"model": "trading_station:block/trading_station",
"y": 270
},
"facing=west,lit=false,powered=true": {
"model": "trading_station:block/trading_station_powered",
"y": 270
},
"facing=west,lit=true,powered=false": {
"model": "trading_station:block/trading_station_lit",
"y": 270
},
"facing=west,lit=true,powered=true": {
"model": "trading_station:block/trading_station_powered_lit",
"y": 270
}
}
}

View File

@@ -1,6 +1,8 @@
{
"block.trading_station.powered_trading_station": "uoıʇɐʇS buıpɐɹ⟘ pǝɹǝʍoԀ",
"block.trading_station.powered_trading_station_unbreakable": "uoıʇɐʇS buıpɐɹ⟘ pǝɹǝʍoԀ ǝןqɐʞɐǝɹqu∩",
"block.trading_station.trading_station": "uoıʇɐʇS buıpɐɹ⟘",
"block.trading_station.trading_station_unbreakable": "uoıʇɐʇS buıpɐɹ⟘",
"config.jade.plugin_trading_station.trading_station_data": "ɐʇɐp uoıʇɐʇS buıpɐɹ⟘",
"itemGroup.trading_station": "uoıʇɐʇS buıpɐɹ⟘",
"trading_station.screen.redstone.high": "ɥbıH",

View File

@@ -1,6 +1,8 @@
{
"block.trading_station.powered_trading_station": "Powered Trading Station",
"block.trading_station.powered_trading_station_unbreakable": "Unbreakable Powered Trading Station",
"block.trading_station.trading_station": "Trading Station",
"block.trading_station.trading_station_unbreakable": "Trading Station",
"config.jade.plugin_trading_station.trading_station_data": "Trading Station data",
"itemGroup.trading_station": "Trading Station",
"trading_station.screen.redstone.high": "High",

View File

@@ -0,0 +1,3 @@
{
"parent": "trading_station:block/powered_trading_station_unbreakable"
}

View File

@@ -0,0 +1,3 @@
{
"parent": "trading_station:block/trading_station_unbreakable"
}

View File

@@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "trading_station:powered_trading_station_unbreakable"
}
],
"rolls": 1.0
}
]
}

View File

@@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "trading_station:trading_station_unbreakable"
}
],
"rolls": 1.0
}
]
}

View File

@@ -57,7 +57,6 @@ public class TradingStation
modEventBus.addListener(EventPriority.LOWEST, TradingStation::gatherData);
Mods.CREATE.executeIfInstalled(() -> MechanicalTradingStationRegistrate::register);
}
public static void gatherData(GatherDataEvent event) {
DataGenerator gen = event.getGenerator();

View File

@@ -43,7 +43,9 @@ public class JEIPlugin implements IModPlugin {
@Override
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
registration.addRecipeCatalyst(new ItemStack(TradingStationRegistrate.BLOCK.get()),new RecipeType<>(TradingRecipeCategory.UID, TradingRecipe.class));
registration.addRecipeCatalyst(new ItemStack(TradingStationRegistrate.BLOCK_UNBREAKABLE.get()),new RecipeType<>(TradingRecipeCategory.UID, TradingRecipe.class));
registration.addRecipeCatalyst(new ItemStack(PoweredTradingStationRegistrate.BLOCK.get()),new RecipeType<>(TradingRecipeCategory.UID, TradingRecipe.class));
registration.addRecipeCatalyst(new ItemStack(PoweredTradingStationRegistrate.BLOCK_UNBREAKABLE.get()),new RecipeType<>(TradingRecipeCategory.UID, TradingRecipe.class));
}
@Override
@@ -57,7 +59,7 @@ public class JEIPlugin implements IModPlugin {
@Override
public void registerRecipeTransferHandlers(IRecipeTransferRegistration registration) {
registration.addRecipeTransferHandler(new TradingRecipeHandler(), TRAING_RECIPE);
//registration.addRecipeTransferHandler(new TradingRecipeHandler(), TRAING_RECIPE);
//registration.addRecipeTransferHandler(TradingStationMenu.class, TradingStationRegistrate.MENU.get(), new RecipeType<>(TradingRecipeCategory.UID, TradingRecipe.class), 36, 2, 0, 36);
}

View File

@@ -15,6 +15,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biome;
import javax.annotation.Nullable;
import java.util.ServiceLoader;
public class TradingRecipe implements Recipe<SimpleContainer> {
private final ResourceLocation id;
@@ -38,7 +39,7 @@ public class TradingRecipe implements Recipe<SimpleContainer> {
}
@Override
public boolean matches(SimpleContainer pContainer, Level pLevel) {
return matches(pContainer, pLevel, (Biome) null);
return matches(pContainer, pLevel, (Biome) null, "");
}
public boolean matchesBiome(Biome biome, Level pLevel){
@@ -49,7 +50,7 @@ public class TradingRecipe implements Recipe<SimpleContainer> {
return exclusiveToCondition.test(targetedMachine);
}
public boolean matches(SimpleContainer pContainer, Level pLevel, @Nullable Biome biome) {
public boolean matches(SimpleContainer pContainer, Level pLevel, @Nullable Biome biome, String traderType) {
if(pLevel.isClientSide)
return false;
if(pContainer.getContainerSize() != itemIngredients.size())
@@ -57,6 +58,8 @@ public class TradingRecipe implements Recipe<SimpleContainer> {
if(!getBiomeCondition().test(biome,pLevel))
return false;
if(!getExclusiveToCondition().test(traderType))
return false;
int matchedIngredients = 0;
for (int i = 0; i < itemIngredients.size(); i++) {
@@ -69,10 +72,10 @@ public class TradingRecipe implements Recipe<SimpleContainer> {
}
}
return matchedIngredients == itemIngredients.size();
}
return false;
return matchedIngredients == itemIngredients.size();
}
public boolean matches(SimpleContainer pContainer, Level pLevel, ItemStack preferedOutput){
@@ -133,6 +136,11 @@ public class TradingRecipe implements Recipe<SimpleContainer> {
public RecipeType<?> getType() {
return Type.INSTANCE;
}
public boolean matchesId(ResourceLocation pId) {
return id.equals(pId);
}
public static class Type implements RecipeType<TradingRecipe> {
private Type() { }
public static final Type INSTANCE = new Type();

View File

@@ -4,12 +4,12 @@ import com.oierbravo.trading_station.content.trading_recipe.TradingRecipe;
import com.oierbravo.trading_station.network.packets.ItemStackSyncS2CPacket;
import com.oierbravo.trading_station.registrate.ModRecipes;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.SimpleContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.items.IItemHandler;
@@ -45,6 +45,11 @@ public interface ITradingStationBlockEntity {
String getTraderType();
String getTargetedRecipeId();
void setTargetedRecipeById(ResourceLocation recipeId);
enum REDSTONE_MODES {
IGNORE,
LOW,
@@ -69,7 +74,7 @@ public interface ITradingStationBlockEntity {
SimpleContainer inputInventory = getInputInventory();
if(!getTargetItemHandler().getStackInSlot(0).isEmpty())
return ModRecipes.findByOutput(level,getTargetItemHandler().getStackInSlot(0));
return ModRecipes.find(inputInventory,level, getBiome());
return ModRecipes.find(inputInventory,level, getBiome(), getTraderType());
};
default SimpleContainer getInputInventory(){
int containerSize = 0;

View File

@@ -1,7 +1,6 @@
package com.oierbravo.trading_station.content.trading_station;
import com.oierbravo.trading_station.content.trading_recipe.TradingRecipe;
import com.oierbravo.trading_station.foundation.util.ModLang;
import com.oierbravo.trading_station.network.packets.ItemStackSyncS2CPacket;
import com.oierbravo.trading_station.registrate.ModMessages;
import com.oierbravo.trading_station.registrate.ModRecipes;
@@ -20,7 +19,6 @@ import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.ContainerData;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.Level;
@@ -64,11 +62,14 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
byte currentRedstoneMode = 0;
Optional<TradingRecipe> targetedRecipe;
public TradingStationBlockEntity(BlockEntityType<?> pType, BlockPos pWorldPosition, BlockState pBlockState) {
super(pType, pWorldPosition, pBlockState);
updateTag = getPersistentData();
lastBlockState = this.getBlockState();
containerData = createContainerData();
targetedRecipe = Optional.empty();
}
public ContainerData createContainerData(){
return new ContainerData(){
@@ -223,6 +224,11 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
tag.putInt("trading_station.progress", progress);
tag.putInt("trading_station.maxProgress", maxProgress);
tag.putByte("redstoneMode", currentRedstoneMode);
String targetedRecipeId = "";
if(targetedRecipe.isPresent()){
targetedRecipeId = targetedRecipe.get().getId().toString();
}
tag.putString("targetedRecipeId", targetedRecipeId);
}
@Override
@@ -234,6 +240,7 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
progress = tag.getInt("trading_station.progress");
maxProgress = tag.getInt("trading_station.maxProgress");
currentRedstoneMode = tag.getByte("redstoneMode");
setTargetedRecipeById(tag.getString("targetedRecipeId"));
}
public void drops() {
@@ -421,6 +428,8 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
return "basic";
}
@Override
public Component getDisplayName() {
return Component.translatable("block.trading_station.trading_station");
@@ -441,4 +450,34 @@ public class TradingStationBlockEntity extends BlockEntity implements MenuProvi
return targetItemHandler.getStackInSlot(0);
}
public ItemStackHandler getTargetItemHandler(){ return targetItemHandler;}
@Override
public void setTargetedRecipeById(ResourceLocation recipeId){
Optional<TradingRecipe> recipe = ModRecipes.findById(this.getLevel(),recipeId);
targetedRecipe = recipe;
if(recipe.isPresent()) {
targetItemHandler.setStackInSlot(0,recipe.get().getResultItem());
}
}
public void setTargetedRecipeById(String recipeId){
Optional<TradingRecipe> recipe = ModRecipes.findById(this.getLevel(), recipeId);
targetedRecipe = recipe;
if(recipe.isPresent()) {
targetItemHandler.setStackInSlot(0,recipe.get().getResultItem());
}
setChanged();
}
@Nullable
public Optional<TradingRecipe> getTargetedRecipe(){
return targetedRecipe;
}
@Override
public String getTargetedRecipeId() {
if(!targetedRecipe.isPresent()){
return "";
}
return targetedRecipe.get().getId().toString();
}
}

View File

@@ -27,7 +27,11 @@ public class TradingStationMenu extends AbstractTradingMenu {
}
@Override
public boolean stillValid(Player pPlayer) {
return stillValid(ContainerLevelAccess.create(level, getBlockPos()), pPlayer, TradingStationRegistrate.BLOCK.get());
if(stillValid(ContainerLevelAccess.create(level, getBlockPos()), pPlayer, TradingStationRegistrate.BLOCK.get()))
return true;
if(stillValid(ContainerLevelAccess.create(level, getBlockPos()), pPlayer, TradingStationRegistrate.BLOCK_UNBREAKABLE.get()))
return true;
return false;
}
@Override
public Coords2D[] getInputSlotCoords() {
@@ -37,6 +41,13 @@ public class TradingStationMenu extends AbstractTradingMenu {
};
}
@Override
public Coords2D[] getInputRecipeCoords() {
return new Coords2D[]{
Coords2D.of(19,25),
Coords2D.of(42,25)
};
}
@Override
public Coords2D getOutputSlotCoords() {
return Coords2D.of(131,49);
}

View File

@@ -3,11 +3,12 @@ package com.oierbravo.trading_station.content.trading_station;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.oierbravo.trading_station.TradingStation;
import com.oierbravo.trading_station.content.trading_recipe.TradingRecipe;
import com.oierbravo.trading_station.foundation.util.ModLang;
import com.oierbravo.trading_station.network.packets.GhostItemSyncC2SPacket;
import com.oierbravo.trading_station.network.packets.RecipeSelectC2SPacket;
import com.oierbravo.trading_station.registrate.ModMessages;
import com.oierbravo.trading_station.registrate.ModRecipes;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
@@ -29,8 +30,8 @@ import java.util.List;
public class TradingStationTargetSelectScreen extends Screen {
private static final ResourceLocation TEXTURE = TradingStation.asResource("textures/gui/trade_select.png");
private ITradingStationBlockEntity blockEntity;
private List<ItemStack> allPossibleOutputs;
private LinkedList<ItemStack> displayedItemStacks = new LinkedList<>();
private List<TradingRecipe> allPossibleRecipes;
private LinkedList<TradingRecipe> displayedRecipes = new LinkedList<>();
private float scrollOffset;
@@ -61,7 +62,8 @@ public class TradingStationTargetSelectScreen extends Screen {
this(ModLang.translate("select_target.title"));
this.blockEntity = pBlockEntity;
this.blockPos = pBlockPos;
this.allPossibleOutputs = ModRecipes.getAllOutputs(pBlockEntity.getLevel(),pBlockEntity.getBiome(),pBlockEntity.getTraderType());
//this.allPossibleRecipes = ModRecipes.getAllOutputs(pBlockEntity.getLevel(),pBlockEntity.getBiome(),pBlockEntity.getTraderType());
this.allPossibleRecipes = ModRecipes.getAllRecipesForMachine(pBlockEntity.getLevel(),pBlockEntity.getBiome(),pBlockEntity.getTraderType());
resetDisplayedTargets();
}
@@ -91,11 +93,11 @@ public class TradingStationTargetSelectScreen extends Screen {
public int getGuiTop() { return topPos; }
@Override
public void tick() {
if (displayedItemStacks.size() < MAX_DISPLAYED_RECIPES) {
if (displayedRecipes.size() < MAX_DISPLAYED_RECIPES) {
mouseScrolled(0, 0, 0);
scrollOffset = 0.0f;
}
if (displayedItemStacks.size() <= MAX_DISPLAYED_RECIPES) {
if (displayedRecipes.size() <= MAX_DISPLAYED_RECIPES) {
startIndex = 0;
scrollOffset = 0;
}
@@ -109,8 +111,8 @@ public class TradingStationTargetSelectScreen extends Screen {
int lastDisplayedIndex = startIndex + MAX_DISPLAYED_RECIPES;
renderScrollbar(pPoseStack);
renderSelectedTarget(pPoseStack, pMouseX, pMouseY, lastDisplayedIndex);
renderTargetItems(pPoseStack, pMouseX, pMouseY, lastDisplayedIndex);
renderSelectedRecipe(pPoseStack, pMouseX, pMouseY, lastDisplayedIndex);
renderRecipe(pPoseStack, pMouseX, pMouseY, lastDisplayedIndex);
renderLabels(pPoseStack, pMouseX, pMouseY);
super.render(pPoseStack, pMouseX, pMouseY, pPartialTick);
@@ -118,39 +120,40 @@ public class TradingStationTargetSelectScreen extends Screen {
protected void renderLabels(PoseStack pPoseStack, int pMouseX, int pMouseY) {
this.font.draw(pPoseStack, this.title, (float)this.titleLabelX + getGuiLeft(), (float)this.titleLabelY + getGuiTop(), 4210752);
}
private void renderSelectedTarget(PoseStack pPoseStack, int pMouseX, int pMouseY, int pLastDisplayedIndex) {
LinkedList<ItemStack> displayedRecipes = getDisplayedItemStacks();
ItemStack selectedTarget = this.blockEntity.getTargetItemHandler().getStackInSlot(0);
private void renderSelectedRecipe(PoseStack pPoseStack, int pMouseX, int pMouseY, int pLastDisplayedIndex) {
LinkedList<TradingRecipe> displayedRecipes = getDisplayedRecipes();
for (int index = startIndex; index >= 0 && index < pLastDisplayedIndex && index < displayedRecipes.size(); index++) {
int firstDisplayedIndex = index - startIndex;
ItemStack target = allPossibleOutputs.get(index);
TradingRecipe target = allPossibleRecipes.get(index);
int xStart = getGuiLeft() + targetBoxLeftPosOffset + firstDisplayedIndex % COLUMNS * TARGET_BOX_SIZE + 1;
int yStart = getGuiTop() + targetBoxTopPosOffset + (firstDisplayedIndex / COLUMNS) * TARGET_BOX_SIZE + 3;
if(ItemStack.isSameItemSameTags(selectedTarget, target ))
if(target.getId().toString().equals(this.blockEntity.getTargetedRecipeId()))
blit(pPoseStack, xStart, yStart, 0, imageHeight + 19, TARGET_BOX_SIZE, TARGET_BOX_SIZE);
}
}
private void renderTargetItems(PoseStack pPoseStack, int pMouseX, int pMouseY, int pLastDisplayedIndex) {
LinkedList<ItemStack> displayedRecipes = getDisplayedItemStacks();
private void renderRecipe(PoseStack pPoseStack, int pMouseX, int pMouseY, int pLastDisplayedIndex) {
LinkedList<TradingRecipe> displayedRecipes = getDisplayedRecipes();
for (int index = startIndex; index >= 0 && index < pLastDisplayedIndex && index < displayedRecipes.size(); index++) {
int firstDisplayedIndex = index - startIndex;
ItemStack target = allPossibleOutputs.get(index);
TradingRecipe target = allPossibleRecipes.get(index);
int xStart = getGuiLeft() + targetBoxLeftPosOffset + firstDisplayedIndex % COLUMNS * TARGET_BOX_SIZE + 1;
int yStart = getGuiTop() + targetBoxTopPosOffset + (firstDisplayedIndex / COLUMNS) * TARGET_BOX_SIZE + 3;
renderFloatingItem(target, xStart, yStart );
// if(target.getId().toString().equals(this.blockEntity.getTargetedRecipeId())){
// blit(pPoseStack, xStart, yStart, 0, imageHeight + 19, TARGET_BOX_SIZE, TARGET_BOX_SIZE);
// }
renderFloatingItem(target.getResultItem(), xStart, yStart );
if (pMouseX >= xStart - 1 && pMouseX <= xStart + 16 && pMouseY >= yStart - 1 && pMouseY <= yStart + 16) {
renderTooltip(pPoseStack, target, pMouseX, pMouseY);
renderTooltip(pPoseStack, target.getResultItem(), pMouseX, pMouseY);
}
}
}
private LinkedList<ItemStack> getDisplayedItemStacks() {
return displayedItemStacks;
private LinkedList<TradingRecipe> getDisplayedRecipes() {
return displayedRecipes;
}
private void renderFloatingItem(ItemStack pItemStack, int pX, int pY) {
@@ -192,8 +195,9 @@ public class TradingStationTargetSelectScreen extends Screen {
double boxY = pMouseY - (double)(getGuiTop() + targetBoxTopPosOffset + currentIndex / COLUMNS * TARGET_BOX_SIZE);
if (boxX > 0 && boxX <= TARGET_BOX_SIZE + 1 && boxY > 0 && boxY <= TARGET_BOX_SIZE + 1 && isValidRecipeIndex(index)) {
ItemStack itemStack = getDisplayedItemStacks().get(index);
ModMessages.sendToServer(new GhostItemSyncC2SPacket(itemStack,getBlockPos()));
TradingRecipe recipe = getDisplayedRecipes().get(index);
//ModMessages.sendToServer(new GhostItemSyncC2SPacket(itemStack,getBlockPos()));
ModMessages.sendToServer(new RecipeSelectC2SPacket(recipe.getId(),getBlockPos()));
Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_STONECUTTER_SELECT_RECIPE, 1.0f));
Minecraft.getInstance().popGuiLayer();
return true;
@@ -211,15 +215,15 @@ public class TradingStationTargetSelectScreen extends Screen {
return super.mouseClicked(pMouseX, pMouseY, pButton);
}
private boolean isValidRecipeIndex(int pSlot) {
return pSlot >= 0 && pSlot < getDisplayedItemStacks().size();
return pSlot >= 0 && pSlot < getDisplayedRecipes().size();
}
@Override
public boolean isPauseScreen() {
return false;
}
public void resetDisplayedTargets() {
this.displayedItemStacks.clear();
this.displayedItemStacks.addAll(allPossibleOutputs);
this.displayedRecipes.clear();
this.displayedRecipes.addAll(allPossibleRecipes);
}
@Override
@@ -245,10 +249,10 @@ public class TradingStationTargetSelectScreen extends Screen {
return true;
}
private int getOffscreenRows() {
return (displayedItemStacks.size() + 6 - 1) / 6 - 3;
return (displayedRecipes.size() + 6 - 1) / 6 - 3;
}
private boolean isScrollBarActive() {
return displayedItemStacks.size() > MAX_DISPLAYED_RECIPES;
return displayedRecipes.size() > MAX_DISPLAYED_RECIPES;
}
}

View File

@@ -18,9 +18,9 @@ public class PoweredTradingStationConfig {
.defineInRange("energyCapacity", 64000, 1, Integer.MAX_VALUE);
ENERGY_TRANSFER = COMMON_BUILDER
.comment("How much energy can transfer")
.defineInRange("energyTransfer", 200, 1, Integer.MAX_VALUE);
.defineInRange("energyTransfer", 2000, 1, Integer.MAX_VALUE);
ENERGY_PER_TICK = COMMON_BUILDER
.comment("How much energy can transfer")
.comment("How much energy consumens per tick")
.defineInRange("energyPerTick", 1000, 1, Integer.MAX_VALUE);
COMMON_BUILDER.pop();
}

View File

@@ -26,7 +26,11 @@ public class PoweredTradingStationMenu extends AbstractTradingMenu {
}
@Override
public boolean stillValid(Player pPlayer) {
return stillValid(ContainerLevelAccess.create(level, getBlockPos()), pPlayer, PoweredTradingStationRegistrate.BLOCK.get());
if(stillValid(ContainerLevelAccess.create(level, getBlockPos()), pPlayer, PoweredTradingStationRegistrate.BLOCK.get()))
return true;
if(stillValid(ContainerLevelAccess.create(level, getBlockPos()), pPlayer, PoweredTradingStationRegistrate.BLOCK_UNBREAKABLE.get()))
return true;
return false;
}
@Override
public Coords2D[] getInputSlotCoords() {
@@ -35,6 +39,14 @@ public class PoweredTradingStationMenu extends AbstractTradingMenu {
Coords2D.of(51,47)
};
}
@Override
public Coords2D[] getInputRecipeCoords() {
return new Coords2D[]{
Coords2D.of(28,20),
Coords2D.of(51,20)
};
}
@Override
public Coords2D getOutputSlotCoords() {
return Coords2D.of(131,47);

View File

@@ -55,6 +55,7 @@ public abstract class AbstractTradingMenu extends AbstractContainerMenu {
public abstract Coords2D getOutputSlotCoords();
public abstract Coords2D getTargetSlotCoords();
public abstract Coords2D[] getInputRecipeCoords();
@Override
public abstract boolean stillValid(Player pPlayer);

View File

@@ -4,30 +4,24 @@ import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.oierbravo.trading_station.TradingStation;
import com.oierbravo.trading_station.content.trading_recipe.TradingRecipe;
import com.oierbravo.trading_station.content.trading_station.TradingStationScreen;
import com.oierbravo.trading_station.content.trading_station.TradingStationTargetSelectScreen;
import com.oierbravo.trading_station.foundation.render.FakeItemRenderer;
import com.oierbravo.trading_station.foundation.render.LaserIOItemRenderer;
import com.oierbravo.trading_station.foundation.util.MiscTools;
import com.oierbravo.trading_station.foundation.util.ModLang;
import com.oierbravo.trading_station.foundation.util.MouseUtil;
import com.oierbravo.trading_station.network.packets.GhostItemSyncC2SPacket;
import com.oierbravo.trading_station.network.packets.RedstoneModeSyncC2SPacket;
import com.oierbravo.trading_station.registrate.ModMessages;
import com.oierbravo.trading_station.registrate.ModRecipes;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.Level;
import net.minecraftforge.client.gui.widget.ExtendedButton;
import java.util.HashMap;
@@ -100,15 +94,21 @@ public abstract class AbstractTradingScreen<MENU extends AbstractTradingMenu> ex
private void renderSlotPlaceholder(PoseStack pPoseStack, int pX, int pY){
this.blit(pPoseStack, pX , pY , 0, 164,18, 18);
}
private void renderInputRecipePlaceholder(PoseStack pPoseStack, int pX, int pY){
this.blit(pPoseStack, pX , pY , 18, 146,18, 23);
}
private void renderFakeRecipe(TradingRecipe recipe, PoseStack pPoseStack){
for(int index = 0; index < recipe.getIngredients().size(); index++){
Ingredient ingredient = recipe.getIngredients().get(index);
if(!ingredient.isEmpty())
renderItem(ingredient.getItems()[0],getGuiLeft() + this.menu.getInputSlotCoords()[index].x,getGuiTop() + this.menu.getInputSlotCoords()[index].y);
renderInputRecipePlaceholder(pPoseStack, getGuiLeft() + this.menu.getInputRecipeCoords()[index].x, getGuiTop() + this.menu.getInputRecipeCoords()[index].y);
renderItem(ingredient.getItems()[0],getGuiLeft() + this.menu.getInputRecipeCoords()[index].x + 1,getGuiTop() + this.menu.getInputRecipeCoords()[index].y + 1);
}
renderItem(recipe.getResultItem(),getGuiLeft() + this.menu.getOutputSlotCoords().x,getGuiTop() + this.menu.getOutputSlotCoords().y);
//renderItem(recipe.getResultItem(),getGuiLeft() + this.menu.getOutputSlotCoords().x,getGuiTop() + this.menu.getOutputSlotCoords().y);
}

View File

@@ -0,0 +1,4 @@
package com.oierbravo.trading_station.foundation.gui;
public class RecipeRenderer {
}

View File

@@ -84,7 +84,7 @@ public class FakeItemRenderer {
}
}
private static MultiBufferSource getWrappedBuffer(MultiBufferSource pBufferSource, float pAlpha) {
public static MultiBufferSource getWrappedBuffer(MultiBufferSource pBufferSource, float pAlpha) {
return pRenderType -> new WrappedVertexConsumer(pBufferSource.getBuffer(RenderType.entityTranslucentCull(InventoryMenu.BLOCK_ATLAS)), 1F, 1F, 1F, pAlpha);
}

View File

@@ -1,7 +1,6 @@
package com.oierbravo.trading_station.foundation.util;
import com.oierbravo.trading_station.TradingStation;
import com.simibubi.create.foundation.utility.LangBuilder;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
@@ -19,9 +18,9 @@ public class ModLang {
}
public static Object[] resolveBuilders(Object[] args) {
for (int i = 0; i < args.length; i++)
if (args[i]instanceof LangBuilder cb)
args[i] = cb.component();
// for (int i = 0; i < args.length; i++)
// if (args[i]instanceof LangBuilder cb)
// args[i] = cb.component();
return args;
}
}

View File

@@ -0,0 +1,53 @@
package com.oierbravo.trading_station.network.packets;
import com.oierbravo.trading_station.content.trading_station.ITradingStationBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class RecipeSelectC2SPacket {
private final ResourceLocation recipeId;
private final BlockPos pos;
public RecipeSelectC2SPacket(ResourceLocation recipeId, BlockPos pos) {
this.recipeId = recipeId;
this.pos = pos;
}
public RecipeSelectC2SPacket(FriendlyByteBuf buf) {
this.recipeId = buf.readResourceLocation();
this.pos = buf.readBlockPos();
}
public void toBytes(FriendlyByteBuf buf) {
buf.writeResourceLocation(recipeId);
buf.writeBlockPos(pos);
}
public static void handle(RecipeSelectC2SPacket message, Supplier<NetworkEvent.Context> supplier) {
NetworkEvent.Context context = supplier.get();
context.enqueueWork(() -> {
ServerPlayer sender = context.getSender();
if (sender == null)
return;
AbstractContainerMenu container = sender.containerMenu;
if (container == null)
return;
if(sender.getLevel().getBlockEntity(message.pos) instanceof ITradingStationBlockEntity blockEntity) {
blockEntity.setTargetedRecipeById(message.recipeId);
//blockEntity.setChanged();
}
});
context.setPacketHandled(true);
}
}

View File

@@ -1,47 +0,0 @@
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() {
}
}

View File

@@ -3,6 +3,7 @@ package com.oierbravo.trading_station.registrate;
import com.oierbravo.trading_station.TradingStation;
import com.oierbravo.trading_station.network.packets.GhostItemSyncC2SPacket;
import com.oierbravo.trading_station.network.packets.ItemStackSyncS2CPacket;
import com.oierbravo.trading_station.network.packets.RecipeSelectC2SPacket;
import com.oierbravo.trading_station.network.packets.RedstoneModeSyncC2SPacket;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
@@ -48,6 +49,12 @@ public class ModMessages {
.consumerMainThread(RedstoneModeSyncC2SPacket::handle)
.add();
net.messageBuilder(RecipeSelectC2SPacket.class, id(), NetworkDirection.PLAY_TO_SERVER)
.decoder(RecipeSelectC2SPacket::new)
.encoder(RecipeSelectC2SPacket::toBytes)
.consumerMainThread(RecipeSelectC2SPacket::handle)
.add();
}
public static <MSG> void sendToServer(MSG message) {

View File

@@ -2,6 +2,8 @@ package com.oierbravo.trading_station.registrate;
import com.oierbravo.trading_station.TradingStation;
import com.oierbravo.trading_station.content.trading_recipe.TradingRecipe;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.SimpleContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeSerializer;
@@ -15,6 +17,7 @@ import net.minecraftforge.registries.RegistryObject;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
public class ModRecipes {
@@ -39,10 +42,24 @@ public class ModRecipes {
return Optional.empty();
return pLevel.getRecipeManager().getAllRecipesFor(TradingRecipe.Type.INSTANCE).stream()
.filter((tradingRecipe -> tradingRecipe.matchesBiome(biome, pLevel)))
.findAny();
.findFirst();
}
public static Optional<TradingRecipe> find(SimpleContainer pInv, Level pLevel,@Nullable Biome biome, String traderType) {
if(pLevel.isClientSide())
return Optional.empty();
return pLevel.getRecipeManager().getAllRecipesFor(TradingRecipe.Type.INSTANCE).stream()
.filter((tradingRecipe -> tradingRecipe.matches(pInv, pLevel, biome, traderType)))
.findFirst();
}
public static List<TradingRecipe> getAllRecipesForMachine(Level pLevel, Biome biome, String machineType) {
return pLevel.getRecipeManager().getAllRecipesFor(TradingRecipe.Type.INSTANCE).stream()
.filter((tradingRecipe -> tradingRecipe.matchesBiome(biome, pLevel)))
.filter((tradingRecipe -> tradingRecipe.matchesExclusiveTo(machineType)))
.sorted((recipe1, recipe2) -> recipe1.getId().compareNamespaced(recipe2.getId()))
.toList();
}
public static List<ItemStack> getAllOutputs(Level pLevel,@Nullable Biome biome, String machineType){
return pLevel.getRecipeManager().getAllRecipesFor(TradingRecipe.Type.INSTANCE).stream()
.filter((tradingRecipe -> tradingRecipe.matchesBiome(biome, pLevel)))
@@ -63,4 +80,23 @@ public class ModRecipes {
RECIPE_TYPES.register(eventBus);
}
public static Optional<TradingRecipe> findById(Level pLevel, ResourceLocation recipeId) {
if(pLevel.isClientSide())
return Optional.empty();
return Minecraft.getInstance().level.getRecipeManager(). getAllRecipesFor(TradingRecipe.Type.INSTANCE).stream()
.filter(tradingRecipe -> tradingRecipe.matchesId(recipeId))
.findFirst();
}
public static Optional<TradingRecipe> findById(Level pLevel,String pRecipeId) {
if(pLevel == null)
return Optional.empty();
if(pLevel.isClientSide())
return Optional.empty();
if(Objects.equals(pRecipeId, ""))
return Optional.empty();
ResourceLocation recipeId = ResourceLocation.tryParse(pRecipeId);
return findById(pLevel, recipeId);
}
}

View File

@@ -33,10 +33,30 @@ public class PoweredTradingStationRegistrate {
.blockEntity(PoweredTradingStationBlockEntity::new)
.build()
.register();
public static final BlockEntry<PoweredTradingStationBlock> BLOCK_UNBREAKABLE = TradingStation.registrate()
.block("powered_trading_station_unbreakable", PoweredTradingStationBlock::new)
.lang("Powered Trading Station (Unbreakable)")
.properties((ctx)-> ctx.strength(-1.0f, 3_600_000.0f))
.blockstate((ctx, prov) ->
prov.getVariantBuilder(ctx.getEntry()).forAllStates(state -> {
String modelFileName = "trading_station:block/powered_trading_station";
if(state.getValue(BlockStateProperties.POWERED))
modelFileName += "_powered";
if(state.getValue(BlockStateProperties.LIT))
modelFileName += "_lit";
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> BLOCK_ENTITY = TradingStation.registrate()
.blockEntity("powered_trading_station", PoweredTradingStationBlockEntity::new)
.validBlocks(BLOCK)
.validBlocks(BLOCK, BLOCK_UNBREAKABLE)
.renderer(() -> TradingStationBlockRenderer::new)
.register();

View File

@@ -33,9 +33,29 @@ public class TradingStationRegistrate {
.blockEntity(TradingStationBlockEntity::new)
.build()
.register();
public static final BlockEntry<TradingStationBlock> BLOCK_UNBREAKABLE = TradingStation.registrate()
.block("trading_station_unbreakable", TradingStationBlock::new)
.lang("Trading Station (Unbreakable)")
.properties((ctx)-> ctx.strength(-1.0f, 3_600_000.0f))
.blockstate((ctx, prov) ->
prov.getVariantBuilder(ctx.getEntry()).forAllStates(state -> {
String modelFileName = "trading_station:block/trading_station";
if(state.getValue(BlockStateProperties.POWERED))
modelFileName += "_powered";
if(state.getValue(BlockStateProperties.LIT))
modelFileName += "_lit";
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> BLOCK_ENTITY = REGISTRATE
.blockEntity("trading_station", TradingStationBlockEntity::new)
.validBlocks(BLOCK)
.validBlocks(BLOCK, BLOCK_UNBREAKABLE)
.renderer(() -> TradingStationBlockRenderer::new)
.register();

View File

@@ -3,7 +3,7 @@
"parent": "trading_station:block/trading_station",
"textures": {
"base": "trading_station:block/powered_trading_station",
"back": "trading_station:block/powered_trading_station_base",
"back": "trading_station:block/powered_trading_station_back",
"particle": "trading_station:block/powered_trading_station_base"
}
}

View File

@@ -0,0 +1,4 @@
{
"credit": "Made with Blockbench",
"parent": "trading_station:block/powered_trading_station"
}

View File

@@ -0,0 +1,4 @@
{
"credit": "Made with Blockbench",
"parent": "trading_station:block/trading_station"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB