Basic Dynamic cell rendering
This commit is contained in:
parent
fb2a5a15b9
commit
8964c5aceb
16 changed files with 241 additions and 45 deletions
57
src/main/java/techreborn/TechRebornClient.java
Normal file
57
src/main/java/techreborn/TechRebornClient.java
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
package techreborn;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
|
||||||
|
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
|
||||||
|
import net.minecraft.client.render.model.BakedModel;
|
||||||
|
import net.minecraft.client.render.model.ModelBakeSettings;
|
||||||
|
import net.minecraft.client.render.model.ModelLoader;
|
||||||
|
import net.minecraft.client.render.model.UnbakedModel;
|
||||||
|
import net.minecraft.client.texture.Sprite;
|
||||||
|
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import techreborn.client.render.DyamicCellBakedModel;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class TechRebornClient implements ClientModInitializer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInitializeClient() {
|
||||||
|
ClientSpriteRegistryCallback.event(SpriteAtlasTexture.BLOCK_ATLAS_TEX)
|
||||||
|
.register((spriteAtlasTexture, registry) -> registry.register(new Identifier("techreborn:item/cell_base")));
|
||||||
|
|
||||||
|
ModelLoadingRegistry.INSTANCE.registerVariantProvider(resourceManager -> (modelIdentifier, modelProviderContext) -> {
|
||||||
|
if(!modelIdentifier.getNamespace().equals("techreborn")){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if(!modelIdentifier.getPath().equals("cell")){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new UnbakedModel() {
|
||||||
|
@Override
|
||||||
|
public Collection<Identifier> getModelDependencies() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Identifier> getTextureDependencies(Function<Identifier, UnbakedModel> function, Set<String> set) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BakedModel bake(ModelLoader modelLoader, Function<Identifier, Sprite> function, ModelBakeSettings modelBakeSettings) {
|
||||||
|
return new DyamicCellBakedModel();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -40,7 +40,7 @@ import techreborn.TechReborn;
|
||||||
import techreborn.init.ModRecipes;
|
import techreborn.init.ModRecipes;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.items.DynamicCell;
|
import techreborn.items.ItemDynamicCell;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@ public class IndustrialCentrifugeBlockEntity extends GenericMachineBlockEntity i
|
||||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||||
return new ContainerBuilder("centrifuge").player(player.inventory).inventory().hotbar()
|
return new ContainerBuilder("centrifuge").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this)
|
.addInventory().blockEntity(this)
|
||||||
.filterSlot(1, 40, 54, stack -> ItemUtils.isItemEqual(stack, DynamicCell.getEmptyCell(1), true, true))
|
.filterSlot(1, 40, 54, stack -> ItemUtils.isItemEqual(stack, ItemDynamicCell.getEmptyCell(1), true, true))
|
||||||
.filterSlot(0, 40, 34, stack -> !ItemUtils.isItemEqual(stack, DynamicCell.getEmptyCell(1), true, true))
|
.filterSlot(0, 40, 34, stack -> !ItemUtils.isItemEqual(stack, ItemDynamicCell.getEmptyCell(1), true, true))
|
||||||
.outputSlot(2, 82, 44).outputSlot(3, 101, 25)
|
.outputSlot(2, 82, 44).outputSlot(3, 101, 25)
|
||||||
.outputSlot(4, 120, 44).outputSlot(5, 101, 63).energySlot(6, 8, 72).syncEnergyValue()
|
.outputSlot(4, 120, 44).outputSlot(5, 101, 63).energySlot(6, 8, 72).syncEnergyValue()
|
||||||
.syncCrafterValue().addInventory().create(this, syncID);
|
.syncCrafterValue().addInventory().create(this, syncID);
|
||||||
|
|
|
@ -37,7 +37,7 @@ import techreborn.TechReborn;
|
||||||
import techreborn.init.ModRecipes;
|
import techreborn.init.ModRecipes;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.items.DynamicCell;
|
import techreborn.items.ItemDynamicCell;
|
||||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||||
|
|
||||||
@RebornRegister(TechReborn.MOD_ID)
|
@RebornRegister(TechReborn.MOD_ID)
|
||||||
|
@ -61,8 +61,8 @@ public class IndustrialElectrolyzerBlockEntity extends GenericMachineBlockEntity
|
||||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||||
return new ContainerBuilder("industrialelectrolyzer").player(player.inventory).inventory().hotbar()
|
return new ContainerBuilder("industrialelectrolyzer").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this)
|
.addInventory().blockEntity(this)
|
||||||
.filterSlot(1, 47, 72, stack -> ItemUtils.isItemEqual(stack, DynamicCell.getEmptyCell(1), true, true))
|
.filterSlot(1, 47, 72, stack -> ItemUtils.isItemEqual(stack, ItemDynamicCell.getEmptyCell(1), true, true))
|
||||||
.filterSlot(0, 81, 72, stack -> !ItemUtils.isItemEqual(stack, DynamicCell.getEmptyCell(1), true, true))
|
.filterSlot(0, 81, 72, stack -> !ItemUtils.isItemEqual(stack, ItemDynamicCell.getEmptyCell(1), true, true))
|
||||||
.outputSlot(2, 51, 24).outputSlot(3, 71, 24).outputSlot(4, 91, 24).outputSlot(5, 111, 24)
|
.outputSlot(2, 51, 24).outputSlot(3, 71, 24).outputSlot(4, 91, 24).outputSlot(5, 111, 24)
|
||||||
.energySlot(6, 8, 72).syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
.energySlot(6, 8, 72).syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
|
|
140
src/main/java/techreborn/client/render/DyamicCellBakedModel.java
Normal file
140
src/main/java/techreborn/client/render/DyamicCellBakedModel.java
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
package techreborn.client.render;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler;
|
||||||
|
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.Renderer;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.RendererAccess;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.material.RenderMaterial;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.mesh.Mesh;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.mesh.MeshBuilder;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.render.model.BakedModel;
|
||||||
|
import net.minecraft.client.render.model.BakedQuad;
|
||||||
|
import net.minecraft.client.render.model.json.ModelItemPropertyOverrideList;
|
||||||
|
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||||
|
import net.minecraft.client.texture.Sprite;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.fluid.Fluid;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import net.minecraft.world.ExtendedBlockView;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class DyamicCellBakedModel implements BakedModel, FabricBakedModel {
|
||||||
|
|
||||||
|
Sprite base;
|
||||||
|
|
||||||
|
public DyamicCellBakedModel() {
|
||||||
|
base = MinecraftClient.getInstance().getSpriteAtlas().getSprite(new Identifier("techreborn:item/cell_base"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void emitBlockQuads(ExtendedBlockView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context) {
|
||||||
|
|
||||||
|
Fluid fluid = null;
|
||||||
|
if(stack.hasTag() && stack.getTag().containsKey("fluid")){
|
||||||
|
fluid = Registry.FLUID.get(new Identifier(stack.getTag().getString("fluid")));
|
||||||
|
}
|
||||||
|
|
||||||
|
context.meshConsumer().accept(getMesh(fluid));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BakedQuad> getQuads(@Nullable BlockState blockState, @Nullable Direction direction, Random random) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
//I have no idea what im doing, this works good enough for me, if you want to make it nicer a PR or tips would be appreciated, thanks.
|
||||||
|
private Mesh getMesh(Fluid fluid){
|
||||||
|
Renderer renderer = RendererAccess.INSTANCE.getRenderer();
|
||||||
|
MeshBuilder builder = renderer.meshBuilder();
|
||||||
|
QuadEmitter emitter = builder.getEmitter();
|
||||||
|
|
||||||
|
RenderMaterial mat = renderer.materialFinder().disableDiffuse(0, true).find();
|
||||||
|
|
||||||
|
//TODO make the base texture 3d somehow
|
||||||
|
emitter.square(Direction.SOUTH, 0, 0, 1, 1, 0)
|
||||||
|
.material(mat)
|
||||||
|
.spriteColor(0, -1, -1, -1, -1)
|
||||||
|
.spriteBake(0, base, MutableQuadView.BAKE_LOCK_UV).emit();
|
||||||
|
|
||||||
|
if(fluid != null){
|
||||||
|
FluidRenderHandler fluidRenderHandler = FluidRenderHandlerRegistry.INSTANCE.get(fluid);
|
||||||
|
if(fluidRenderHandler != null){
|
||||||
|
Sprite fluidSprite = fluidRenderHandler.getFluidSprites(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState())[0];
|
||||||
|
emitter.square(Direction.SOUTH, 0.4F, 0.25F, 0.6F, 0.75F, -0.0001F)
|
||||||
|
.material(mat)
|
||||||
|
.spriteColor(0, -1, -1, -1, -1)
|
||||||
|
.spriteBake(0, fluidSprite, MutableQuadView.BAKE_LOCK_UV).emit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVanillaAdapter() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useAmbientOcclusion() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasDepthInGui() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBuiltin() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Sprite getSprite() {
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModelTransformation getTransformation() {
|
||||||
|
return ModelHelper.HANDHELD_ITEM_TRANSFORMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class ItemProxy extends ModelItemPropertyOverrideList {
|
||||||
|
public ItemProxy() {
|
||||||
|
super(null, null, null, Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BakedModel apply(BakedModel bakedModel, ItemStack itemStack, World world, LivingEntity livingEntity) {
|
||||||
|
return DyamicCellBakedModel.this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModelItemPropertyOverrideList getItemPropertyOverrides() {
|
||||||
|
return new ItemProxy();
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ import techreborn.init.TRArmorMaterial;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
import techreborn.init.TRContent.*;
|
import techreborn.init.TRContent.*;
|
||||||
import techreborn.init.TRToolTier;
|
import techreborn.init.TRToolTier;
|
||||||
import techreborn.items.DynamicCell;
|
import techreborn.items.ItemDynamicCell;
|
||||||
import techreborn.items.ItemFrequencyTransmitter;
|
import techreborn.items.ItemFrequencyTransmitter;
|
||||||
import techreborn.items.ItemManual;
|
import techreborn.items.ItemManual;
|
||||||
import techreborn.items.ItemScrapBox;
|
import techreborn.items.ItemScrapBox;
|
||||||
|
@ -70,7 +70,6 @@ import techreborn.items.tool.vanilla.*;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
|
@ -207,7 +206,7 @@ public class ModRegistry {
|
||||||
RebornRegistry.registerItem(TRContent.SCRAP_BOX = InitUtils.setup(new ItemScrapBox(), "scrap_box"));
|
RebornRegistry.registerItem(TRContent.SCRAP_BOX = InitUtils.setup(new ItemScrapBox(), "scrap_box"));
|
||||||
RebornRegistry.registerItem(TRContent.MANUAL = InitUtils.setup(new ItemManual(), "manual"));
|
RebornRegistry.registerItem(TRContent.MANUAL = InitUtils.setup(new ItemManual(), "manual"));
|
||||||
RebornRegistry.registerItem(TRContent.DEBUG_TOOL = InitUtils.setup(new ItemDebugTool(), "debug_tool"));
|
RebornRegistry.registerItem(TRContent.DEBUG_TOOL = InitUtils.setup(new ItemDebugTool(), "debug_tool"));
|
||||||
RebornRegistry.registerItem(TRContent.CELL = InitUtils.setup(new DynamicCell(), "cell"));
|
RebornRegistry.registerItem(TRContent.CELL = InitUtils.setup(new ItemDynamicCell(), "cell"));
|
||||||
|
|
||||||
TechReborn.LOGGER.debug("TechReborns Items Loaded");
|
TechReborn.LOGGER.debug("TechReborns Items Loaded");
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ public enum ModFluids {
|
||||||
Registry.register(Registry.ITEM, identifier, bucket);
|
Registry.register(Registry.ITEM, identifier, bucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Fluid getFluid() {
|
public RebornFluid getFluid() {
|
||||||
return stillFluid;
|
return stillFluid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ import techreborn.blocks.transformers.BlockLVTransformer;
|
||||||
import techreborn.blocks.transformers.BlockMVTransformer;
|
import techreborn.blocks.transformers.BlockMVTransformer;
|
||||||
import techreborn.config.ConfigTechReborn;
|
import techreborn.config.ConfigTechReborn;
|
||||||
import techreborn.entities.EntityNukePrimed;
|
import techreborn.entities.EntityNukePrimed;
|
||||||
import techreborn.items.DynamicCell;
|
import techreborn.items.ItemDynamicCell;
|
||||||
import techreborn.items.ItemUpgrade;
|
import techreborn.items.ItemUpgrade;
|
||||||
import techreborn.utils.InitUtils;
|
import techreborn.utils.InitUtils;
|
||||||
import techreborn.blockentity.storage.AdjustableSUBlockEntity;
|
import techreborn.blockentity.storage.AdjustableSUBlockEntity;
|
||||||
|
@ -112,7 +112,7 @@ public class TRContent {
|
||||||
public static Item FREQUENCY_TRANSMITTER;
|
public static Item FREQUENCY_TRANSMITTER;
|
||||||
public static Item SCRAP_BOX;
|
public static Item SCRAP_BOX;
|
||||||
public static Item MANUAL;
|
public static Item MANUAL;
|
||||||
public static DynamicCell CELL;
|
public static ItemDynamicCell CELL;
|
||||||
|
|
||||||
// Gem armor & tools
|
// Gem armor & tools
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
package techreborn.init.recipes;
|
package techreborn.init.recipes;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import techreborn.items.DynamicCell;
|
import techreborn.items.ItemDynamicCell;
|
||||||
import techreborn.items.ItemCells;
|
import techreborn.items.ItemCells;
|
||||||
|
|
||||||
import java.security.InvalidParameterException;
|
import java.security.InvalidParameterException;
|
||||||
|
@ -66,20 +66,20 @@ public class DistillationTowerRecipes extends RecipeMethods {
|
||||||
|
|
||||||
int cellCount = 0;
|
int cellCount = 0;
|
||||||
for (ItemStack stack : outputs) {
|
for (ItemStack stack : outputs) {
|
||||||
if (stack.getItem() instanceof DynamicCell) {
|
if (stack.getItem() instanceof ItemDynamicCell) {
|
||||||
cellCount += stack.getCount();
|
cellCount += stack.getCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.getItem() instanceof DynamicCell) {
|
if (input.getItem() instanceof ItemDynamicCell) {
|
||||||
int inputCount = input.getCount();
|
int inputCount = input.getCount();
|
||||||
if (cellCount < inputCount) {
|
if (cellCount < inputCount) {
|
||||||
if (output2 == null) {
|
if (output2 == null) {
|
||||||
output2 = DynamicCell.getEmptyCell(inputCount - cellCount);
|
output2 = ItemDynamicCell.getEmptyCell(inputCount - cellCount);
|
||||||
} else if (output3 == null) {
|
} else if (output3 == null) {
|
||||||
output3 = DynamicCell.getEmptyCell(inputCount - cellCount);
|
output3 = ItemDynamicCell.getEmptyCell(inputCount - cellCount);
|
||||||
} else if (output4 == null) {
|
} else if (output4 == null) {
|
||||||
output4 = DynamicCell.getEmptyCell(inputCount - cellCount);
|
output4 = ItemDynamicCell.getEmptyCell(inputCount - cellCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cellCount -= inputCount;
|
cellCount -= inputCount;
|
||||||
|
@ -92,7 +92,7 @@ public class DistillationTowerRecipes extends RecipeMethods {
|
||||||
if (cellCount > 64) {
|
if (cellCount > 64) {
|
||||||
throw new InvalidParameterException("Invalid Distillation tower outputs: " + outputs + "(Recipe requires > 64 cells)");
|
throw new InvalidParameterException("Invalid Distillation tower outputs: " + outputs + "(Recipe requires > 64 cells)");
|
||||||
}
|
}
|
||||||
cells = DynamicCell.getEmptyCell(cellCount);
|
cells = ItemDynamicCell.getEmptyCell(cellCount);
|
||||||
}
|
}
|
||||||
// RecipeHandler.addRecipe(Reference.DistiLLATION_TOWER_RECIPE, new DistillationTowerRecipe(input, cells, output1, output2, output3, output4, ticks, euPerTick, oreDict));
|
// RecipeHandler.addRecipe(Reference.DistiLLATION_TOWER_RECIPE, new DistillationTowerRecipe(input, cells, output1, output2, output3, output4, ticks, euPerTick, oreDict));
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ package techreborn.init.recipes;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import techreborn.items.DynamicCell;
|
import techreborn.items.ItemDynamicCell;
|
||||||
|
|
||||||
import java.security.InvalidParameterException;
|
import java.security.InvalidParameterException;
|
||||||
|
|
||||||
|
@ -138,22 +138,22 @@ public class IndustrialCentrifugeRecipes extends RecipeMethods {
|
||||||
|
|
||||||
int cellCount = 0;
|
int cellCount = 0;
|
||||||
for (ItemStack stack : outputs) {
|
for (ItemStack stack : outputs) {
|
||||||
if (stack.getItem() instanceof DynamicCell) {
|
if (stack.getItem() instanceof ItemDynamicCell) {
|
||||||
cellCount += stack.getCount();
|
cellCount += stack.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input instanceof ItemStack) {
|
if (input instanceof ItemStack) {
|
||||||
if (((ItemStack) input).getItem() instanceof DynamicCell) {
|
if (((ItemStack) input).getItem() instanceof ItemDynamicCell) {
|
||||||
int inputCount = ((ItemStack) input).getCount();
|
int inputCount = ((ItemStack) input).getCount();
|
||||||
if (cellCount < inputCount) {
|
if (cellCount < inputCount) {
|
||||||
if (output2 == null) {
|
if (output2 == null) {
|
||||||
output2 = DynamicCell.getEmptyCell(inputCount - cellCount);
|
output2 = ItemDynamicCell.getEmptyCell(inputCount - cellCount);
|
||||||
} else if (output3 == null) {
|
} else if (output3 == null) {
|
||||||
output3 = DynamicCell.getEmptyCell(inputCount - cellCount);
|
output3 = ItemDynamicCell.getEmptyCell(inputCount - cellCount);
|
||||||
} else if (output4 == null) {
|
} else if (output4 == null) {
|
||||||
output4 = DynamicCell.getEmptyCell(inputCount - cellCount);
|
output4 = ItemDynamicCell.getEmptyCell(inputCount - cellCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cellCount -= inputCount;
|
cellCount -= inputCount;
|
||||||
|
@ -169,7 +169,7 @@ public class IndustrialCentrifugeRecipes extends RecipeMethods {
|
||||||
if (cellCount > 64) {
|
if (cellCount > 64) {
|
||||||
throw new InvalidParameterException("Invalid industrial centrifuge outputs: " + outputs + "(Recipe requires > 64 cells)");
|
throw new InvalidParameterException("Invalid industrial centrifuge outputs: " + outputs + "(Recipe requires > 64 cells)");
|
||||||
}
|
}
|
||||||
cells = DynamicCell.getEmptyCell(cellCount);
|
cells = ItemDynamicCell.getEmptyCell(cellCount);
|
||||||
}
|
}
|
||||||
//RecipeHandler.addRecipe(Reference.CENTRIFUGE_RECIPE, new CentrifugeRecipe(input, cells, output1, output2, output3, output4, ticks, 5, oreDict));
|
//RecipeHandler.addRecipe(Reference.CENTRIFUGE_RECIPE, new CentrifugeRecipe(input, cells, output1, output2, output3, output4, ticks, 5, oreDict));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
import techreborn.items.DynamicCell;
|
import techreborn.items.ItemDynamicCell;
|
||||||
import techreborn.utils.StackWIPHandler;
|
import techreborn.utils.StackWIPHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,7 +117,7 @@ public class ScrapboxRecipes extends RecipeMethods {
|
||||||
register(getStack(Items.GOLD_NUGGET));
|
register(getStack(Items.GOLD_NUGGET));
|
||||||
register(getStack(Items.SHULKER_SHELL));
|
register(getStack(Items.SHULKER_SHELL));
|
||||||
|
|
||||||
register(DynamicCell.getEmptyCell(1));
|
register(ItemDynamicCell.getEmptyCell(1));
|
||||||
register(getMaterial("water", Type.CELL));
|
register(getMaterial("water", Type.CELL));
|
||||||
register(getMaterial("compressedair", Type.CELL));
|
register(getMaterial("compressedair", Type.CELL));
|
||||||
register(TRContent.Parts.SAP.getStack());
|
register(TRContent.Parts.SAP.getStack());
|
||||||
|
|
|
@ -32,7 +32,7 @@ import techreborn.utils.FluidUtils;
|
||||||
public class ItemCells {
|
public class ItemCells {
|
||||||
public static ItemStack getCellByName(String name, int count) {
|
public static ItemStack getCellByName(String name, int count) {
|
||||||
if (name.equalsIgnoreCase("empty") || name.equalsIgnoreCase("cell")) {
|
if (name.equalsIgnoreCase("empty") || name.equalsIgnoreCase("cell")) {
|
||||||
return DynamicCell.getEmptyCell(count).copy();
|
return ItemDynamicCell.getEmptyCell(count).copy();
|
||||||
}
|
}
|
||||||
Fluid fluid = FluidUtils.getFluid("fluid" + name.toLowerCase());
|
Fluid fluid = FluidUtils.getFluid("fluid" + name.toLowerCase());
|
||||||
if (fluid == null) {
|
if (fluid == null) {
|
||||||
|
@ -42,7 +42,7 @@ public class ItemCells {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Validate.notNull(fluid, "The fluid " + name + " could not be found");
|
Validate.notNull(fluid, "The fluid " + name + " could not be found");
|
||||||
return DynamicCell.getCellWithFluid(fluid, count);
|
return ItemDynamicCell.getCellWithFluid(fluid, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getCellByName(String name) {
|
public static ItemStack getCellByName(String name) {
|
||||||
|
|
|
@ -31,9 +31,11 @@ import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.DefaultedList;
|
import net.minecraft.util.DefaultedList;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
|
import reborncore.common.util.ItemNBTHelper;
|
||||||
import techreborn.TechReborn;
|
import techreborn.TechReborn;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
import techreborn.utils.FluidUtils;
|
import techreborn.utils.FluidUtils;
|
||||||
|
@ -41,11 +43,11 @@ import techreborn.utils.FluidUtils;
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 17/05/2016.
|
* Created by modmuss50 on 17/05/2016.
|
||||||
*/
|
*/
|
||||||
public class DynamicCell extends Item {
|
public class ItemDynamicCell extends Item {
|
||||||
|
|
||||||
public static final int CAPACITY = 1000;
|
public static final int CAPACITY = 1000;
|
||||||
|
|
||||||
public DynamicCell() {
|
public ItemDynamicCell() {
|
||||||
super(new Item.Settings().group(TechReborn.ITEMGROUP));
|
super(new Item.Settings().group(TechReborn.ITEMGROUP));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,13 +67,6 @@ public class DynamicCell extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean tryAddCellToInventory(PlayerEntity player, ItemStack stack, Fluid fluid) {
|
|
||||||
if (player.inventory.insertStack(DynamicCell.getCellWithFluid(fluid))) {
|
|
||||||
stack.decrement(1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendStacks(ItemGroup tab, DefaultedList<ItemStack> subItems) {
|
public void appendStacks(ItemGroup tab, DefaultedList<ItemStack> subItems) {
|
||||||
|
@ -101,7 +96,7 @@ public class DynamicCell extends Item {
|
||||||
public static ItemStack getCellWithFluid(Fluid fluid, int stackSize) {
|
public static ItemStack getCellWithFluid(Fluid fluid, int stackSize) {
|
||||||
Validate.notNull(fluid);
|
Validate.notNull(fluid);
|
||||||
ItemStack stack = new ItemStack(TRContent.CELL);
|
ItemStack stack = new ItemStack(TRContent.CELL);
|
||||||
//getFluidHandler(stack).fill(new FluidStack(fluid, CAPACITY), true);
|
ItemNBTHelper.getNBT(stack).putString("fluid", Registry.FLUID.getId(fluid).toString());
|
||||||
stack.setCount(stackSize);
|
stack.setCount(stackSize);
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
|
@ -31,7 +31,7 @@ import reborncore.api.blockentity.IUpgradeable;
|
||||||
import reborncore.client.gui.builder.GuiBase;
|
import reborncore.client.gui.builder.GuiBase;
|
||||||
import reborncore.client.hud.StackInfoHUD;
|
import reborncore.client.hud.StackInfoHUD;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
import techreborn.items.DynamicCell;
|
import techreborn.items.ItemDynamicCell;
|
||||||
import techreborn.items.ItemFrequencyTransmitter;
|
import techreborn.items.ItemFrequencyTransmitter;
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy {
|
public class ClientProxy extends CommonProxy {
|
||||||
|
@ -56,7 +56,7 @@ public class ClientProxy extends CommonProxy {
|
||||||
// StateMap rubberLeavesStateMap = new StateMap.Builder().ignore(BlockRubberLeaves.CHECK_DECAY, BlockRubberLeaves.DECAYABLE).build();
|
// StateMap rubberLeavesStateMap = new StateMap.Builder().ignore(BlockRubberLeaves.CHECK_DECAY, BlockRubberLeaves.DECAYABLE).build();
|
||||||
// ModelLoader.setCustomStateMapper(TRContent.RUBBER_LEAVES, rubberLeavesStateMap);
|
// ModelLoader.setCustomStateMapper(TRContent.RUBBER_LEAVES, rubberLeavesStateMap);
|
||||||
GuiBase.wrenchStack = new ItemStack(TRContent.WRENCH);
|
GuiBase.wrenchStack = new ItemStack(TRContent.WRENCH);
|
||||||
GuiBase.fluidCellProvider = DynamicCell::getCellWithFluid;
|
GuiBase.fluidCellProvider = ItemDynamicCell::getCellWithFluid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,14 @@ package techreborn.utils;
|
||||||
import io.github.prospector.silk.fluid.FluidInstance;
|
import io.github.prospector.silk.fluid.FluidInstance;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import reborncore.common.util.Tank;
|
import reborncore.common.util.Tank;
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class FluidUtils {
|
public class FluidUtils {
|
||||||
|
|
||||||
|
@ -41,7 +43,7 @@ public class FluidUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Fluid> getAllFluids() {
|
public static List<Fluid> getAllFluids() {
|
||||||
return Collections.emptyList();
|
return Registry.FLUID.stream().collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Fluid getFluid(String name){
|
public static Fluid getFluid(String name){
|
||||||
|
|
|
@ -25,13 +25,13 @@
|
||||||
package techreborn.utils;
|
package techreborn.utils;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import techreborn.items.DynamicCell;
|
import techreborn.items.ItemDynamicCell;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class RecipeUtils {
|
public class RecipeUtils {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static ItemStack getEmptyCell(int stackSize) {
|
public static ItemStack getEmptyCell(int stackSize) {
|
||||||
return DynamicCell.getEmptyCell(stackSize);
|
return ItemDynamicCell.getEmptyCell(stackSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
"techreborn.TechReborn"
|
"techreborn.TechReborn"
|
||||||
|
],
|
||||||
|
"client": [
|
||||||
|
"techreborn.TechRebornClient"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"requires": {
|
"requires": {
|
||||||
|
|
Loading…
Reference in a new issue