Skip to content

Commit

Permalink
Drop Part Offsets into their original form, Closes #1418
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Nov 19, 2024
1 parent 3bc03bb commit fee74c2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ public class GeneralConfig extends DummyConfig {
@ConfigurableProperty(category = "machine", comment = "The distance from which part offsets should be shown.", minimalValue = 1, configLocation = ModConfig.Type.SERVER)
public static int partOffsetRenderDistance = 16;

@ConfigurableProperty(category = "machine", comment = "The maximum values that Part Offset items will have when dropped from a broken part.", minimalValue = 1, configLocation = ModConfig.Type.SERVER)
public static int enchancementOffsetPartDropValue = 4;

public GeneralConfig() {
super(IntegratedDynamics._instance, "general");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,14 @@
import org.cyclops.cyclopscore.config.extendedconfig.BlockConfig;
import org.cyclops.cyclopscore.datastructure.DimPos;
import org.cyclops.cyclopscore.init.ModBase;
import org.cyclops.integrateddynamics.GeneralConfig;
import org.cyclops.integrateddynamics.IntegratedDynamics;
import org.cyclops.integrateddynamics.RegistryEntries;
import org.cyclops.integrateddynamics.api.network.INetwork;
import org.cyclops.integrateddynamics.api.network.INetworkElement;
import org.cyclops.integrateddynamics.api.network.IPartNetworkElement;
import org.cyclops.integrateddynamics.api.network.event.INetworkEvent;
import org.cyclops.integrateddynamics.api.part.IPartContainer;
import org.cyclops.integrateddynamics.api.part.IPartState;
import org.cyclops.integrateddynamics.api.part.IPartType;
import org.cyclops.integrateddynamics.api.part.PartPos;
import org.cyclops.integrateddynamics.api.part.PartRenderPosition;
import org.cyclops.integrateddynamics.api.part.PartTarget;
import org.cyclops.integrateddynamics.api.part.PartTypeAdapter;
import org.cyclops.integrateddynamics.api.part.*;
import org.cyclops.integrateddynamics.core.block.IgnoredBlock;
import org.cyclops.integrateddynamics.core.helper.L10NValues;
import org.cyclops.integrateddynamics.core.helper.PartHelpers;
Expand Down Expand Up @@ -173,9 +168,21 @@ public void addDrops(PartTarget target, S state, List<ItemStack> itemStacks, boo

// Save enhancements
if (!saveState && state.getMaxOffset() > 0) {
ItemStack itemStack = new ItemStack(RegistryEntries.ITEM_ENHANCEMENT_OFFSET);
RegistryEntries.ITEM_ENHANCEMENT_OFFSET.setEnhancementValue(itemStack, state.getMaxOffset());
itemStacks.add(itemStack);
// Drop Part Offset items each with as maximum the GeneralConfig.enchancementOffsetPartDropValue offset value.
int remainingOffset = state.getMaxOffset();
while (remainingOffset > 0) {
int offset;
if (remainingOffset < GeneralConfig.enchancementOffsetPartDropValue) {
offset = remainingOffset;
} else {
offset = GeneralConfig.enchancementOffsetPartDropValue;
}
remainingOffset -= offset;

ItemStack itemStack = new ItemStack(RegistryEntries.ITEM_ENHANCEMENT_OFFSET);
RegistryEntries.ITEM_ENHANCEMENT_OFFSET.setEnhancementValue(itemStack, offset);
itemStacks.add(itemStack);
}
}
}

Expand Down

0 comments on commit fee74c2

Please sign in to comment.