-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into LCT_recipe_visualization
- Loading branch information
Showing
131 changed files
with
1,911 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
src/main/java/be/uantwerpen/minelabs/crafting/molecules/ValenceElectrons.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package be.uantwerpen.minelabs.crafting.molecules; | ||
|
||
import be.uantwerpen.minelabs.item.Items; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NbtCompound; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class ValenceElectrons { | ||
private final int totalElectronCount; | ||
|
||
private Map<String, Integer> directionalValence; | ||
|
||
/** | ||
* @param bondDirections : amount of bonds in which direction | ||
* @param valenceE : amount of electrons on the current atom | ||
* @param forced : True = use pairs, False = Use 1's | ||
*/ | ||
public ValenceElectrons(Map<String, Integer> bondDirections, int valenceE, boolean forced) { | ||
this.totalElectronCount = valenceE; | ||
directionalValence = new HashMap<>(Map.of( | ||
"n", 0, | ||
"e", 0, | ||
"s", 0, | ||
"w", 0 | ||
)); | ||
addElectrons(bondDirections, valenceE, forced); | ||
} | ||
|
||
/** | ||
* @param bondDirections : amount of bonds in which direction | ||
* @param count : amount of electrons to place around the atom | ||
* @param forced : True = use pairs, False = Use 1's | ||
*/ | ||
private void addElectrons(Map<String, Integer> bondDirections, int count, boolean forced) { | ||
//inverse bonddir & voorkeur N-E-S-W | ||
// int: in elke richting 0,1,2 | ||
while (count > 0) { | ||
for (String key : getBestList(bondDirections, forced)) { | ||
if (count == 0) { | ||
break; | ||
} | ||
if (bondDirections.get(key) == 0) { | ||
if (count >= 2 && directionalValence.get(key) == 0 && forced) { | ||
addEDir(key, 2); | ||
count -= 2; | ||
} else { | ||
addEDir(key, 1); | ||
count -= 1; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @param bondDirections : amount of bonds in which direction | ||
* @param forced : True = use pairs, False = Use 1's | ||
* @return A list contain a set order to iterate over | ||
*/ | ||
private List<String> getBestList(Map<String, Integer> bondDirections, boolean forced) { | ||
if (totalElectronCount > 3 || (totalElectronCount == 2 && !forced)) { | ||
if (bondDirections.get("n") != 0 || bondDirections.get("s") != 0) { | ||
return Arrays.asList("e", "w", "n", "s"); | ||
} else if (bondDirections.get("e") != 0 || bondDirections.get("w") != 0) { | ||
return Arrays.asList("n", "s", "e", "w"); | ||
} else { | ||
return Arrays.asList("n", "e", "s", "w"); | ||
} | ||
} else { | ||
if (bondDirections.get("n") != 0 || bondDirections.get("s") != 0) { | ||
return Arrays.asList("n", "s", "e", "w"); | ||
} else if (bondDirections.get("e") != 0 || bondDirections.get("w") != 0) { | ||
return Arrays.asList("e", "w", "n", "s"); | ||
} else { | ||
return Arrays.asList("n", "e", "s", "w"); | ||
} | ||
} | ||
} | ||
|
||
private void addEDir(String direction, int amount) { | ||
directionalValence.put(direction, directionalValence.get(direction) + amount); | ||
} | ||
|
||
@NotNull | ||
public ItemStack getStack(String direction) { | ||
ItemStack stack = new ItemStack(Items.VALENCEE); | ||
//TODO make item and overrides for model | ||
NbtCompound nbt = stack.getOrCreateNbt(); | ||
|
||
nbt.putInt(direction, directionalValence.get(direction)); | ||
|
||
return stack; | ||
} | ||
|
||
public Integer getDirectionalValence(String direction) { | ||
return directionalValence.get(direction); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package be.uantwerpen.minelabs.fluid; | ||
|
||
import be.uantwerpen.minelabs.block.Blocks; | ||
import be.uantwerpen.minelabs.item.Items; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.fluid.Fluid; | ||
import net.minecraft.fluid.FluidState; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.state.property.Properties; | ||
|
||
public abstract class CCl4Fluid extends AbstractFluid { | ||
@Override | ||
public Fluid getFlowing() { | ||
return Fluids.FLOWING_CCl4; | ||
} | ||
|
||
@Override | ||
public Fluid getStill() { | ||
return Fluids.STILL_CCl4; | ||
} | ||
|
||
public Item getBucketItem() { | ||
return Items.ERLENMEYER_CCL4; | ||
} | ||
|
||
@Override | ||
protected BlockState toBlockState(FluidState fluidState) { | ||
// getBlockStateLevel converts the LEVEL_1_8 of the fluid state to the LEVEL_15 the fluid block uses | ||
return Blocks.CCl4.getDefaultState().with(Properties.LEVEL_15, getBlockStateLevel(fluidState)); | ||
} | ||
|
||
public static class Flowing extends CCl4Fluid { | ||
@Override | ||
protected void appendProperties(net.minecraft.state.StateManager.Builder<Fluid, FluidState> builder) { | ||
super.appendProperties(builder); | ||
builder.add(LEVEL); | ||
} | ||
|
||
@Override | ||
public int getLevel(FluidState fluidState) { | ||
return fluidState.get(LEVEL); | ||
} | ||
|
||
@Override | ||
public boolean isStill(FluidState fluidState) { | ||
return false; | ||
} | ||
} | ||
|
||
public static class Still extends CCl4Fluid { | ||
@Override | ||
public int getLevel(FluidState fluidState) { | ||
return 2; | ||
} | ||
|
||
@Override | ||
public boolean isStill(FluidState fluidState) { | ||
return true; | ||
} | ||
} | ||
} |
Oops, something went wrong.