Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
HbmMods committed Sep 13, 2024
1 parent f806dee commit 2a81e2c
Show file tree
Hide file tree
Showing 8 changed files with 464 additions and 459 deletions.
7 changes: 7 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## Added
* Settings tool
* Allows settings of blocks and machines to be copied
* Uses settings such as conveyor item filters, fluid types and liquid metal types

## Changed
* Most loot piles now have configurable loot pools
* The ntmsatellites command now has the "list" parameter which shows all active satellites in orbit
* Burning in the nether in 528 mode now has a config option, and it no longer affects NPCs

## Fixed
* Fixed some things not using variable max charge for armor mods, like static pads and DNT nanosuit tooltips
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/hbm/explosion/ExplosionNukeGeneric.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import api.hbm.energymk2.IEnergyHandlerMK2;
import cofh.api.energy.IEnergyProvider;

@Spaghetti("this sucks ass")
public class ExplosionNukeGeneric {

private final static Random random = new Random();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/hbm/interfaces/ICopiable.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

public interface ICopiable {

NBTTagCompound getSettings(World world, int x, int y, int z);
NBTTagCompound getSettings(World world, int x, int y, int z);

void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z);
void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z);

default String getSettingsSourceID(Either<TileEntity, Block> self) {
Block block = self.isLeft() ? self.left().getBlockType() : self.right();
Expand Down
767 changes: 382 additions & 385 deletions src/main/java/com/hbm/inventory/recipes/SILEXRecipes.java

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/main/java/com/hbm/items/tool/ItemSettingsTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import com.hbm.handler.HbmKeybinds;
import com.hbm.interfaces.ICopiable;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.PlayerInformPacket;
import com.hbm.packet.toclient.PlayerInformPacket;
import com.hbm.util.ChatBuilder;
import com.hbm.util.Either;
import com.hbm.util.I18nUtil;

import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -17,7 +19,6 @@
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -66,16 +67,15 @@ public void addInformation(ItemStack stack, EntityPlayer player, List list, bool
list.add("Can copy the settings (filters, fluid ID, etc) of machines");
list.add("Shift right-click to copy, right click to paste");
list.add("Ctrl click on pipes to paste settings to multiple pipes");
/*if(stack.stackTagCompound != null) {
if(stack.stackTagCompound != null) {
NBTTagCompound nbt = stack.stackTagCompound;
if (nbt.hasKey("tileName")){
list.add(ChatBuilder.startTranslation(nbt.getString("tileName")).color(EnumChatFormatting.BLUE).flush().getFormattedText());
list.add(EnumChatFormatting.BLUE + I18nUtil.resolveKey(nbt.getString("tileName") + ".name"));
} else {
list.add(EnumChatFormatting.RED + " None ");
}

}*/
//the translation wont fucking work I swear to allah
}
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float fX, float fY, float fZ) {
Expand Down
93 changes: 47 additions & 46 deletions src/main/java/com/hbm/tileentity/IFluidCopiable.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,56 +14,57 @@
import java.util.ArrayList;

public interface IFluidCopiable extends ICopiable {
/**
* @return First type for the normal paste, second type for the alt paste, none if there is no alt paste support
*/
default int[] getFluidIDToCopy(){
IFluidUser tile = (IFluidUser) this;
ArrayList<Integer> types = new ArrayList<>();

/**
* @return First type for the normal paste, second type for the alt paste,
* none if there is no alt paste support
*/
default int[] getFluidIDToCopy() {
IFluidUser tile = (IFluidUser) this;
ArrayList<Integer> types = new ArrayList<>();

for (FluidTank tank : tile.getAllTanks()) {
if (!tank.getTankType().hasNoID())
types.add(tank.getTankType().getID());
}
for(FluidTank tank : tile.getAllTanks()) {
if(!tank.getTankType().hasNoID())
types.add(tank.getTankType().getID());
}

return BobMathUtil.intCollectionToArray(types);
}
return BobMathUtil.intCollectionToArray(types);
}

default FluidTank getTankToPaste(){
TileEntity te = (TileEntity) this;
if (te instanceof IFluidStandardTransceiver) {
IFluidStandardTransceiver tile = (IFluidStandardTransceiver) this;
return tile.getReceivingTanks() != null ? tile.getReceivingTanks()[0] : null;
}
return null;
}
default FluidTank getTankToPaste() {
TileEntity te = (TileEntity) this;
if(te instanceof IFluidStandardTransceiver) {
IFluidStandardTransceiver tile = (IFluidStandardTransceiver) this;
return tile.getReceivingTanks() != null ? tile.getReceivingTanks()[0] : null;
}
return null;
}

@Override
default NBTTagCompound getSettings(World world, int x, int y, int z){
NBTTagCompound tag = new NBTTagCompound();
if(getFluidIDToCopy().length > 0)
tag.setIntArray("fluidID", getFluidIDToCopy());
return tag;
}
@Override
default NBTTagCompound getSettings(World world, int x, int y, int z) {
NBTTagCompound tag = new NBTTagCompound();
if(getFluidIDToCopy().length > 0) tag.setIntArray("fluidID", getFluidIDToCopy());
return tag;
}

@Override
default void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) {
if(getTankToPaste() != null) {
int[] ids = nbt.getIntArray("fluidID");
if(ids.length > 0 && index < ids.length) {
int id = ids[index];
getTankToPaste().setTankType(Fluids.fromID(id));
}
}
}
@Override
default void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) {
if(getTankToPaste() != null) {
int[] ids = nbt.getIntArray("fluidID");
if(ids.length > 0 && index < ids.length) {
int id = ids[index];
getTankToPaste().setTankType(Fluids.fromID(id));
}
}
}

