Skip to content

Commit

Permalink
0.5.1-beta update
Browse files Browse the repository at this point in the history
  • Loading branch information
GL33P-0R4NG3 committed Jul 29, 2021
1 parent 4982e94 commit 1573f23
Show file tree
Hide file tree
Showing 17 changed files with 168 additions and 79 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md → CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
Lead:
+ Bush Hammer - new way how to crack blocks (right clicking should do nothing for now)

Tags:
+ Added support for forge tags so now other mods that uses forge tags should be compatible with this mod

Other:
+ Packets but now does not work
- Now pressing Shift will show the tinted items durability in inventory
- Lead Ingot texture little bit fixed
- Fixed wrong xp drop calculation from Lead Ore
- Fixed bug when you get Dawn Shine effect when you had no silver tinted item
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '1.16.4-0.5.1-aplha-1'
version = '1.16.4-0.5.1-beta'
group = 'me.gleep.oreganized' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'oreganized'

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/me/gleep/oreganized/armors/STABase.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package me.gleep.oreganized.armors;

import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
Expand All @@ -18,14 +20,15 @@
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW;

import java.util.List;

public class STABase extends ArmorItem {
//Maximum durability of the tint
public static final int MAX_TINT_DURABILITY = 50;
private final boolean immuneToFire;
//Used for tinted durability
//Used for tinted durability bar
private boolean shouldDisplayTint;

public STABase(IArmorMaterial materialIn, EquipmentSlotType slot) {
Expand All @@ -43,12 +46,15 @@ public boolean makesPiglinsNeutral(ItemStack stack, LivingEntity wearer) {
return stack.getItemEnchantability() == ArmorMaterial.GOLD.getEnchantability();
}

/**
* Used to change durability bar when holding left shift or crouching.
*/
@Override
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
super.inventoryTick(stack, worldIn, entityIn, itemSlot, isSelected);
if (entityIn instanceof PlayerEntity) {
PlayerEntity pl = (PlayerEntity) entityIn;
this.shouldDisplayTint = pl.isCrouching();
this.shouldDisplayTint = pl.isCrouching() || InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

public class BlastedIronBlock extends Block {

//Magic properties
public static final BooleanProperty UP = BooleanProperty.create("up");
public static final BooleanProperty DOWN = BooleanProperty.create("down");
public static final BooleanProperty NORTH = BooleanProperty.create("north");
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/me/gleep/oreganized/blocks/MoltenLeadBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public MoltenLeadBlock() {
.noDrops());
}


/**
* Used to make entities "think" they can walk through it
* @return {@link PathNodeType#WALKABLE}
*/
@Nullable
@Override
public PathNodeType getAiPathNodeType(BlockState state, IBlockReader world, BlockPos pos, @Nullable MobEntity entity) {
Expand All @@ -36,6 +41,9 @@ public int getLightValue(BlockState state, IBlockReader world, BlockPos pos) {
return 8;
}

/**
* When player have iron boots it will return Cube collision shape otherwise empty
*/
@NotNull
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/me/gleep/oreganized/blocks/StoneSign.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package me.gleep.oreganized.blocks;

import me.gleep.oreganized.entities.tileentities.StoneSignTileEntity;
import me.gleep.oreganized.util.EditStoneSignScreen;
import me.gleep.oreganized.util.RegistryHandler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.state.IntegerProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

public class StoneSign extends Block {
Expand All @@ -22,6 +30,14 @@ protected void fillStateContainer(StateContainer.Builder<Block, BlockState> buil
builder.add(PROGRESS);
}

/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
Minecraft.getInstance().displayGuiScreen(new EditStoneSignScreen((StoneSignTileEntity) worldIn.getTileEntity(pos)));
}

/**
* Called throughout the code as a replacement for block instanceof BlockContainer
* Moving this to the Block base class allows for mods that wish to extend vanilla
Expand Down
30 changes: 29 additions & 1 deletion src/main/java/me/gleep/oreganized/events/ModEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.function.Consumer;

@Mod.EventBusSubscriber(modid = Oreganized.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public class ModEvents {
/**
* Event to handle Silver Tintend Swords break
*/
@SubscribeEvent
public static void onToolBreakEvent(final PlayerDestroyItemEvent event) {
ItemStack stack = event.getOriginal();
Expand All @@ -66,6 +71,9 @@ public static void onToolBreakEvent(final PlayerDestroyItemEvent event) {
pl.dropItem(item, true);
}

/**
* Event to handle Cauldron replacement
*/
@SubscribeEvent
public static void onPlayerRightClick(final PlayerInteractEvent.RightClickBlock event) {
ItemStack item = event.getItemStack();
Expand Down Expand Up @@ -119,6 +127,9 @@ public static void onLivingJump(final LivingEvent.LivingJumpEvent event) {
}
}*/

/**
* Event to handle entities in mod fluid
*/
@SubscribeEvent
public static void onEntityUpdate(final LivingEvent.LivingUpdateEvent event) {
if (event.getEntity() instanceof LivingEntity) {
Expand Down Expand Up @@ -160,6 +171,9 @@ public static void onEntityUpdate(final LivingEvent.LivingUpdateEvent event) {
}
}

/**
* Event to handle block cracking and damaging BushHammer item
*/
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void onBlockDestroyed(BlockEvent.BreakEvent event) {
Expand All @@ -170,22 +184,30 @@ public static void onBlockDestroyed(BlockEvent.BreakEvent event) {

if (currentitem.getItem().equals(RegistryHandler.BUSH_HAMMER.get())) {
for (Block b : BushHammer.EFFECTIVE_ON.keySet()) {
if (state.getBlock().equals(b)) {
if (state.getBlock().equals(b) && !event.getPlayer().isCreative()) {
world.setBlockState(pos, BushHammer.EFFECTIVE_ON.get(b).getDefaultState(), 2);
currentitem.damageItem(1, event.getPlayer(), (player) -> {
player.sendBreakAnimation(event.getPlayer().getActiveHand());
});
event.setCanceled(true);
}
}
}

}

/*
/**
* Event to emit particles when entity gets DawnShine effect
//
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void onDawnShineEffect(PotionEvent.PotionAddedEvent event) {
if (event.getPotionEffect().getPotion().equals(RegistryHandler.DAWN_SHINE.get())) {
Minecraft.getInstance().particles.addParticleEmitter(event.getEntityLiving(), RegistryHandler.DAWN_SHINE_PARTICLE.get());
}
}
*/

/*@SubscribeEvent
public static void onLeadNuggetImpact(ProjectileImpactEvent event) {
Expand All @@ -194,6 +216,9 @@ public static void onLeadNuggetImpact(ProjectileImpactEvent event) {
}
}*/

/**
* Event to change fluid fog density for rendering
*/
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void getFogDensity(EntityViewRenderEvent.FogDensity event) {
Expand All @@ -209,6 +234,9 @@ public static void getFogDensity(EntityViewRenderEvent.FogDensity event) {
}
}

/**
* Event to change the fluid fog color for rendering
*/
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void getFogColor(EntityViewRenderEvent.FogColors event) {
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/me/gleep/oreganized/fluids/LeadFluid.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ public LeadFluid() {

@Override
public Vector3d getFlow(IBlockReader blockReader, BlockPos pos, FluidState fluidState) {
double d0 = 0.0D;
double d1 = 0.0D;
BlockPos.Mutable blockpos$mutable = new BlockPos.Mutable();

Vector3d vector3d = new Vector3d(d0, 0.0D, d1);
Vector3d vector3d = new Vector3d(0.0D, 0.0D, 0.0D);

return vector3d.normalize();
}
Expand Down
51 changes: 32 additions & 19 deletions src/main/java/me/gleep/oreganized/items/BushHammer.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package me.gleep.oreganized.items;

import com.google.common.collect.*;
import jdk.nashorn.internal.codegen.MapCreator;
import me.gleep.oreganized.entities.tileentities.StoneSignTileEntity;
import me.gleep.oreganized.items.tiers.ModTier;
import me.gleep.oreganized.util.EditStoneSignScreen;
Expand All @@ -10,57 +9,56 @@
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.EditSignScreen;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.*;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.lang.management.PlatformLoggingMXBean;
import java.util.*;

import static me.gleep.oreganized.Oreganized.MOD_ID;
import java.util.function.Consumer;

public class BushHammer extends ToolItem {
/**
* Map where first element is the effective block and second element is the cracked version
*/
public static final Map<Block, Block> EFFECTIVE_ON = ImmutableMap.of(
Blocks.STONE, Blocks.COBBLESTONE,
Blocks.STONE_BRICKS, Blocks.CRACKED_STONE_BRICKS,
Blocks.POLISHED_BLACKSTONE_BRICKS, Blocks.CRACKED_POLISHED_BLACKSTONE_BRICKS,
Blocks.NETHER_BRICKS, Blocks.CRACKED_NETHER_BRICKS
);
public static final Map<Block, Block> SIGNS = new HashMap<>();

static {
SIGNS.put(Blocks.STONE, RegistryHandler.STONE.get());
SIGNS.put(Blocks.STONE_BRICKS, RegistryHandler.STONE_BRICKS.get());
}
/**
* Map containing vanilla and mod version of blocks
*/
public static final Map<Block, Block> SIGNS = ImmutableMap.of(
Blocks.STONE, RegistryHandler.STONE.get(),
Blocks.STONE_BRICKS, RegistryHandler.STONE_BRICKS.get()
);

public BushHammer() {
super(2.5F, -2.9F, ModTier.LEAD, EFFECTIVE_ON.keySet(),
super(2.5F, -3.1F, ModTier.LEAD, EFFECTIVE_ON.keySet(),
new Item.Properties().group(ItemGroup.TOOLS).maxStackSize(1)
);
}

/**
* Called when this item is used when targetting a Block
*
* Used for stone sign placement
*/
@NotNull
@Override
public ActionResultType onItemUse(ItemUseContext context) {
World world = context.getWorld();
BlockPos pos = context.getPos();
BlockState state = world.getBlockState(pos);
PlayerEntity player = context.getPlayer();

if (SIGNS.containsKey(state.getBlock())) {
if (SIGNS.containsKey(state.getBlock()) && !world.isRemote()) {
world.setBlockState(pos, SIGNS.get(state.getBlock()).getDefaultState(), 2);
Minecraft.getInstance().displayGuiScreen(new EditStoneSignScreen((StoneSignTileEntity) world.getTileEntity(pos)));
return ActionResultType.SUCCESS;
}
return super.onItemUse(context);
Expand All @@ -78,6 +76,21 @@ public void onUsingTick(ItemStack stack, LivingEntity player, int count) {

}

/**
* Reduce the durability of this item by the amount given.
* This can be used to e.g. consume power from NBT before durability.
*
* @param stack The itemstack to damage
* @param amount The amount to damage
* @param entity The entity damaging the item
* @param onBroken The on-broken callback from vanilla
* @return The amount of damage to pass to the vanilla logic
*/
@Override
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
return super.damageItem(stack, amount, entity, onBroken);
}

/**
* Called when the player stops using an Item (stops holding the right mouse button).
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/gleep/oreganized/items/tiers/ModTier.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum ModTier implements IItemTier {
private final int enchantability;
private final LazyValue<Ingredient> repairMaterial;

private ModTier(int harvestLevelIn, int maxUsesIn, float efficiencyIn, float attackDamageIn, int enchantabilityIn, Supplier<Ingredient> repairMaterialIn) {
ModTier(int harvestLevelIn, int maxUsesIn, float efficiencyIn, float attackDamageIn, int enchantabilityIn, Supplier<Ingredient> repairMaterialIn) {
this.harvestLevel = harvestLevelIn;
this.maxUses = maxUsesIn;
this.efficiency = efficiencyIn;
Expand Down
Loading

0 comments on commit 1573f23

Please sign in to comment.