Fixed satellite loot being overridden by lunar mining ship

This commit is contained in:
Toshayo 2023-07-05 21:20:46 +02:00
parent ea9dc777fb
commit c5d1960842
No known key found for this signature in database
GPG Key ID: 7DC46644B561B1B4
2 changed files with 39 additions and 33 deletions

View File

@ -7,7 +7,7 @@ import net.minecraft.item.ItemStack;
public class SatelliteLunarMiner extends SatelliteMiner { public class SatelliteLunarMiner extends SatelliteMiner {
static { static {
registerCargo(new WeightedRandomObject[] { registerCargo(SatelliteLunarMiner.class, new WeightedRandomObject[] {
new WeightedRandomObject(new ItemStack(ModBlocks.moon_turf, 48), 5), new WeightedRandomObject(new ItemStack(ModBlocks.moon_turf, 48), 5),
new WeightedRandomObject(new ItemStack(ModBlocks.moon_turf, 32), 7), new WeightedRandomObject(new ItemStack(ModBlocks.moon_turf, 32), 7),
new WeightedRandomObject(new ItemStack(ModBlocks.moon_turf, 16), 5), new WeightedRandomObject(new ItemStack(ModBlocks.moon_turf, 16), 5),

View File

@ -7,11 +7,46 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import java.util.HashMap;
public class SatelliteMiner extends Satellite { public class SatelliteMiner extends Satellite {
/** /**
* {@link WeightedRandomObject} array with loot the satellite will deliver. * {@link WeightedRandomObject} array with loot the satellite will deliver.
*/ */
private static WeightedRandomObject[] CARGO = new WeightedRandomObject[] { private static final HashMap<Class<? extends SatelliteMiner>, WeightedRandomObject[]> CARGO = new HashMap<>();
public long lastOp;
public SatelliteMiner() {
this.satIface = Interfaces.NONE;
}
public void writeToNBT(NBTTagCompound nbt) {
nbt.setLong("lastOp", lastOp);
}
public void readFromNBT(NBTTagCompound nbt) {
lastOp = nbt.getLong("lastOp");
}
/**
* Replaces cargo of the satellite.
* @param cargo - Array of {@link WeightedRandomObject} representing the loot that will be delivered.
*/
public static void registerCargo(Class<? extends SatelliteMiner> minerSatelliteClass, WeightedRandomObject[] cargo) {
CARGO.put(minerSatelliteClass, cargo);
}
/**
* Gets items the satellite can deliver.
* @return - Array of {@link WeightedRandomObject} of satellite loot.
*/
public WeightedRandomObject[] getCargo() {
return CARGO.get(getClass());
}
static {
registerCargo(SatelliteMiner.class, new WeightedRandomObject[] {
new WeightedRandomObject(new ItemStack(ModItems.powder_aluminium, 3), 10), new WeightedRandomObject(new ItemStack(ModItems.powder_aluminium, 3), 10),
new WeightedRandomObject(new ItemStack(ModItems.powder_iron, 3), 10), new WeightedRandomObject(new ItemStack(ModItems.powder_iron, 3), 10),
new WeightedRandomObject(new ItemStack(ModItems.powder_titanium, 2), 8), new WeightedRandomObject(new ItemStack(ModItems.powder_titanium, 2), 8),
@ -39,35 +74,6 @@ public class SatelliteMiner extends Satellite {
new WeightedRandomObject(new ItemStack(ModItems.crystal_trixite, 1), 1), new WeightedRandomObject(new ItemStack(ModItems.crystal_trixite, 1), 1),
new WeightedRandomObject(new ItemStack(ModItems.crystal_starmetal, 1), 1), new WeightedRandomObject(new ItemStack(ModItems.crystal_starmetal, 1), 1),
new WeightedRandomObject(new ItemStack(ModItems.crystal_lithium, 2), 4) new WeightedRandomObject(new ItemStack(ModItems.crystal_lithium, 2), 4)
}; });
public long lastOp;
public SatelliteMiner() {
this.satIface = Interfaces.NONE;
}
public void writeToNBT(NBTTagCompound nbt) {
nbt.setLong("lastOp", lastOp);
}
public void readFromNBT(NBTTagCompound nbt) {
lastOp = nbt.getLong("lastOp");
}
/**
* Replaces cargo of the satellite.
* @param cargo - Array of {@link WeightedRandomObject} representing the loot that will be delivered.
*/
public static void registerCargo(WeightedRandomObject[] cargo) {
CARGO = cargo;
}
/**
* Gets items the satellite can deliver.
* @return - Array of {@link WeightedRandomObject} of satellite loot.
*/
public WeightedRandomObject[] getCargo() {
return CARGO;
} }
} }