@Override
default String[] infoForDisplay(World world, int x, int y, int z) {
int[] ids = getFluidIDToCopy();
String[] names = new String[ids.length];
for (int i = 0; i < ids.length; i++) {
names[i] = Fluids.fromID(ids[i]).getUnlocalizedName();
}
return names;
}
@Override
default String[] infoForDisplay(World world, int x, int y, int z) {
int[] ids = getFluidIDToCopy();
String[] names = new String[ids.length];
for(int i = 0; i < ids.length; i++) {
names[i] = Fluids.fromID(ids[i]).getUnlocalizedName();
}
return names;
}
}
38 changes: 18 additions & 20 deletions src/main/java/com/hbm/tileentity/IMetalCopiable.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,24 @@
import net.minecraft.world.World;

public interface IMetalCopiable extends ICopiable {
int[] getMatsToCopy();

int[] getMatsToCopy();

@Override
default NBTTagCompound getSettings(World world, int x, int y, int z){
NBTTagCompound tag = new NBTTagCompound();
if(getMatsToCopy().length > 0)
tag.setIntArray("matFilter", getMatsToCopy());
return tag;
}
@Override
default String[] infoForDisplay(World world, int x, int y, int z) {
int[] ids = getMatsToCopy();
String[] names = new String[ids.length];
for (int i = 0; i < ids.length; i++) {
names[i] = Mats.matById.get(ids[i]).getUnlocalizedName();
}
return names;
}
@Override
default void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z){
@Override
default NBTTagCompound getSettings(World world, int x, int y, int z) {
NBTTagCompound tag = new NBTTagCompound();
if(getMatsToCopy().length > 0) tag.setIntArray("matFilter", getMatsToCopy());
return tag;
}

};
@Override
default String[] infoForDisplay(World world, int x, int y, int z) {
int[] ids = getMatsToCopy();
String[] names = new String[ids.length];
for(int i = 0; i < ids.length; i++) names[i] = Mats.matById.get(ids[i]).getUnlocalizedName();
return names;
}

@Override
default void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) { };
}
1 change: 1 addition & 0 deletions src/main/java/com/hbm/util/Either.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
@SuppressWarnings("unchecked")
public final class Either<L, R> {

public static <L, R> Either<L, R> left(L value) {
return new Either<>(value, true);
}
Expand Down

0 comments on commit 2a81e2c

Please sign in to comment.