Skip to content

Commit

Permalink
Updated blocks with itemblock creation + some updates in discord rich…
Browse files Browse the repository at this point in the history
… presence
  • Loading branch information
HyCraftHD committed Mar 2, 2019
1 parent 125fbcb commit 751a991
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 41 deletions.
22 changes: 10 additions & 12 deletions src/main/java/info/u_team/u_team_core/block/UBlock.java
Expand Up @@ -8,30 +8,28 @@ public class UBlock extends Block implements IUBlock {

protected final String name;

protected ItemBlock itemblock;
protected final ItemBlock itemblock;

public UBlock(String name, Properties properties) {
this(name, properties, true);
this(name, null, properties);
}

public UBlock(String name, Properties properties, boolean shouldCreateItemBlock) {
this(name, null, properties, shouldCreateItemBlock);
public UBlock(String name, ItemGroup group, Properties properties) {
this(name, group, properties, null);
}

public UBlock(String name, ItemGroup group, Properties properties) {
this(name, group, properties, true);
public UBlock(String name, Properties properties, Item.Properties itemblockproperties) {
this(name, null, properties, itemblockproperties);
}

public UBlock(String name, ItemGroup group, Properties properties, boolean shouldCreateItemBlock) {
public UBlock(String name, ItemGroup group, Properties properties, Item.Properties itemblockproperties) {
super(properties);
this.name = name;
if (shouldCreateItemBlock) {
itemblock = createItemBlock(group);
}
itemblock = createItemBlock(itemblockproperties == null ? new Item.Properties().group(group) : group == null ? itemblockproperties : itemblockproperties.group(group));
}

protected ItemBlock createItemBlock(ItemGroup group) {
return new ItemBlock(this, group == null ? new Item.Properties() : new Item.Properties().group(group));
protected ItemBlock createItemBlock(Item.Properties itemblockproperties) {
return new ItemBlock(this, itemblockproperties);
}

@Override
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/info/u_team/u_team_core/block/UBlockTileEntity.java
Expand Up @@ -5,7 +5,7 @@
import info.u_team.u_team_core.api.ISyncedContainerTileEntity;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.*;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.*;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.*;
import net.minecraft.util.math.BlockPos;
Expand All @@ -21,7 +21,15 @@ public UBlockTileEntity(String name, Properties properties, TileEntityType<?> ti
}

public UBlockTileEntity(String name, ItemGroup group, Properties properties, TileEntityType<?> tileentitytype) {
super(name, group, properties);
this(name, group, properties, null, tileentitytype);
}

public UBlockTileEntity(String name, Properties properties, Item.Properties itemblockproperties, TileEntityType<?> tileentitytype) {
this(name, null, properties, itemblockproperties, tileentitytype);
}

public UBlockTileEntity(String name, ItemGroup group, Properties properties, Item.Properties itemblockproperties, TileEntityType<?> tileentitytype) {
super(name, group, properties, itemblockproperties);
this.tileentitytype = tileentitytype;
}

Expand Down
Expand Up @@ -123,6 +123,10 @@ public static boolean isEnabled() {
return isEnabled;
}

public static State getCurrent() {
return current;
}

public static class State {

private EnumState state;
Expand Down
@@ -1,6 +1,7 @@
package info.u_team.u_team_core.intern.event;

import info.u_team.u_team_core.intern.discord.DiscordRichPresence;
import info.u_team.u_team_core.intern.discord.DiscordRichPresence.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.*;
Expand All @@ -16,7 +17,10 @@ public class EventHandlerUpdateDiscordRichPresence {
@SubscribeEvent
public static void on(InitGuiEvent.Pre event) {
if (event.getGui() instanceof GuiMainMenu || event.getGui() instanceof GuiWorldSelection || event.getGui() instanceof GuiMultiplayer) {
DiscordRichPresence.setIdling();
State state = DiscordRichPresence.getCurrent();
if (state == null || state.getState() != EnumState.MENU) {
DiscordRichPresence.setIdling();
}
}
}

Expand Down
7 changes: 1 addition & 6 deletions src/test/java/info/u_team/u_team_test/block/BlockBasic.java
Expand Up @@ -9,12 +9,7 @@
public class BlockBasic extends UBlock {

public BlockBasic(String name) {
super(name, TestItemGroups.group, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.GROUND).slipperiness(0.8F).lightValue(1));
}

@Override
protected ItemBlock createItemBlock(ItemGroup group) {
return new ItemBlock(this, new Item.Properties().rarity(EnumRarity.UNCOMMON).group(group));
super(name, TestItemGroups.group, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.GROUND).slipperiness(0.8F).lightValue(1), new Item.Properties().rarity(EnumRarity.UNCOMMON));
}

}
@@ -1,6 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "uteamtest:item/basictool_axe"
}
"parent": "item/handheld",
"textures": {
"layer0": "uteamtest:item/basictool_axe"
}
}
@@ -1,6 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "uteamtest:item/basictool_hoe"
}
"parent": "item/handheld",
"textures": {
"layer0": "uteamtest:item/basictool_hoe"
}
}
@@ -1,6 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "uteamtest:item/basictool_pickaxe"
}
"parent": "item/handheld",
"textures": {
"layer0": "uteamtest:item/basictool_pickaxe"
}
}
@@ -1,6 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "uteamtest:item/basictool_shovel"
}
"parent": "item/handheld",
"textures": {
"layer0": "uteamtest:item/basictool_shovel"
}
}
@@ -1,6 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "uteamtest:item/basictool_sword"
}
"parent": "item/handheld",
"textures": {
"layer0": "uteamtest:item/basictool_sword"
}
}

0 comments on commit 751a991

Please sign in to comment.