diff --git a/README.md b/README.md index 4560e9b..f6600c0 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ ## Kore Sample -**LATEST OFFICIAL VERSION**: [Kore Sample 1.2.5 for MC 1.7.10][latest] ([changelog][changelog.md]) ([all releases][releases]) -[latest]: https://github.com/MinecraftModArchive/KoreSample/releases/latest +**LATEST OFFICIAL VERSION**: [Kore Sample 1.3.0 for MC 1.7.10][latest] ([changelog][changelog.md]) ([all +releases][releases]) + +[latest]: http://scottk.us/KoreSampleMod [releases]: https://github.com/MinecraftModArchive/KoreSample/releases [changelog.md]: https://github.com/MinecraftModArchive/KoreSample/blob/develop/src/main/resources/CHANGELOG.md -![KoreSample](https://raw.githubusercontent.com/MinecraftModArchive/KoreSample/develop/src/main/resources/assets/logo.png) +![Kore Sample](https://raw.githubusercontent.com/MinecraftModArchive/KoreSample/develop/art/logo/logo-128.png) Kore Sample provides a set of tools and base classes for other Minecraft mods that depend on it. @@ -47,6 +49,16 @@ purpose in mind. #### Licensing +##### Logo + +The logo is a colorized version of ['Half tornado icon'][logo-icon] by [Lorc][lorc-site] under [CC BY 3.0][ccby30]. + +[logo-icon]: http://game-icons.net/lorc/originals/half-tornado.html +[lorc-site]: http://lorcblog.blogspot.com/ +[ccby30]: http://creativecommons.org/licenses/by/3.0/ + +##### Software + This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or diff --git a/art/logo/logo-128.png b/art/logo/logo-128.png new file mode 100644 index 0000000..3d44f1e Binary files /dev/null and b/art/logo/logo-128.png differ diff --git a/art/logo/logo-400.png b/art/logo/logo-400.png new file mode 100644 index 0000000..62a9a70 Binary files /dev/null and b/art/logo/logo-400.png differ diff --git a/art/logo/logo-512.png b/art/logo/logo-512.png new file mode 100644 index 0000000..f45861d Binary files /dev/null and b/art/logo/logo-512.png differ diff --git a/src/main/java/com/scottkillen/mod/koresample/common/util/WeightedSet.java b/src/main/java/com/scottkillen/mod/koresample/common/util/WeightedSet.java new file mode 100644 index 0000000..29aa0fe --- /dev/null +++ b/src/main/java/com/scottkillen/mod/koresample/common/util/WeightedSet.java @@ -0,0 +1,106 @@ +package com.scottkillen.mod.koresample.common.util; + +import com.google.common.base.Objects; +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Multiset; +import java.util.Collection; +import java.util.Iterator; +import java.util.Random; + +import static com.google.common.base.Preconditions.checkNotNull; + +@SuppressWarnings({ "WeakerAccess", "StandardVariableNames" }) +public class WeightedSet implements Collection +{ + private final Random random; + private final Multiset elements = HashMultiset.create(); + + public static WeightedSet newWeightedSet() { return new WeightedSet(); } + + public static WeightedSet newWeightedSet(Random random) { return new WeightedSet(random); } + + public WeightedSet() + { + this(new Random()); + } + + public WeightedSet(Random random) + { + checkNotNull(random, "Random generator is required."); + + this.random = random; + } + + public T randomPick() + { + final int pick = random.nextInt(elements.size()); + int count = 0; + for (final T t : elements.elementSet()) + { + count += elements.count(t); + if (count >= pick) return t; + } + //noinspection ReturnOfNull + return null; + } + + public void setWeight(T t, int weight) { elements.setCount(t, weight); } + + @Override + public int size() { return elements.size(); } + + @Override + public boolean isEmpty() { return elements.isEmpty(); } + + @Override + public boolean contains(Object o) { return elements.contains(o); } + + @Override + public Iterator iterator() { return elements.iterator(); } + + @Override + public Object[] toArray() { return elements.toArray(); } + + @SuppressWarnings({ "SuspiciousToArrayCall", "TypeParameterHidesVisibleType" }) + @Override + public T[] toArray(T[] a) { return elements.toArray(a); } + + @Override + public boolean add(T t) { return elements.add(t); } + + @Override + public boolean remove(Object o) { return elements.remove(o); } + + @Override + public boolean containsAll(Collection c) { return elements.containsAll(c); } + + @Override + public boolean addAll(Collection c) { return elements.addAll(c); } + + @Override + public boolean removeAll(Collection c) { return elements.removeAll(c); } + + @Override + public boolean retainAll(Collection c) { return elements.retainAll(c); } + + @Override + public void clear() { elements.clear(); } + + @Override + public boolean equals(Object o) + { + if (!(o instanceof WeightedSet)) return false; + + final WeightedSet that = (WeightedSet) o; + return elements.equals(that.elements); + } + + @Override + public int hashCode() { return elements.hashCode(); } + + @Override + public String toString() + { + return Objects.toStringHelper(this).add("random", random).add("elements", elements).toString(); + } +} diff --git a/src/main/java/com/scottkillen/mod/koresample/common/util/multiblock/SubBlockManager.java b/src/main/java/com/scottkillen/mod/koresample/common/util/multiblock/SubBlockManager.java new file mode 100644 index 0000000..37d213c --- /dev/null +++ b/src/main/java/com/scottkillen/mod/koresample/common/util/multiblock/SubBlockManager.java @@ -0,0 +1,21 @@ +package com.scottkillen.mod.koresample.common.util.multiblock; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.util.IIcon; +import java.util.List; + +public interface SubBlockManager +{ + @SideOnly(Side.CLIENT) + IIcon getIcon(int side, int meta); + + @SideOnly(Side.CLIENT) + void registerIcons(IIconRegister register); + + @SideOnly(Side.CLIENT) + void getSubBlocks(Item item, CreativeTabs tabs, List list); +} diff --git a/src/main/java/com/scottkillen/mod/koresample/tree/block/WoodBlock.java b/src/main/java/com/scottkillen/mod/koresample/tree/block/WoodBlock.java index 09a5bab..d376405 100644 --- a/src/main/java/com/scottkillen/mod/koresample/tree/block/WoodBlock.java +++ b/src/main/java/com/scottkillen/mod/koresample/tree/block/WoodBlock.java @@ -19,75 +19,76 @@ public abstract class WoodBlock extends BlockWood { - public static final int CAPACITY = 16; - private final ImmutableList subBlocks; - private final List icons = Lists.newArrayList(); + public static final int CAPACITY = 16; + private final ImmutableList subBlocks; + private final List icons = Lists.newArrayList(); - protected WoodBlock(Collection subBlocks) - { - Preconditions.checkArgument(!subBlocks.isEmpty()); - Preconditions.checkArgument(subBlocks.size() <= CAPACITY); - this.subBlocks = ImmutableList.copyOf(subBlocks); - setBlockName("wood"); - } + protected WoodBlock(Collection subBlocks) + { + Preconditions.checkArgument(!subBlocks.isEmpty()); + Preconditions.checkArgument(subBlocks.size() <= CAPACITY); + this.subBlocks = ImmutableList.copyOf(subBlocks); + setBlockName("wood"); + } - @SuppressWarnings("WeakerAccess") - protected static String getUnwrappedUnlocalizedName(String unlocalizedName) - { - return unlocalizedName.substring(unlocalizedName.indexOf('.') + 1); - } + @SuppressWarnings("WeakerAccess") + protected static String getUnwrappedUnlocalizedName(String unlocalizedName) + { + return unlocalizedName.substring(unlocalizedName.indexOf('.') + 1); + } - protected final List subBlocks() { return Collections.unmodifiableList(subBlocks); } + protected final List subBlocks() { return Collections.unmodifiableList(subBlocks); } - public final ImmutableList getSubBlockNames() - { - final List names = Lists.newArrayList(); - for (final DefinesWood subBlock : subBlocks) - names.add(subBlock.speciesName()); - return ImmutableList.copyOf(names); - } + public final ImmutableList getSubBlockNames() + { + final List names = Lists.newArrayList(); + for (final DefinesWood subBlock : subBlocks) + names.add(subBlock.speciesName()); + return ImmutableList.copyOf(names); + } - @Override - public final String getUnlocalizedName() - { - return String.format("tile.%s%s", resourcePrefix(), getUnwrappedUnlocalizedName(super.getUnlocalizedName())); - } + @Override + public final String getUnlocalizedName() + { + return String.format("tile.%s%s", resourcePrefix(), getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + } - @SideOnly(Side.CLIENT) - @Override - public final IIcon getIcon(int unused, int meta) - { - final int meta1 = meta < 0 || meta >= icons.size() ? 0 : meta; - return icons.get(meta1); - } + @SideOnly(Side.CLIENT) + @Override + public final IIcon getIcon(int unused, int meta) + { + final int meta1 = meta < 0 || meta >= icons.size() ? 0 : meta; + return icons.get(meta1); + } - @SuppressWarnings("unchecked") - @SideOnly(Side.CLIENT) - @Override - public final void getSubBlocks(Item item, CreativeTabs unused, List subblocks) - { - for (int i = 0; i < subBlocks.size(); i++) - //noinspection ObjectAllocationInLoop - subblocks.add(new ItemStack(item, 1, i)); - } + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + @Override + public final void getSubBlocks(Item item, CreativeTabs unused, List subblocks) + { + for (int i = 0; i < subBlocks.size(); i++) + //noinspection ObjectAllocationInLoop + subblocks.add(new ItemStack(item, 1, i)); + } - @Override - public final void registerBlockIcons(IIconRegister iconRegister) - { - icons.clear(); + @SideOnly(Side.CLIENT) + @Override + public final void registerBlockIcons(IIconRegister iconRegister) + { + icons.clear(); - for (int i = 0; i < subBlocks.size(); i++) - { - final String iconName = String.format("%splanks_%s", resourcePrefix(), subBlocks.get(i).speciesName()); - icons.add(i, iconRegister.registerIcon(iconName)); - } - } + for (int i = 0; i < subBlocks.size(); i++) + { + final String iconName = String.format("%splanks_%s", resourcePrefix(), subBlocks.get(i).speciesName()); + icons.add(i, iconRegister.registerIcon(iconName)); + } + } - protected abstract String resourcePrefix(); + protected abstract String resourcePrefix(); - @Override - public String toString() - { - return Objects.toStringHelper(this).add("subBlocks", subBlocks).add("icons", icons).toString(); - } + @Override + public String toString() + { + return Objects.toStringHelper(this).add("subBlocks", subBlocks).add("icons", icons).toString(); + } } diff --git a/src/main/resources/CHANGELOG.md b/src/main/resources/CHANGELOG.md index d7ad2d8..07940b5 100644 --- a/src/main/resources/CHANGELOG.md +++ b/src/main/resources/CHANGELOG.md @@ -1,3 +1,9 @@ +# Kore Sample Changelog + +## 1.3.0 +- Changed logo. +- Added WeightedSet utility. + ## 1.2.5 - Fixed lighting bug for slabs and stairs. - Fixed slabs showing wrong textures. diff --git a/src/main/resources/assets/logo.png b/src/main/resources/assets/logo.png index e90b1cf..cbd9d6f 100644 Binary files a/src/main/resources/assets/logo.png and b/src/main/resources/assets/logo.png differ diff --git a/version/gradle.properties b/version/gradle.properties index b8fce11..1d48d52 100644 --- a/version/gradle.properties +++ b/version/gradle.properties @@ -1,6 +1,6 @@ -#Mon, 16 Feb 2015 00:21:40 -0500 +#Sun, 31 May 2015 21:41:35 -0400 mcversion=1.7.10 forgeversion=10.13.2.1291 version_major=1 -version_series=2 -version_revision=5 +version_series=3 +version_revision=0