Skip to content

Commit

Permalink
Fixed #113, hoe sounds only playing on server. Fixed #104, loose rock…
Browse files Browse the repository at this point in the history
…s generating at normal grade instead of small.
  • Loading branch information
alcatrazEscapee committed Jun 29, 2019
1 parent 06e826b commit bc008fe
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/dries007/tfc/CommonEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public static void onUseHoe(UseHoeEvent event)
{
if (!world.isRemote)
{
world.playSound(event.getEntityPlayer(), pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.playSound(null, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.setBlockState(pos, BlockRockVariant.get(blockRock.getRock(), Rock.Type.FARMLAND).getDefaultState());
}
event.setResult(Event.Result.ALLOW);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ public static ItemStack get(Ore ore, int amount)
return new ItemStack(MAP.get(ore), amount);
}

public final Ore ore;
private final Ore ore;

public ItemSmallOre(Ore ore)
{
this.ore = ore;
if (MAP.put(ore, this) != null) throw new IllegalStateException("There can only be one.");
if (MAP.put(ore, this) != null)
{
throw new IllegalStateException("There can only be one.");
}
setMaxDamage(0);
OreDictionaryHelper.register(this, "ore");
OreDictionaryHelper.register(this, "ore", ore.getRegistryName().getPath());
Expand Down Expand Up @@ -70,4 +73,10 @@ public Weight getWeight(@Nonnull ItemStack stack)
{
return Weight.HEAVY;
}

@Nonnull
public Ore getOre()
{
return ore;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Random;
import javax.annotation.Nullable;

import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand Down Expand Up @@ -79,7 +80,16 @@ private void generateRock(World world, BlockPos pos, @Nullable Vein vein, Rock r
TEPlacedItemFlat tile = Helpers.getTE(world, pos, TEPlacedItemFlat.class);
if (tile != null)
{
tile.setStack(vein == null ? ItemRock.get(rock, 1) : vein.type.getLooseRockItem());
ItemStack stack = ItemStack.EMPTY;
if (vein != null)
{
stack = vein.type.getLooseRockItem();
}
if (stack.isEmpty())
{
stack = ItemRock.get(rock, 1);
}
tile.setStack(stack);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@

import java.util.Collection;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;

import com.google.common.collect.ImmutableSet;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import net.dries007.tfc.api.types.Ore;
import net.dries007.tfc.api.types.Rock;
import net.dries007.tfc.objects.blocks.stone.BlockOreTFC;
import net.dries007.tfc.objects.items.metal.ItemOreTFC;
import net.dries007.tfc.objects.items.metal.ItemSmallOre;

@ParametersAreNonnullByDefault
public class VeinType
Expand Down Expand Up @@ -68,9 +70,19 @@ public boolean hasLooseRocks()
return ore != null && ore.isGraded();
}

@Nonnull
public ItemStack getLooseRockItem()
{
return ore != null ? ItemOreTFC.get(ore, 1) : ItemStack.EMPTY;
if (ore != null)
{
// This is done intentionally, as some ores may not have a small ore item
Item itemOre = ItemSmallOre.get(ore);
if (itemOre != null)
{
return new ItemStack(itemOre, 1);
}
}
return ItemStack.EMPTY;
}

public void setRegistryName(String name)
Expand Down

0 comments on commit bc008fe

Please sign in to comment.