Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matter manipulator compat #3222

Merged
merged 78 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
8be87b1
matter manipulator initial implementation
RecursivePineapple Jul 23, 2024
2a07737
worked on building logic
RecursivePineapple Aug 24, 2024
c8f76d8
worked on placing logic some more
RecursivePineapple Aug 26, 2024
7dab1d1
fixed problem with radial menu
RecursivePineapple Sep 1, 2024
8a794cd
misc fixes
RecursivePineapple Sep 1, 2024
df7896b
fixes for rename
RecursivePineapple Sep 5, 2024
cfd680f
finished AE integration
RecursivePineapple Sep 11, 2024
c1788df
misc polish
RecursivePineapple Sep 11, 2024
10db7ba
worked on block analyzer
RecursivePineapple Sep 11, 2024
1f57966
general polishing
RecursivePineapple Sep 15, 2024
3aa728f
Replaced DirectionUtil with ForgeDirection
RecursivePineapple Sep 15, 2024
efda385
misc fixes
RecursivePineapple Sep 18, 2024
d529846
applied spotless
RecursivePineapple Sep 18, 2024
214538b
moved item & final cleanup
RecursivePineapple Sep 18, 2024
a5f7bb4
Improved AE dismantling
RecursivePineapple Sep 18, 2024
5b66809
worked on the block analyzer & applier
RecursivePineapple Sep 23, 2024
ac8f449
added ae config support
RecursivePineapple Sep 23, 2024
6be7e61
worked on block analysis
RecursivePineapple Sep 26, 2024
a155f69
moved classes to their own files
RecursivePineapple Sep 29, 2024
213551b
got copying working kinda
RecursivePineapple Oct 1, 2024
6fcb5bd
worked on tons of stuff
RecursivePineapple Oct 4, 2024
4b7eb37
applied spotless
RecursivePineapple Oct 4, 2024
e0f2a8a
Added & fixed lots of things
RecursivePineapple Oct 10, 2024
43767f8
item usage estimation & cleanup
RecursivePineapple Oct 16, 2024
1aa66a8
uplink skeleton
RecursivePineapple Oct 16, 2024
8584447
Finished uplink & added moving
RecursivePineapple Oct 18, 2024
9944263
Added meta item 4 & manipulator parts
RecursivePineapple Oct 20, 2024
19050df
Added exchanging + cleanup
RecursivePineapple Oct 20, 2024
759a28c
applied spotless
RecursivePineapple Oct 20, 2024
e1e721b
added recipes for manipulators
RecursivePineapple Oct 20, 2024
1869fae
changed manipulator charge tooltip
RecursivePineapple Oct 20, 2024
4b39762
Misc changes
RecursivePineapple Oct 22, 2024
421c46a
fixed problem with obfuscated field name
RecursivePineapple Oct 22, 2024
0526610
fix rebase error
RecursivePineapple Oct 23, 2024
3083bd4
misc cleanup
RecursivePineapple Oct 24, 2024
df4a556
Added cable mode + misc fixes
RecursivePineapple Oct 24, 2024
9048a37
Various fixes
RecursivePineapple Oct 30, 2024
9832797
added new textures & tweaked recipes
RecursivePineapple Oct 30, 2024
2e008cc
applied spotless
RecursivePineapple Oct 30, 2024
9624510
fixed ender io conduits getting deleted
RecursivePineapple Oct 30, 2024
cdc8979
Misc fixes & changes
RecursivePineapple Oct 31, 2024
2025873
Fixed several minor issues
RecursivePineapple Nov 1, 2024
b309bf1
THE GREAT COMMENTING + misc fixes
RecursivePineapple Nov 1, 2024
8f9c4f4
Fix getWorld returning null on MP clients
RecursivePineapple Nov 3, 2024
41802b9
Fixed NPE when cell doesn't have upgrades
RecursivePineapple Nov 4, 2024
f596201
Fixed torch/redstone/repeater placing
RecursivePineapple Nov 4, 2024
5247ab3
Fixed crash on server
RecursivePineapple Nov 4, 2024
d11092c
Added crash mitigation
RecursivePineapple Nov 4, 2024
f40d76d
Added ME output bus/hatch support
RecursivePineapple Nov 8, 2024
564e14a
Fixed several minor issues
RecursivePineapple Nov 9, 2024
9bb8307
Fixed drawers & added infra. for rotation hacks
RecursivePineapple Nov 9, 2024
74de4da
fixed incorrect recipe & halved MKIII build speed
RecursivePineapple Nov 20, 2024
e495442
added ore voiding
RecursivePineapple Nov 21, 2024
72c1d25
added arraying
RecursivePineapple Nov 21, 2024
c06cf95
improved arraying
RecursivePineapple Nov 22, 2024
8553007
added rotation/flipping
RecursivePineapple Nov 26, 2024
aee67ec
tectech input parameters
RecursivePineapple Nov 26, 2024
65fbb1b
Moved most manipulator code to new mod
RecursivePineapple Dec 1, 2024
13d83f2
Fixed cables connecting to air
RecursivePineapple Dec 2, 2024
e90d48d
Added temporary fake items
RecursivePineapple Dec 2, 2024
490b978
Revert "Fixed cables connecting to air"
RecursivePineapple Dec 2, 2024
1bcf8aa
Removed old files & code
RecursivePineapple Dec 2, 2024
65a5197
Merge branch 'master' into matter-manipulator
Dream-Master Dec 9, 2024
08acd6b
Merge branch 'master' into matter-manipulator
Dream-Master Dec 9, 2024
dab6bfd
removed temp items
RecursivePineapple Dec 10, 2024
d837987
Merge branch 'master' into matter-manipulator
Dream-Master Dec 10, 2024
32a6420
Remove pointless multi registration mechanism
RecursivePineapple Dec 17, 2024
0cdc953
Merge branch 'matter-manipulator' of github-recursive:RecursivePineap…
RecursivePineapple Dec 17, 2024
19f04e6
Merge branch 'master' into matter-manipulator
Dream-Master Dec 21, 2024
6f3d4fa
Merge branch 'master' into matter-manipulator
Dream-Master Dec 21, 2024
e1ac93d
Merge branch 'master' into matter-manipulator
Dream-Master Dec 22, 2024
f84514c
move IMetaTileEntityPipe to MetaPipeEntity
RecursivePineapple Dec 22, 2024
cd04663
fixed redstone strong output
RecursivePineapple Dec 22, 2024
346da99
Merge branch 'master' into matter-manipulator
Dream-Master Dec 22, 2024
48e8000
remove interface from MetaPipeEntity
RecursivePineapple Dec 22, 2024
39f12d9
Merge branch 'master' into matter-manipulator
Dream-Master Dec 23, 2024
96bd8a6
Merge branch 'master' into matter-manipulator
serenibyss Dec 27, 2024
9167e11
Merge branch 'master' into matter-manipulator
serenibyss Dec 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/gregtech/api/enums/MetaTileEntityIDs.java
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,8 @@ public enum MetaTileEntityIDs {
SOLAR_PANEL_LuV(2736),
SOLAR_PANEL_ZPM(2737),
SOLAR_PANEL_UV(2738),
MATTER_MANIPULATOR_UPLINK(2750),
HATCH_MATTER_MANIPULATOR_UPLINK_ME(2751),
INDUSTRIAL_LASER_ENGRAVER_CONTROLLER(3004),
INDUSTRIAL_COMPRESSOR_CONTROLLER(3005),
HIP_COMPRESSOR_CONTROLLER(3006),
Expand Down
51 changes: 51 additions & 0 deletions src/main/java/gregtech/api/enums/OrePrefixes.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.List;

import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

import com.google.common.collect.ImmutableList;

Expand All @@ -25,7 +26,10 @@
import gregtech.api.objects.MaterialStack;
import gregtech.api.util.GTLog;
import gregtech.api.util.GTUtility;
import gregtech.api.util.GTUtility.ItemId;
import gregtech.loaders.materialprocessing.ProcessingModSupport;
import it.unimi.dsi.fastutil.Pair;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet;
import it.unimi.dsi.fastutil.objects.ObjectSet;

Expand Down Expand Up @@ -1184,6 +1188,53 @@ public static String stripPrefix(String aOre) {
return aOre;
}

public static Pair<OrePrefixes, String> detectPrefix(String oredictName) {
for (OrePrefixes prefix : values()) {
if (oredictName.startsWith(prefix.name())) {
return Pair.of(
prefix,
oredictName.substring(
prefix.name()
.length()));
}
}

return null;
}

private static final ThreadLocal<Object2ObjectLinkedOpenHashMap<ItemId, ImmutableList<Pair<OrePrefixes, String>>>> PREFIX_CACHE = ThreadLocal
.withInitial(Object2ObjectLinkedOpenHashMap::new);

public static ImmutableList<Pair<OrePrefixes, String>> detectPrefix(ItemStack stack) {
serenibyss marked this conversation as resolved.
Show resolved Hide resolved
Object2ObjectLinkedOpenHashMap<ItemId, ImmutableList<Pair<OrePrefixes, String>>> cache = PREFIX_CACHE.get();

ItemId itemId = ItemId.create(stack);

var cacheResult = cache.getAndMoveToFirst(itemId);

if (cacheResult != null) return cacheResult;

ImmutableList.Builder<Pair<OrePrefixes, String>> result = ImmutableList.builder();

for (int id : OreDictionary.getOreIDs(stack)) {
Pair<OrePrefixes, String> p = detectPrefix(OreDictionary.getOreName(id));

if (p != null) {
result.add(p);
}
}

ImmutableList<Pair<OrePrefixes, String>> prefixes = result.build();

cache.putAndMoveToFirst(itemId, prefixes);

while (cache.size() > 1024) {
cache.removeLast();
}

return prefixes;
}

public static String replacePrefix(String aOre, OrePrefixes aPrefix) {
for (OrePrefixes tPrefix : values()) {
if (aOre.startsWith(tPrefix.toString())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public interface ICoverable extends IRedstoneTileEntity, IHasInventory, IBasicEn

boolean dropCover(ForgeDirection side, ForgeDirection droppedSide, boolean aForced);

default ItemStack removeCoverAtSide(ForgeDirection side, boolean aForced) {
return null;
}

@Deprecated
void setCoverDataAtSide(ForgeDirection side, int aData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@ public interface IRedstoneEmitter extends IHasWorldObjectAndCoords {
*/
void setStrongOutputRedstoneSignal(ForgeDirection side, byte aStrength);

/**
* Sets the strength of the redstone signal on the given side to strong or weak.
* Does not change the actual signal.
*
* @param side Must not be UNKNOWN
* @param isStrong True = strong, false = weak
*/
default void setRedstoneOutputStrength(ForgeDirection side, boolean isStrong) {}
RecursivePineapple marked this conversation as resolved.
Show resolved Hide resolved

/**
* Checks if the given side will output a strong redstone signal when emitting a redstone signal.
*
* @param side Must not be UNKNOWN
* @return True = strong signal, false = weak signal
*/
default boolean getRedstoneOutputStrength(ForgeDirection side) {
return false;
}

/**
* Gets the Output for the comparator on the given Side
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,10 @@ public void generatePowerNodes() {
}
}

public void setCableUpdateDelay(int delay) {
cableUpdateDelay = delay;
}

@Override
public long getOutputAmperage() {
if (canAccessData() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxAmperesOut();
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,21 @@ public boolean dropCover(ForgeDirection side, ForgeDirection droppedSide, boolea
return true;
}

@Override
public ItemStack removeCoverAtSide(ForgeDirection side, boolean aForced) {
final CoverInfo coverInfo = getCoverInfoAtSide(side);
if (!coverInfo.isValid()) return null;
if (!coverInfo.onCoverRemoval(aForced) && !aForced) return null;
final ItemStack tStack = coverInfo.getDrop();
if (tStack != null) {
coverInfo.onDropped();
}
clearCoverInfoAtSide(side);
updateOutputRedstoneSignal(side);

return tStack;
}

protected void onBaseTEDestroyed() {
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
final CoverInfo coverInfo = getCoverInfoAtSide(side);
Expand All @@ -446,6 +461,21 @@ public void setStrongOutputRedstoneSignal(ForgeDirection side, byte strength) {
setOutputRedstoneSignal(side, strength);
}

@Override
public void setRedstoneOutputStrength(ForgeDirection side, boolean isStrong) {
if (isStrong) {
mStrongRedstone |= (byte) side.flag;
} else {
mStrongRedstone &= ~(byte) side.flag;
}
setOutputRedstoneSignal(side, mSidedRedstone[side.ordinal()]);
}

@Override
public boolean getRedstoneOutputStrength(ForgeDirection side) {
return (mStrongRedstone & side.flag) != 0;
}

@Override
public void setInternalOutputRedstoneSignal(ForgeDirection side, byte aStrength) {
if (!getCoverBehaviorAtSideNew(side)
Expand Down
134 changes: 133 additions & 1 deletion src/main/java/gregtech/api/util/GTUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.oredict.OreDictionary;

import org.joml.Vector3i;

import com.google.auto.value.AutoValue;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -4516,6 +4518,14 @@ public static int clamp(int val, int lo, int hi) {
return MathHelper.clamp_int(val, lo, hi);
}

public static int min(int first, int... rest) {
for (int i = 0; i < rest.length; i++) {
int l = rest[i];
if (l < first) first = l;
}
return first;
}

public static long min(long first, long... rest) {
for (int i = 0; i < rest.length; i++) {
long l = rest[i];
Expand All @@ -4524,6 +4534,14 @@ public static long min(long first, long... rest) {
return first;
}

public static int max(int first, int... rest) {
for (int i = 0; i < rest.length; i++) {
int l = rest[i];
if (l > first) first = l;
}
return first;
}

public static long max(long first, long... rest) {
for (int i = 0; i < rest.length; i++) {
long l = rest[i];
Expand All @@ -4536,10 +4554,41 @@ public static int ceilDiv(int lhs, int rhs) {
return (lhs + rhs - 1) / rhs;
}

/** Handles negatives properly, but it's slower than {@link #ceilDiv(int, int)}. */
public static int ceilDiv2(int lhs, int rhs) {
int sign = signum(lhs) * signum(rhs);

if (lhs == 0) return 0;
if (rhs == 0) throw new ArithmeticException("/ by zero");

lhs = Math.abs(lhs);
rhs = Math.abs(rhs);

int unsigned = 1 + ((lhs - 1) / rhs);

return unsigned * sign;
}

public static long ceilDiv(long lhs, long rhs) {
return (lhs + rhs - 1) / rhs;
}

public static int signum(int x) {
return x < 0 ? -1 : x > 0 ? 1 : 0;
}

public static long signum(long x) {
return x < 0 ? -1 : x > 0 ? 1 : 0;
}

public static Vector3i signum(Vector3i v) {
v.x = signum(v.x);
v.y = signum(v.y);
v.z = signum(v.z);

return v;
}

/**
* Hash an item stack for the purpose of storing hash across launches
*/
Expand Down Expand Up @@ -4781,6 +4830,14 @@ public static ItemId createAsWildcard(ItemStack itemStack) {
return new AutoValue_GTUtility_ItemId(itemStack.getItem(), W, null, null);
}

public static ItemId createAsWildcardWithNBT(ItemStack itemStack) {
NBTTagCompound nbt = itemStack.getTagCompound();
if (nbt != null) {
nbt = (NBTTagCompound) nbt.copy();
}
return new AutoValue_GTUtility_ItemId(itemStack.getItem(), W, nbt, null);
}

/**
* This method stores NBT as null.
*/
Expand Down Expand Up @@ -4839,9 +4896,84 @@ public NBTTagCompound writeToNBT() {
@Nonnull
public ItemStack getItemStack() {
ItemStack itemStack = new ItemStack(item(), 1, metaData());
itemStack.setTagCompound(nbt());
NBTTagCompound nbt = nbt();
itemStack.setTagCompound(nbt == null ? null : (NBTTagCompound) nbt.copy());
return itemStack;
}

@Nonnull
public ItemStack getItemStack(int stackSize) {
ItemStack itemStack = new ItemStack(item(), stackSize, metaData());
NBTTagCompound nbt = nbt();
itemStack.setTagCompound(nbt == null ? null : (NBTTagCompound) nbt.copy());
return itemStack;
}
}

@AutoValue
public abstract static class FluidId {

public static FluidId create(NBTTagCompound tag) {
return new AutoValue_GTUtility_FluidId(
FluidRegistry.getFluid(tag.getString("FluidName")),
tag.hasKey("Tag", Constants.NBT.TAG_COMPOUND) ? tag.getCompoundTag("Tag") : null,
tag.hasKey("Amount", Constants.NBT.TAG_INT) ? tag.getInteger("Amount") : null);
}

public NBTTagCompound writeToNBT() {
NBTTagCompound tag = new NBTTagCompound();
tag.setString("FluidName", fluid().getName());
if (nbt() != null) tag.setTag("Tag", nbt());
Integer amount = amount();
if (amount != null) tag.setInteger("Amount", amount);
return tag;
}

public static FluidId create(FluidStack fluidStack) {
return createWithCopy(fluidStack.getFluid(), null, fluidStack.tag);
}

public static FluidId createWithAmount(FluidStack fluidStack) {
return createWithCopy(fluidStack.getFluid(), (Integer) fluidStack.amount, fluidStack.tag);
}

public static FluidId create(Fluid fluid) {
return createNoCopy(fluid, null, null);
}

public static FluidId createWithCopy(Fluid fluid, Integer amount, @Nullable NBTTagCompound nbt) {
if (nbt != null) {
nbt = (NBTTagCompound) nbt.copy();
}
return new AutoValue_GTUtility_FluidId(fluid, nbt, amount);
}

/**
* This method does not copy the NBT tag.
*/
public static FluidId createNoCopy(Fluid fluid, Integer amount, @Nullable NBTTagCompound nbt) {
return new AutoValue_GTUtility_FluidId(fluid, nbt, amount);
}

protected abstract Fluid fluid();

@Nullable
protected abstract NBTTagCompound nbt();

@Nullable
protected abstract Integer amount();

@Nonnull
public FluidStack getFluidStack() {
NBTTagCompound nbt = nbt();
return new FluidStack(fluid(), 1, nbt != null ? (NBTTagCompound) nbt.copy() : null);
}

@Nonnull
public FluidStack getFluidStack(int amount) {
NBTTagCompound nbt = nbt();
return new FluidStack(fluid(), amount, nbt != null ? (NBTTagCompound) nbt.copy() : null);
}
}

public static int getPlasmaFuelValueInEUPerLiterFromMaterial(Materials material) {
Expand Down
Loading
Loading