Skip to content

Commit

Permalink
Renamed "connections" to "fluidConnections" to avoid further confusion.
Browse files Browse the repository at this point in the history
Tweaked meteor showers.
Improved item I/O with the ability to select the first empty/full slot.
Added the Assembler.
Reactivated BTWaila support that was disabled on accident.
  • Loading branch information
MartinSVK12 committed Apr 7, 2024
1 parent f51024e commit c15ce70
Show file tree
Hide file tree
Showing 48 changed files with 1,174 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.core.block.*;
import net.minecraft.core.block.material.Material;
import net.minecraft.core.block.tag.BlockTags;
import net.minecraft.core.data.registry.recipe.RecipeSymbol;
import net.minecraft.core.data.tag.Tag;
import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.item.Item;
Expand Down Expand Up @@ -663,6 +664,15 @@ public class SignalIndustries implements ModInitializer, GameStartEntrypoint {
.setSideTextures("infuser_basic_side_inactive.png")
.build(new BlockInfuser("basic.infuser",config.getInt("BlockIDs.basicInfuser"), Tier.BASIC,Material.metal));

public static final Block basicAssembler = new BlockBuilder(MOD_ID)
.setHardness(1)
.setResistance(3)
.setBlockSound(BlockSounds.METAL)
.setTextures("basic_assembler_side.png")
.setNorthTexture("basic_assembler_front.png")
.build(new BlockAssembler("basic.assembler",config.getInt("BlockIDs.basicAssembler"), Tier.BASIC, Material.metal));


public static final Block basicWrathBeacon = new BlockBuilder(MOD_ID)
.setHardness(2)
.setResistance(500)
Expand Down Expand Up @@ -1246,6 +1256,8 @@ public void onInitialize() {
textures.put(Tier.BASIC.name()+".externalIo",new BlockTexture(MOD_ID).setAll("external_io_blank.png").setTopTexture("external_io_input.png").setBottomTexture("external_io_output.png").setNorthTexture("external_io_both.png"));
textures.put(Tier.REINFORCED.name()+".externalIo",new BlockTexture(MOD_ID).setAll("reinforced_external_io_blank.png").setTopTexture("reinforced_external_io_input.png").setBottomTexture("reinforced_external_io_output.png").setNorthTexture("reinforced_external_io_both.png"));

textures.put(Tier.BASIC.name()+".assembler.active",new BlockTexture(MOD_ID).setAll("basic_assembler_side_active.png").setNorthTexture("basic_assembler_front_active.png"));
textures.put(Tier.BASIC.name()+".assembler.active.overlay",new BlockTexture(MOD_ID).setAll("assembler_overlay_side.png").setNorthTexture("assembler_overlay_front.png"));

textures.put(Tier.REINFORCED.name()+".centrifuge.active",new BlockTexture(MOD_ID).setAll("reinforced_blank.png").setTopTexture("reinforced_centrifuge_closed.png").setNorthTexture("reinforced_centrifuge_front_active.png"));
textures.put(Tier.REINFORCED.name()+".centrifuge.active.overlay",new BlockTexture(MOD_ID).setNorthTexture("centrifuge_overlay.png"));
Expand Down Expand Up @@ -1318,6 +1330,14 @@ public SignalIndustries(){
EntityHelper.Core.createEntity(EntityFallingMeteor.class,50,"fallingMeteor");
EntityHelper.Client.assignEntityRenderer(EntityFallingMeteor.class,new FallingMeteorRenderer());

addEntities();
//crafting recipes in RecipeHandlerCraftingSI

}

//idea got *too smart* recently and now considers anything after accessor stubs "unreachable" due to the throw statement in them that will never be triggered
@SuppressWarnings("UnreachableCode")
private void addEntities(){
EntityHelper.Core.createSpecialTileEntity(TileEntityConduit.class, new RenderFluidInConduit(),"Conduit");

EntityHelper.Core.createSpecialTileEntity(TileEntityFluidConduit.class, new RenderFluidInConduit(),"Fluid Conduit");
Expand Down Expand Up @@ -1364,6 +1384,9 @@ public SignalIndustries(){
EntityHelper.Core.createTileEntity(TileEntityPump.class,"Pump");
addToNameGuiMap("Pump", GuiPump.class, TileEntityCrystalChamber.class);

EntityHelper.Core.createSpecialTileEntity(TileEntityAssembler.class, new RenderAssemblerItemSprite3D(),"Assembler");
addToNameGuiMap("Assembler", GuiAssembler.class, TileEntityAssembler.class);

EntityHelper.Core.createSpecialTileEntity(TileEntityDimensionalAnchor.class,new RenderMultiblock(),"Dimensional Anchor");
addToNameGuiMap("Dimensional Anchor", GuiDimAnchor.class, TileEntityDimensionalAnchor.class);

Expand Down Expand Up @@ -1422,8 +1445,6 @@ public SignalIndustries(){

EntityHelper.Core.createEntity(EntityInfernal.class,config.getInt("EntityIDs.infernalId"),"Infernal");
EntityHelper.Client.assignEntityRenderer(EntityInfernal.class,new MobRenderer<EntityInfernal>(new ModelZombie(),0.5F));
//crafting recipes in RecipeHandlerCraftingSI

}

public static <K,V> Map<K,V> mapOf(K[] keys, V[] values){
Expand Down Expand Up @@ -1540,6 +1561,25 @@ public static ArrayList<ItemStack> condenseList(List<ItemStack> list){
return stacks;
}

public static boolean hasItems(List<RecipeSymbol> symbols, List<ItemStack> available){
symbols.removeIf(Objects::isNull);
List<ItemStack> copy = available.stream().map(ItemStack::copy).collect(Collectors.toList());
int s = 0;
int sReq = (int) symbols.stream().filter(Objects::nonNull).count();
label:
for (RecipeSymbol symbol : symbols) {
for (ItemStack stack : copy) {
if(symbol.matches(stack)){
if(stack == null || stack.stackSize <= 0) continue;
stack.stackSize--;
s++;
continue label;
}
}
}
return s == sReq;
}

public static void usePortal(int dim) {
Minecraft mc = Minecraft.getMinecraft(Minecraft.class);
Dimension lastDim = Dimension.getDimensionList().get(mc.thePlayer.dimension);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public void initTooltip() {
addClass(TileEntitySignalumDynamo.class);
addClass(TileEntityPump.class);
addClass(TileEntityAutoMiner.class);
addClass(TileEntityAssembler.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
import sunsetsatellite.catalyst.core.util.Connection;
import sunsetsatellite.catalyst.core.util.Direction;
import sunsetsatellite.catalyst.fluids.impl.containers.ContainerFluidTank;
import sunsetsatellite.catalyst.fluids.impl.tiles.TileEntityFluidContainer;
import sunsetsatellite.catalyst.fluids.impl.tiles.TileEntityFluidPipe;
import sunsetsatellite.signalindustries.SignalIndustries;
import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered;
import sunsetsatellite.signalindustries.gui.GuiEnergyCell;
import sunsetsatellite.signalindustries.inventories.TileEntityEnergyCell;
import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase;
import sunsetsatellite.signalindustries.util.IOPreview;
import sunsetsatellite.signalindustries.util.Tier;
import turniplabs.halplibe.helper.TextureHelper;
Expand All @@ -41,7 +39,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int
break;
}
case FLUID: {
con = tile.connections.get(dir);
con = tile.fluidConnections.get(dir);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import sunsetsatellite.signalindustries.SignalIndustries;
import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered;
import sunsetsatellite.signalindustries.gui.GuiSIFluidTank;
import sunsetsatellite.signalindustries.inventories.TileEntityEnergyCell;
import sunsetsatellite.signalindustries.inventories.TileEntitySIFluidTank;
import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase;
import sunsetsatellite.signalindustries.util.IOPreview;
import sunsetsatellite.signalindustries.util.Tier;
import turniplabs.halplibe.helper.TextureHelper;
Expand Down Expand Up @@ -46,7 +44,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int
break;
}
case FLUID: {
con = tile.connections.get(dir);
con = tile.fluidConnections.get(dir);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int
break;
}
case FLUID: {
con = tile.connections.get(dir);
con = tile.fluidConnections.get(dir);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package sunsetsatellite.signalindustries.blocks.machines;

import net.minecraft.core.block.entity.TileEntity;
import net.minecraft.core.block.material.Material;
import net.minecraft.core.entity.EntityItem;
import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.util.helper.Side;
import net.minecraft.core.util.helper.Sides;
import net.minecraft.core.world.World;
import net.minecraft.core.world.WorldSource;
import sunsetsatellite.catalyst.core.util.Connection;
import sunsetsatellite.catalyst.core.util.Direction;
import sunsetsatellite.catalyst.fluids.impl.tiles.TileEntityFluidPipe;
import sunsetsatellite.signalindustries.SignalIndustries;
import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered;
import sunsetsatellite.signalindustries.containers.ContainerAssembler;
import sunsetsatellite.signalindustries.gui.GuiAssembler;
import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase;
import sunsetsatellite.signalindustries.inventories.machines.TileEntityAssembler;
import sunsetsatellite.signalindustries.util.IOPreview;
import sunsetsatellite.signalindustries.util.Tier;
import turniplabs.halplibe.helper.TextureHelper;

import java.util.ArrayList;
import java.util.Random;

public class BlockAssembler extends BlockContainerTiered {
public BlockAssembler(String key, int i, Tier tier, Material material) {
super(key, i, tier, material);
hasOverbright = true;
}

@Override
public void onBlockRemoved(World world, int i, int j, int k, int data) {
TileEntityAssembler tile = (TileEntityAssembler) world.getBlockTileEntity(i, j, k);
if (tile != null) {
for (Direction dir : Direction.values()) {
TileEntity tile2 = dir.getTileEntity(world, tile);
if (tile2 instanceof TileEntityFluidPipe) {
tile.unpressurizePipes((TileEntityFluidPipe) tile2, new ArrayList<>());
}
}
Random random = new Random();
for (int l = 0; l < tile.getSizeInventory(); ++l) {
ItemStack itemstack = tile.getStackInSlot(l);
if (itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
float f2 = random.nextFloat() * 0.8F + 0.1F;

while (itemstack.stackSize > 0) {
int i1 = random.nextInt(21) + 10;
if (i1 > itemstack.stackSize) {
i1 = itemstack.stackSize;
}

itemstack.stackSize -= i1;
EntityItem entityitem = new EntityItem(world, (float) i + f, (float) j + f1, (float) k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getMetadata()));
float f3 = 0.05F;
entityitem.xd = (float) random.nextGaussian() * f3;
entityitem.yd = (float) random.nextGaussian() * f3 + 0.2F;
entityitem.zd = (float) random.nextGaussian() * f3;
world.entityJoinedWorld(entityitem);
}
}
}
for (int l = 0; l < tile.template.getSizeInventory(); ++l) {
ItemStack itemstack = tile.template.getStackInSlot(l);
if (itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
float f2 = random.nextFloat() * 0.8F + 0.1F;

while (itemstack.stackSize > 0) {
int i1 = random.nextInt(21) + 10;
if (i1 > itemstack.stackSize) {
i1 = itemstack.stackSize;
}

itemstack.stackSize -= i1;
EntityItem entityitem = new EntityItem(world, (float) i + f, (float) j + f1, (float) k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getMetadata()));
float f3 = 0.05F;
entityitem.xd = (float) random.nextGaussian() * f3;
entityitem.yd = (float) random.nextGaussian() * f3 + 0.2F;
entityitem.zd = (float) random.nextGaussian() * f3;
world.entityJoinedWorld(entityitem);
}
}
}
}

super.onBlockRemoved(world, i, j, k, data);
}

@Override
public int getBlockTexture(WorldSource blockAccess, int x, int y, int z, Side side) {
TileEntityTieredMachineBase tile = (TileEntityTieredMachineBase) blockAccess.getBlockTileEntity(x,y,z);
int meta = blockAccess.getBlockMetadata(x,y,z);
int index = Sides.orientationLookUpHorizontal[6 * meta + side.getId()];
if(tile.isBurning() && tile.tier == tier){
return SignalIndustries.textures.get(tile.tier.name()+".assembler.active").getTexture(Side.getSideById(index));
}
return this.atlasIndices[index];
}

@Override
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
{
if(world.isClientSide)
{
return true;
} else
{
TileEntityAssembler tile = (TileEntityAssembler) world.getBlockTileEntity(i, j, k);
if(tile != null) {
SignalIndustries.displayGui(entityplayer,new GuiAssembler(entityplayer.inventory, tile),new ContainerAssembler(entityplayer.inventory,tile),tile,i,j,k);
}
return true;
}
}

@Override
public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int z, int side) {
TileEntityTieredMachineBase tile = (TileEntityTieredMachineBase) blockAccess.getBlockTileEntity(x,y,z);
if(tile.preview != IOPreview.NONE){
Direction dir = Direction.getDirectionFromSide(side);
Connection con = Connection.NONE;
switch (tile.preview){
case ITEM: {
con = tile.itemConnections.get(dir);
break;
}
case FLUID: {
con = tile.fluidConnections.get(dir);
break;
}
}
switch (con){
case INPUT:
return TextureHelper.getOrCreateBlockTextureIndex(SignalIndustries.MOD_ID,"input_overlay.png");
case OUTPUT:
return TextureHelper.getOrCreateBlockTextureIndex(SignalIndustries.MOD_ID,"output_overlay.png");
case BOTH:
return TextureHelper.getOrCreateBlockTextureIndex(SignalIndustries.MOD_ID,"both_io_overlay.png");
case NONE:
return -1;
}
} else {
int meta = blockAccess.getBlockMetadata(x,y,z);
int index = Sides.orientationLookUpHorizontal[6 * meta + side];
if(tile.isBurning() && tile.tier == tier){
return SignalIndustries.textures.get(tile.tier.name()+".assembler.active.overlay").getTexture(Side.getSideById(index));
}
return -1;
}
return -1;
}

@Override
protected TileEntity getNewBlockEntity() {
return new TileEntityAssembler();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import sunsetsatellite.signalindustries.containers.ContainerAutoMiner;
import sunsetsatellite.signalindustries.gui.GuiAutoMiner;
import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase;
import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineSimple;
import sunsetsatellite.signalindustries.inventories.machines.TileEntityAutoMiner;
import sunsetsatellite.signalindustries.util.IOPreview;
import sunsetsatellite.signalindustries.util.Tier;
Expand All @@ -44,7 +43,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int
break;
}
case FLUID: {
con = tile.connections.get(dir);
con = tile.fluidConnections.get(dir);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered;
import sunsetsatellite.signalindustries.containers.ContainerCentrifuge;
import sunsetsatellite.signalindustries.gui.GuiCentrifuge;
import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase;
import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineSimple;
import sunsetsatellite.signalindustries.inventories.machines.TileEntityCentrifuge;
import sunsetsatellite.signalindustries.util.IOPreview;
Expand Down Expand Up @@ -116,7 +115,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int
break;
}
case FLUID: {
con = tile.connections.get(dir);
con = tile.fluidConnections.get(dir);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered;
import sunsetsatellite.signalindustries.containers.ContainerCrusher;
import sunsetsatellite.signalindustries.gui.GuiCrusher;
import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase;
import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineSimple;
import sunsetsatellite.signalindustries.inventories.machines.TileEntityCrusher;
import sunsetsatellite.signalindustries.util.IOPreview;
Expand Down Expand Up @@ -118,7 +117,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int
break;
}
case FLUID: {
con = tile.connections.get(dir);
con = tile.fluidConnections.get(dir);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered;
import sunsetsatellite.signalindustries.containers.ContainerCrystalChamber;
import sunsetsatellite.signalindustries.gui.GuiCrystalChamber;
import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase;
import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineSimple;
import sunsetsatellite.signalindustries.inventories.machines.TileEntityCrystalChamber;
import sunsetsatellite.signalindustries.util.IOPreview;
Expand Down Expand Up @@ -117,7 +116,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int
break;
}
case FLUID: {
con = tile.connections.get(dir);
con = tile.fluidConnections.get(dir);
break;
}
}
Expand Down
Loading

0 comments on commit c15ce70

Please sign in to comment.