mirror of
https://github.com/RoBaertschi/EnvironmentTech.git
synced 2025-04-20 07:03:30 +00:00
upgrade userdev and neoforge, display message from env detector above hotbar, damage item if not in creative, only add data to server side chunks and add 10 durability to env detector
This commit is contained in:
parent
5c05e112d7
commit
eda52283d6
@ -3,7 +3,7 @@ plugins {
|
|||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'net.neoforged.gradle.userdev' version '7.0.136'
|
id 'net.neoforged.gradle.userdev' version '7.0.138'
|
||||||
}
|
}
|
||||||
|
|
||||||
version = mod_version
|
version = mod_version
|
||||||
|
@ -12,7 +12,7 @@ minecraft_version=1.20.6
|
|||||||
# as they do not follow standard versioning conventions.
|
# as they do not follow standard versioning conventions.
|
||||||
minecraft_version_range=[1.20.6,1.21)
|
minecraft_version_range=[1.20.6,1.21)
|
||||||
# The Neo version must agree with the Minecraft version to get a valid artifact
|
# The Neo version must agree with the Minecraft version to get a valid artifact
|
||||||
neo_version=20.6.99-beta
|
neo_version=20.6.100-beta
|
||||||
# The Neo version range can use any version of Neo as bounds
|
# The Neo version range can use any version of Neo as bounds
|
||||||
neo_version_range=[20,)
|
neo_version_range=[20,)
|
||||||
# The loader version range can only use the major version of FML as bounds
|
# The loader version range can only use the major version of FML as bounds
|
||||||
|
@ -13,16 +13,17 @@ import robaertschi.environmenttech.data.attachments.ETAttachments;
|
|||||||
public class ETChunkEvents {
|
public class ETChunkEvents {
|
||||||
@SubscribeEvent()
|
@SubscribeEvent()
|
||||||
public static void onChunkLoad(ChunkEvent.Load event) {
|
public static void onChunkLoad(ChunkEvent.Load event) {
|
||||||
|
if (event.getLevel().isClientSide()) return;
|
||||||
if (event.isNewChunk() && event.getChunk() instanceof LevelChunk levelChunk && !event.getChunk().hasData(ETAttachments.ENV)) {
|
if (event.isNewChunk() && event.getChunk() instanceof LevelChunk levelChunk && !event.getChunk().hasData(ETAttachments.ENV)) {
|
||||||
if (levelChunk.getStatus() != ChunkStatus.FULL) {
|
if (levelChunk.getStatus() != ChunkStatus.FULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int random = event.getLevel().getRandom().nextIntBetweenInclusive(Config.minEnvForNewChunk, Config.maxEnvForNewChunk);
|
int random = event.getLevel().getRandom().nextIntBetweenInclusive(Config.minEnvForNewChunk, Config.maxEnvForNewChunk);
|
||||||
EnvironmentTech.LOGGER.info("New Chunk, set random to {}", random);
|
EnvironmentTech.LOGGER.debug("New Chunk, set random to {}", random);
|
||||||
event.getChunk().setData(ETAttachments.ENV, random);
|
event.getChunk().setData(ETAttachments.ENV, random);
|
||||||
} else if (!event.getChunk().hasData(ETAttachments.ENV)) {
|
} else if (!event.getChunk().hasData(ETAttachments.ENV)) {
|
||||||
int random = event.getLevel().getRandom().nextIntBetweenInclusive(Config.minEnvForNewChunk, Config.maxEnvForNewChunk);
|
int random = event.getLevel().getRandom().nextIntBetweenInclusive(Config.minEnvForNewChunk, Config.maxEnvForNewChunk);
|
||||||
EnvironmentTech.LOGGER.info("Chunk without data, set random to {}", random);
|
EnvironmentTech.LOGGER.debug("Chunk without data, set random to {}", random);
|
||||||
event.getChunk().setData(ETAttachments.ENV, random);
|
event.getChunk().setData(ETAttachments.ENV, random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class ETItems {
|
|||||||
public static final DeferredItem<Item> EXAMPLE_ITEM = ITEMS.registerSimpleItem("example_item", new Item.Properties().food(new FoodProperties.Builder()
|
public static final DeferredItem<Item> EXAMPLE_ITEM = ITEMS.registerSimpleItem("example_item", new Item.Properties().food(new FoodProperties.Builder()
|
||||||
.alwaysEdible().nutrition(1).saturationModifier(2f).build()));
|
.alwaysEdible().nutrition(1).saturationModifier(2f).build()));
|
||||||
|
|
||||||
public static final DeferredItem<EnvDetectorItem> ENV_DETECTOR_ITEM = ITEMS.registerItem("env_detector", EnvDetectorItem::new, new Item.Properties().stacksTo(1));
|
public static final DeferredItem<EnvDetectorItem> ENV_DETECTOR_ITEM = ITEMS.registerItem("env_detector", EnvDetectorItem::new, new Item.Properties().stacksTo(1).durability(10));
|
||||||
|
|
||||||
|
|
||||||
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> EXAMPLE_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder()
|
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> EXAMPLE_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package robaertschi.environmenttech.level.item;
|
package robaertschi.environmenttech.level.item;
|
||||||
|
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
@ -18,19 +19,23 @@ public class EnvDetectorItem extends Item {
|
|||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUseTick(Level pLevel, LivingEntity pLivingEntity, ItemStack pStack, int pRemainingUseDuration) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) {
|
public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) {
|
||||||
if (pLevel.isClientSide()) return InteractionResultHolder.pass(pPlayer.getItemInHand(pUsedHand));
|
if (pLevel.isClientSide()) return InteractionResultHolder.pass(pPlayer.getItemInHand(pUsedHand));
|
||||||
|
|
||||||
var chunk = pLevel.getChunk(pPlayer.blockPosition());
|
var chunk = pLevel.getChunk(pPlayer.blockPosition());
|
||||||
|
|
||||||
if (chunk.hasData(ETAttachments.ENV)) {
|
if (chunk.hasData(ETAttachments.ENV)) {
|
||||||
pPlayer.sendSystemMessage(Component.literal("Chunk has " + chunk.getData(ETAttachments.ENV) + " ENV"));
|
pPlayer.displayClientMessage(Component.literal("Chunk has " + chunk.getData(ETAttachments.ENV) + " ENV").withStyle(ChatFormatting.GREEN), true);
|
||||||
} else {
|
} else {
|
||||||
pPlayer.sendSystemMessage(Component.literal("Warning: This chunk does not have the ENV attachment"));
|
pPlayer.displayClientMessage(Component.literal("Warning: This chunk does not have the ENV attachment, please report this to the Author of the Mod.").withStyle(ChatFormatting.YELLOW), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pPlayer.isCreative()) {
|
||||||
|
pPlayer.getItemInHand(pUsedHand).hurtAndBreak(1, pLevel.getRandom(), pPlayer, () -> {
|
||||||
|
pPlayer.getItemInHand(pUsedHand).setCount(0);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return InteractionResultHolder.consume(pPlayer.getItemInHand(pUsedHand));
|
return InteractionResultHolder.consume(pPlayer.getItemInHand(pUsedHand));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user