Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottKillen committed Jun 1, 2015
2 parents d444810 + 2dfdc77 commit efeaeda
Show file tree
Hide file tree
Showing 10 changed files with 212 additions and 66 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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
Expand Down
Binary file added art/logo/logo-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/logo/logo-400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/logo/logo-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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<T> implements Collection<T>
{
private final Random random;
private final Multiset<T> elements = HashMultiset.create();

public static <T> WeightedSet<T> newWeightedSet() { return new WeightedSet<T>(); }

public static <T> WeightedSet<T> newWeightedSet(Random random) { return new WeightedSet<T>(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<T> iterator() { return elements.iterator(); }

@Override
public Object[] toArray() { return elements.toArray(); }

@SuppressWarnings({ "SuspiciousToArrayCall", "TypeParameterHidesVisibleType" })
@Override
public <T> 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<? extends T> 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();
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
121 changes: 61 additions & 60 deletions src/main/java/com/scottkillen/mod/koresample/tree/block/WoodBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,75 +19,76 @@

public abstract class WoodBlock extends BlockWood
{
public static final int CAPACITY = 16;
private final ImmutableList<DefinesWood> subBlocks;
private final List<IIcon> icons = Lists.newArrayList();
public static final int CAPACITY = 16;
private final ImmutableList<DefinesWood> subBlocks;
private final List<IIcon> icons = Lists.newArrayList();

protected WoodBlock(Collection<? extends DefinesWood> subBlocks)
{
Preconditions.checkArgument(!subBlocks.isEmpty());
Preconditions.checkArgument(subBlocks.size() <= CAPACITY);
this.subBlocks = ImmutableList.copyOf(subBlocks);
setBlockName("wood");
}
protected WoodBlock(Collection<? extends DefinesWood> 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<DefinesWood> subBlocks() { return Collections.unmodifiableList(subBlocks); }
protected final List<DefinesWood> subBlocks() { return Collections.unmodifiableList(subBlocks); }

public final ImmutableList<String> getSubBlockNames()
{
final List<String> names = Lists.newArrayList();
for (final DefinesWood subBlock : subBlocks)
names.add(subBlock.speciesName());
return ImmutableList.copyOf(names);
}
public final ImmutableList<String> getSubBlockNames()
{
final List<String> 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();
}
}
6 changes: 6 additions & 0 deletions src/main/resources/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Binary file modified src/main/resources/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions version/gradle.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit efeaeda

Please sign in to comment.