Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #48 from bartimaeusnek/SelfSortingListTest
Browse files Browse the repository at this point in the history
Fixes:
  • Loading branch information
bartimaeusnek authored Jan 7, 2020
2 parents 11bd816 + 4da6497 commit a2b09bd
Show file tree
Hide file tree
Showing 8 changed files with 306 additions and 251 deletions.
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
mc_version=1.7.10
majorUpdate=0
minorUpdate=5
buildNumber=5
buildNumber=6
APIVersion=8
ic2.version=2.2.828-experimental
gregtech.version=5.09.32.36
Expand Down
144 changes: 72 additions & 72 deletions src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld
}
BW_MetaGenerated_Block_TE tTileEntity = (BW_MetaGenerated_Block_TE) aWorld.getTileEntity(aX, aY, aZ);
tTileEntity.mMetaData = tDamage;
} else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3)) {
} else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3))
return false;
}
if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) {
this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack);
this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, tDamage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ public BW_MetaGenerated_Blocks(Material p_i45386_1_, Class<? extends TileEntity>
this.setResistance(5.0F);
this.setBlockTextureName("stone");
this.setCreativeTab(metaTab);
for (Werkstoff w : Werkstoff.werkstoffHashSet)
doRegistrationStuff(w);
Werkstoff.werkstoffHashSet.forEach(this::doRegistrationStuff);
}

@SideOnly(Side.CLIENT)
public final BW_MetaGenerated_Block_TE getProperTileEntityForRendering(){
public final BW_MetaGenerated_Block_TE getProperTileEntityForRendering() {
return (BW_MetaGenerated_Block_TE) createNewTileEntity(null,0);
}

Expand All @@ -69,9 +68,8 @@ protected boolean canSilkHarvest() {
}

public int getRenderType() {
if (BW_Renderer_Block_Ores.INSTANCE == null) {
if (BW_Renderer_Block_Ores.INSTANCE == null)
return super.getRenderType();
}
return BW_Renderer_Block_Ores.INSTANCE.mRenderID;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ public BW_MetaGenerated_Ores(Material p_i45386_1_, Class<? extends TileEntity> t
super(p_i45386_1_, tileEntity, blockName);
}

protected void doRegistrationStuff(Werkstoff w){
protected void doRegistrationStuff(Werkstoff w) {
if (w != null) {
if ((w.getGenerationFeatures().toGenerate & 0b1000) == 0 || ((w.getGenerationFeatures().blacklist & 0b1000) != 0))
return;
GT_ModHandler.addValuableOre(this, w.getmID(), 1);
GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + w.getmID() + ".name", w.getDefaultName() + OrePrefixes.ore.mLocalizedMaterialPost);

}
}

Expand Down Expand Up @@ -113,7 +114,7 @@ public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) {
}

@SuppressWarnings("unused")
private boolean checkForAir(IBlockAccess aWorld, int aX, int aY, int aZ){
private boolean checkForAir(IBlockAccess aWorld, int aX, int aY, int aZ) {
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
for (int z = -1; z <= 1; z++) {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ public static ItemStack getCorrespondingItemStack(OrePrefixes orePrefixes, Werks
return WerkstoffLoader.getCorrespondingItemStack(orePrefixes, werkstoff, 1);
}

public static ItemStack getCorrespondingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) {
private static ItemStack getCorrespondingItemStackUnsafe(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount){
if (!werkstoff.getGenerationFeatures().enforceUnification) {
ItemStack ret = OreDictHandler.getItemStack(werkstoff.getVarName(), orePrefixes, amount);
if (ret != null)
Expand All @@ -1369,6 +1369,15 @@ else if (orePrefixes == oreSmall)
else if (orePrefixes == block)
return new ItemStack(WerkstoffLoader.BWBlocks,amount,werkstoff.getmID());
else if (WerkstoffLoader.items.get(orePrefixes) == null)
return null;
return new ItemStack(WerkstoffLoader.items.get(orePrefixes), amount, werkstoff.getmID()).copy();
}

public static ItemStack getCorrespondingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) {
ItemStack stack = getCorrespondingItemStackUnsafe(orePrefixes, werkstoff, amount);
if (stack != null)
return stack;
else
MainMod.LOGGER.catching(Level.ERROR,new Exception("NO SUCH ITEM! "+orePrefixes+werkstoff.getVarName() +" If you encounter this as a user, make sure to contact the authors of the pack/the mods you're playing! " +
"If you are a Developer, you forgot to enable "+orePrefixes+" OrePrefix for Werkstoff "+werkstoff.getDefaultName()));
return new ItemStack(WerkstoffLoader.items.get(orePrefixes), amount, werkstoff.getmID()).copy();
Expand Down Expand Up @@ -1640,11 +1649,10 @@ void gameRegistryHandler(){
}

private static void runGTItemDataRegistrator() {
// HashSet<Materials> toRem = new HashSet<>();
for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) {
//int aMetaItemSubID, TextureSet aIconSet, float aToolSpeed, int aDurability, int aToolQuality, int aTypes, int aR, int aG, int aB, int aA, String aName, String aDefaultLocalName, int aFuelType, int aFuelPower, int aMeltingPoint, int aBlastFurnaceTemp, boolean aBlastFurnaceRequired, boolean aTransparent, int aOreValue, int aDensityMultiplier, int aDensityDivider, Dyes aColor, String aConfigSection, boolean aCustomOre, String aCustomID
Materials werkstoffBridgeMaterial = werkstoff.getBridgeMaterial() != null ? werkstoff.getBridgeMaterial() : Materials.get(werkstoff.getVarName()) != Materials._NULL ? Materials.get(werkstoff.getVarName()) :
new Materials(-1, werkstoff.getTexSet(), werkstoff.getToolSpeed(), werkstoff.getDurability(), werkstoff.getToolQuality(),0, werkstoff.getRGBA()[0],werkstoff.getRGBA()[1], werkstoff.getRGBA()[2], werkstoff.getRGBA()[3], werkstoff.getVarName(), werkstoff.getDefaultName(),0,0,werkstoff.getStats().meltingPoint,werkstoff.getStats().meltingPoint,werkstoff.getStats().isBlastFurnace(),false,0,1,1,null);
new Materials(-1, werkstoff.getTexSet(), werkstoff.getToolSpeed(), werkstoff.getDurability(), werkstoff.getToolQuality(), 0, werkstoff.getRGBA()[0], werkstoff.getRGBA()[1], werkstoff.getRGBA()[2], werkstoff.getRGBA()[3], werkstoff.getVarName(), werkstoff.getDefaultName(), 0, 0, werkstoff.getStats().meltingPoint, werkstoff.getStats().meltingPoint, werkstoff.getStats().isBlastFurnace(), false, 0, 1, 1, null);
for (OrePrefixes prefixes : values()) {
if (!(prefixes == cell && werkstoff.getType().equals(Werkstoff.Types.ELEMENT))) {
if (prefixes == dust && werkstoff.getType().equals(Werkstoff.Types.ELEMENT)) {
Expand All @@ -1655,7 +1663,7 @@ private static void runGTItemDataRegistrator() {
if (e.mLinkedMaterials.size() > 0)
break;
werkstoffBridgeMaterial = werkstoff.getBridgeMaterial() != null ? werkstoff.getBridgeMaterial() : Materials.get(werkstoff.getVarName()) != Materials._NULL ? Materials.get(werkstoff.getVarName()) :
new Materials(-1, werkstoff.getTexSet(), werkstoff.getToolSpeed(), werkstoff.getDurability(), werkstoff.getToolQuality(),0, werkstoff.getRGBA()[0],werkstoff.getRGBA()[1], werkstoff.getRGBA()[2], werkstoff.getRGBA()[3], werkstoff.getVarName(), werkstoff.getDefaultName(),0,0,werkstoff.getStats().meltingPoint,werkstoff.getStats().meltingPoint,werkstoff.getStats().isBlastFurnace(),false,0,1,1,null);
new Materials(-1, werkstoff.getTexSet(), werkstoff.getToolSpeed(), werkstoff.getDurability(), werkstoff.getToolQuality(), 0, werkstoff.getRGBA()[0], werkstoff.getRGBA()[1], werkstoff.getRGBA()[2], werkstoff.getRGBA()[3], werkstoff.getVarName(), werkstoff.getDefaultName(), 0, 0, werkstoff.getStats().meltingPoint, werkstoff.getStats().meltingPoint, werkstoff.getStats().isBlastFurnace(), false, 0, 1, 1, null);
werkstoffBridgeMaterial.mElement = e;
e.mLinkedMaterials = new ArrayList<>();
e.mLinkedMaterials.add(werkstoffBridgeMaterial);
Expand Down Expand Up @@ -1693,6 +1701,7 @@ private static void runGTItemDataRegistrator() {
werkstoffBridgeMaterial.mFluid = werkstoff.getFluidOrGas(1).getFluid();
werkstoffBridgeMaterial.mGas = werkstoff.getFluidOrGas(1).getFluid();
}

if (werkstoff.getGenerationFeatures().hasMolten()) {
werkstoffBridgeMaterial.mStandardMoltenFluid = werkstoff.getMolten(1).getFluid();
}
Expand All @@ -1701,33 +1710,74 @@ private static void runGTItemDataRegistrator() {
try {
Field f = Materials.class.getField("mLocalizedName");
f.set(werkstoffBridgeMaterial, werkstoff.getDefaultName());
} catch (NoSuchFieldException | IllegalAccessException ignored){}
} catch (NoSuchFieldException | IllegalAccessException ignored) {
}
werkstoffBridgeMaterial.mChemicalFormula = werkstoff.getToolTip();
if (Loader.isModLoaded("Thaumcraft"))
werkstoffBridgeMaterial.mAspects = werkstoff.getGTWrappedTCAspects();
werkstoffBridgeMaterial.mMaterialInto = werkstoffBridgeMaterial;
werkstoffBridgeMaterial.mHandleMaterial = werkstoff.contains(SubTag.BURNING) ? Materials.Blaze : werkstoff.contains(SubTag.MAGICAL) ? Materials.Thaumium : werkstoffBridgeMaterial.mDurability > 5120 ? Materials.TungstenSteel : werkstoffBridgeMaterial.mDurability > 1280 ? Materials.Steel : Materials.Wood;
//toRem.add(werkstoffBridgeMaterial);
if (werkstoff.getStats().isRadioactive()){
werkstoffBridgeMaterial.setEnchantmentForArmors(Enchantment_Radioactivity.INSTANCE,werkstoff.getStats().getEnchantmentlvl());
werkstoffBridgeMaterial.setEnchantmentForTools(Enchantment_Radioactivity.INSTANCE,werkstoff.getStats().getEnchantmentlvl());
if (werkstoff.getStats().isRadioactive()) {
werkstoffBridgeMaterial.setEnchantmentForArmors(Enchantment_Radioactivity.INSTANCE, werkstoff.getStats().getEnchantmentlvl());
werkstoffBridgeMaterial.setEnchantmentForTools(Enchantment_Radioactivity.INSTANCE, werkstoff.getStats().getEnchantmentlvl());
}
werkstoff.setBridgeMaterial(werkstoffBridgeMaterial);
if (WerkstoffLoader.items.get(prefixes) != null)
if ((werkstoff.getGenerationFeatures().toGenerate & Werkstoff.GenerationFeatures.prefixLogic.get(prefixes)) != 0 && (werkstoff.getGenerationFeatures().blacklist & Werkstoff.GenerationFeatures.prefixLogic.get(prefixes)) == 0 && werkstoff.get(prefixes) != null && werkstoff.get(prefixes).getItem() != null)
GT_OreDictUnificator.addAssociation(prefixes, werkstoffBridgeMaterial, werkstoff.get(prefixes), false);
//if (WerkstoffLoader.items.get(prefixes) != null)
}
}
}
// try {
// Field f = Materials.class.getDeclaredField("MATERIALS_MAP");
// f.setAccessible(true);
// Map<String, Materials> MATERIALS_MAP = (Map<String, Materials>) f.get(null);
// for (Materials o : toRem)
// MATERIALS_MAP.remove(o.mName);
// } catch (NoSuchFieldException | IllegalAccessException | ClassCastException e) {
// e.printStackTrace();
// }
addAssociationToItems();
addFakeItemDataToInWorldBlocksAndCleanUpFakeData();
}

public static void addAssociationToItems() {
Arrays.stream(values()).forEach( prefixes -> {
Werkstoff.werkstoffHashSet.stream()
.filter(werkstoff -> werkstoff.hasItemType(prefixes) && (werkstoff.getGenerationFeatures().blacklist & Werkstoff.GenerationFeatures.prefixLogic.get(prefixes)) == 0)
.forEach(werkstoff -> {
Materials werkstoffBridgeMaterial = werkstoff.getBridgeMaterial();
ItemStack stack = WerkstoffLoader.getCorrespondingItemStackUnsafe(prefixes, werkstoff, 1);
if (stack != null && stack.getItem() != null) {
GT_OreDictUnificator.addAssociation(prefixes, werkstoffBridgeMaterial, stack, false);
GT_OreDictUnificator.set(prefixes, werkstoffBridgeMaterial, stack, true, true);
}
});
});
}

/**
* very hacky way to make my ores/blocks/smallores detectable by gt assosication in world, well at least the prefix.
* used for the miners mostly
* removing this hacky material from the materials map instantly. we only need the item data.
*/
private static void addFakeItemDataToInWorldBlocksAndCleanUpFakeData() {

Map<String, Materials> MATERIALS_MAP = null;

try {
Field f = Materials.class.getDeclaredField("MATERIALS_MAP");
f.setAccessible(true);
MATERIALS_MAP = (Map<String, Materials>) f.get(null);
} catch (NoSuchFieldException | IllegalAccessException | ClassCastException e) {
e.printStackTrace();
}

if (MATERIALS_MAP == null)
throw new NullPointerException("MATERIALS_MAP null!");

Materials oreMat = new Materials(-1,null,0,0,0,false,"bwores","bwores",null,true,null);
Materials smallOreMat = new Materials(-1,null,0,0,0,false,"bwsmallores","bwsmallores",null,true,null);
Materials blockMat = new Materials(-1,null,0,0,0,false,"bwblocks","bwblocks",null,true,null);

for (int i = 0; i < 16; i++) {
GT_OreDictUnificator.addAssociation(ore, oreMat, new ItemStack(BWOres,1,i), true);
GT_OreDictUnificator.addAssociation(oreSmall, smallOreMat, new ItemStack(BWSmallOres,1,i), true);
GT_OreDictUnificator.addAssociation(block, blockMat, new ItemStack(BWBlocks,1,i), true);
}

MATERIALS_MAP.remove("bwores");
MATERIALS_MAP.remove("bwsmallores");
MATERIALS_MAP.remove("bwblocks");
}

private void addTools(Werkstoff werkstoff){
Expand Down Expand Up @@ -1834,8 +1884,8 @@ private void runAdditionalOreDict(){
if (werkstoff.getGenerationFeatures().hasOres()) {
GT_OreDictUnificator.registerOre(ore + werkstoff.getVarName(), werkstoff.get(ore));
GT_OreDictUnificator.registerOre(oreSmall + werkstoff.getVarName(), werkstoff.get(oreSmall));
werkstoff.getADDITIONAL_OREDICT().forEach( e -> OreDictionary.registerOre(ore+e, werkstoff.get(ore)));
werkstoff.getADDITIONAL_OREDICT().forEach( e -> OreDictionary.registerOre(oreSmall+e, werkstoff.get(oreSmall)));
werkstoff.getADDITIONAL_OREDICT().forEach( e -> OreDictionary.registerOre(ore+e, werkstoff.get(ore)));
werkstoff.getADDITIONAL_OREDICT().forEach( e -> OreDictionary.registerOre(oreSmall+e, werkstoff.get(oreSmall)));
}

if (werkstoff.getGenerationFeatures().hasGems())
Expand All @@ -1850,7 +1900,7 @@ private void runAdditionalOreDict(){
.forEach(s -> ENABLED_ORE_PREFIXES
.stream()
.filter(o -> Objects.nonNull(werkstoff.get(o)))
.forEach( od -> OreDictionary.registerOre(od+s, werkstoff.get(od))));
.forEach(od -> OreDictionary.registerOre(od+s, werkstoff.get(od))));
}

GT_OreDictUnificator.registerOre("craftingIndustrialDiamond", WerkstoffLoader.CubicZirconia.get(gemExquisite));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,8 @@ public void loadConfig() {
stack.setItemDamage(Short.MAX_VALUE);
API.hideItem(stack);
}
// for (int i = 0; i < Short.MAX_VALUE; i++) {
// API.addItemListEntry(new ItemStack(WerkstoffLoader.BWOres,1,i));
// }
}
}

0 comments on commit a2b09bd

Please sign in to comment.